Learn R Programming

spaMM (version 4.5.0)

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)

Value

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

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.

Examples

Run this code
## 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)

Run the code above in your browser using DataLab