linear_algebra | R Documentation |
Finds the basis of the (right) null space of a matrix, a vector (a 1-column matrix) or a model object for which a model matrix can be extracted. I.e. finds basis for the (right) null space x : Mx = 0.
is_caracas_matrix(M)
basis_intersect(M, M2)
basis_orthcomp(M, M2 = NULL)
basis_col(M)
basis_row(M)
basis_null(M)
basis_leftnull(M)
rref(M)
M , M2 |
A matrix or a vector (a 1-column matrix). |
A matrix (possibly with zero columns if the null space consists only of the zero vector).
Søren Højsgaard, sorenh@math.aau.dk
Null
M <- matrix(c(1,1,1,1,1,1,0,0,0,0,1,1), nrow=4)
basis_null(M)
MASS::Null(t(M))
M <- matrix(c(1,1,1,1))
basis_null(M)
MASS::Null(t(M))
m0 <- lm(breaks ~ wool + tension, data=warpbreaks)
basis_null(model.matrix(m0))
MASS::Null(t(model.matrix(m0)))
## Make balanced dataset
dat.bal <- expand.grid(list(A=factor(1:2), B=factor(1:3), C=factor(1:3)))
dat.bal$y <- rnorm(nrow(dat.bal))
## Make unbalanced dataset: 'B' is nested within 'C' so B=1 is only
## found when C=1 and B=2,3 are found in each C=2,3,4
dat.nst <- dat.bal
dat.nst$C <-factor(c(1,1,2,2,2,2,1,1,3,3,3,3,1,1,4,4,4,4))
xtabs(y ~ C+B+A , data=dat.nst)
mod.bal <- lm(y ~ A + B*C, data=dat.bal)
mod.nst <- lm(y ~ A + B*C, data=dat.nst)
basis_null( model.matrix(mod.bal) )
basis_null( model.matrix(mod.nst) )
MASS::Null( t(model.matrix(mod.bal)) )
MASS::Null( t(model.matrix(mod.nst)) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.