rankinfo function

Checking the rank of the fixed-effects design matrix

Checking the rank of the fixed-effects design matrix

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.

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.

Returns

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)
  • Maintainer: François Rousset
  • License: CeCILL-2
  • Last published: 2024-06-09