Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rankinfo

Checking the rank of the fixed-effects design matrix


Description

By default, fitting functions in spaMM check the rank of the design matrix for fixed effects, as stats::lm or stats::glm do (but not, say, nlme::lme). This computation can be quite long. To save time when fitting different models with the same fixed-effect terms to the same data, the result of the check can be extracted from a return object by get_rankinfo(), and can be provided as argument control.HLfit$rankinfo to another fit. Alternatively, the check will not be performed if control.HLfit$rankinfo is set to NA.

Usage

get_rankinfo(object)

Arguments

object

An object of class HLfit, as returned by the fitting functions in spaMM.

Details

The check is performed by a call to qr() methods for either dense or sparse matrices. If the design matrix is singular, a set of columns from the design matrix that define a non-singular matrix is identified. Note that different sets may be identified by sparse- and dense-matrix qr methods.

Value

A list with elements rank, whichcols (a set of columns that define a non-singular matrix), and method (identifying the algorithm used).

Examples

## Data preparation
# Singular matrix from ?Matrix::qr :
singX <- cbind(int = 1,
           b1=rep(1:0, each=3), b2=rep(0:1, each=3),
           c1=rep(c(1,0,0), 2), c2=rep(c(0,1,0), 2), c3=rep(c(0,0,1),2))
rownames(singX) <- paste0("r", seq_len(nrow(singX)))
donn <- as.data.frame(singX)
set.seed(123)
donn$y <- runif(6)

fitlm <- fitme(y~int+ b1+b2+c1+c2+c3,data=donn)
get_rankinfo(fitlm)

spaMM

Mixed-Effect Models, with or without Spatial Random Effects

v3.10.0
CeCILL-2
Authors
François Rousset [aut, cre, cph] (<https://orcid.org/0000-0003-4670-0371>), Jean-Baptiste Ferdy [aut, cph], Alexandre Courtiol [aut] (<https://orcid.org/0000-0003-0637-2959>), GSL authors [ctb] (src/gsl_bessel.*)
Initial release
2022-02-06

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.