## Simple Example
data(Pupfish)
fit <- lm.rrpp(coords ~ Pop, data = Pupfish, print.progress = FALSE)
QR <- QRforX(model.matrix(fit))
QR$Q
QR$R
QR$rank
QR$S4
## Not run, but one could get base::qr and Matrix::qr results as
# base::qr(as.matrix(QR$X))
# Matrix::qr(QR$X)
## Complex example
data("PupfishHeads")
fit <- suppressWarnings(lm.rrpp(headSize ~ sex +
locality/year, data = PupfishHeads))
X <- model.matrix(fit)
dim(X) # Already reduced
colnames(X)
X <- model.matrix(terms(fit), fit$LM$data)
dim(X) # Retains redundant parameters
colnames(X)
QR <- QRforX(X)
QR$fixed
dim(QR$X) # Reduced again
colnames(QR$X)
Run the code above in your browser using DataLab