Skip to contents

Determine a transformation B of the rows of a matrix L such that B %*% L is estimable. A practical example is in jointly testing a set of contrasts L in a linear model, and we need to restrict to the subspace spanned by the rows of L that are estimable.

Usage

estble.subspace (L, nbasis, tol = 1e-8)

Arguments

L

A matrix of dimensions k by p

nbasis

A k by b matrix whose columns form a basis for non-estimable linear functions -- such as is returned by nonest.basis

tol

Numeric tolerance for assessing nonestimability. See is.estble.

Details

We require B such that all the rows of M = B %*% L are estimable, i.e. orthogonal to the columns of nbasis. Thus, we need B %*% L %*% nbasis to be zero, or equivalently, t(B) must be in the null space of t(L %*% nbasis). This can be found using nonest.basis.

Value

An r by p matrix M = B %*% L

whose rows are all orthogonal to the columns of

nbasis. The matrix B is attached as attr(M, "B"). Note that if any rows of L were non-estimable, then r

will be less than k. In fact, if there are no estimable functions in the row space of L, then r = 0.

Author

Russell V. Lenth <russell-lenth@uiowa.edu>

Examples

### Find a set of estimable interaction contrasts for a 3 x 4 design 
### with two empty cells.
des <- expand.grid(A = factor(1:3), B = factor(1:4))
des <- des[-c(5, 12), ]  # cells (2,2) and (3,4) are empty

X <- model.matrix(~ A * B, data = des)
N <- nonest.basis(X)

L <- cbind(matrix(0, nrow = 6, ncol = 6), diag(6))
# i.e., give nonzero weight only to interaction effects

estble.subspace(L, N)
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,]    0    0    0    0    0    0    0    0    1     0     0     0
#> [2,]    0    0    0    0    0    0    0    0    0     1     0     0
#> [3,]    0    0    0    0    0    0    0    0    0     0     1     0
#> [4,]    0    0    0    0    0    0    0   -1    0     0     0     0
#> attr(,"B")
#>      [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,]    0    0    1    0    0    0
#> [2,]    0    0    0    1    0    0
#> [3,]    0    0    0    0    1    0
#> [4,]    0   -1    0    0    0    0

# Tougher demo: create a variation where all rows of L are non-estimable
LL <- matrix(rnorm(36), ncol = 6) %*% L
estble.subspace(LL, N)
#>      [,1] [,2] [,3] [,4] [,5] [,6]          [,7]        [,8]       [,9]
#> [1,]    0    0    0    0    0    0  3.791214e-16  0.94444860 -2.2476951
#> [2,]    0    0    0    0    0    0  3.499401e-16  0.79383782  0.2564956
#> [3,]    0    0    0    0    0    0 -3.144207e-16 -0.74158401  0.4100229
#> [4,]    0    0    0    0    0    0 -5.640383e-16  0.05621727  1.2228212
#>           [,10]      [,11]         [,12]
#> [1,] -0.3746606 -2.2247074 -7.309463e-17
#> [2,]  0.8589392 -0.5328160  2.575030e-16
#> [3,] -1.0361710 -0.5532579  5.432394e-17
#> [4,]  1.1290187 -0.8990313  1.707290e-16
#> attr(,"B")
#>            [,1]       [,2]       [,3]       [,4]        [,5]        [,6]
#> [1,] -0.6542234  0.3710275 0.54920429  0.2615446  0.14314236  0.20930771
#> [2,] -0.3512571 -0.8812953 0.07252168  0.2916776 -0.09453098 -0.02580085
#> [3,]  0.1293034 -0.1892932 0.12285602 -0.1427821  0.95331535 -0.05619815
#> [4,]  0.3123951 -0.1644018 0.21154095 -0.1148613 -0.06632638  0.90168701