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.

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  5.682584e-17 -0.4826649 -0.35335103
#> [2,]    0    0    0    0    0    0 -1.186106e-16  0.6104740 -0.01007794
#> [3,]    0    0    0    0    0    0  3.210396e-17  1.1622021 -1.19955784
#> [4,]    0    0    0    0    0    0 -2.204435e-16 -1.7623062 -1.16636622
#>           [,10]      [,11]         [,12]
#> [1,] -1.1018359 -0.8645554 -2.359216e-17
#> [2,]  1.0737398 -1.6380467 -4.257590e-17
#> [3,]  1.1154563  0.7869244  2.085957e-17
#> [4,] -0.2046462  0.1530720  4.749647e-17
#> attr(,"B")
#>             [,1]        [,2]         [,3]        [,4]        [,5]         [,6]
#> [1,]  0.18306603 -0.01878527  0.980023850 -0.03529784  0.06602438  0.009057455
#> [2,]  0.36925708  0.10803383 -0.038645944  0.91944740  0.07084053  0.009082484
#> [3,] -0.39272102  0.71714997  0.050494693  0.03233355  0.56922896 -0.062043116
#> [4,] -0.05150224  0.10570047  0.006753517  0.00349335 -0.06146960  0.991129964