This function fits the model using least squares. It takes an optional pattern matrix P as in (6.51), which specifies which \(\beta _{ij}\)'s are zero.
An \(N \times P\) design matrix.
The \(N \times Q\) matrix of observations.
A \(Q \times L\) design matrix
An optional \(N \times P\) matrix of 0's and 1's indicating which elements of \(\beta\) are allowed to be nonzero.
A list with the following components:
The least-squares estimate of \(\beta\).
The \(P \times L\) matrix with the \(ij\)th element being the standard error of \(\hat{\beta}_ij\).
The \(P \times L\) matrix with the \(ij\)th element being the \(t\)-statistic based on \(\hat{\beta}_{ij}\).
The estimated covariance matrix of the \(\hat{\beta}_{ij}\)'s.
A \(p\)-dimensional vector of the degrees of freedom for the \(t\)-statistics, where the \(j\)th component contains the degrees of freedom for the \(j\)th column of \(\hat{\beta}\).
The \(Q \times Q\) matrix \(\hat{\Sigma}_z\).
The \(Q \times Q\) residual sum of squares and crossproducts matrix.
# Mouth Size Example from 6.4.1
data(mouths)
x <- cbind(1, mouths[, 5])
y <- mouths[, 1:4]
z <- cbind(c(1, 1, 1, 1), c(-3, -1, 1, 3), c(1, -1, -1, 1), c(-1, 3, -3, 1))
bothsidesmodel(x, y, z)
#> $Beta
#> [,1] [,2] [,3] [,4]
#> [1,] 24.968750 0.7843750 0.2031250 -0.05625000
#> [2,] -2.321023 -0.3048295 -0.2144886 0.07215909
#>
#> $SE
#> [,1] [,2] [,3] [,4]
#> [1,] 0.4860008 0.08599951 0.1275764 0.08868435
#> [2,] 0.7614168 0.13473534 0.1998739 0.13894168
#>
#> $T
#> [,1] [,2] [,3] [,4]
#> [1,] 51.375949 9.120691 1.592183 -0.634272
#> [2,] -3.048294 -2.262432 -1.073120 0.519348
#>
#> $Covbeta
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.236196733 0.0042588778 -0.0026296165 -0.0097208807 -0.236196733
#> [2,] 0.004258878 0.0073959162 -0.0031372514 0.0005659801 -0.004258878
#> [3,] -0.002629616 -0.0031372514 0.0162757457 -0.0003583097 0.002629616
#> [4,] -0.009720881 0.0005659801 -0.0003583097 0.0078649148 0.009720881
#> [5,] -0.236196733 -0.0042588778 0.0026296165 0.0097208807 0.579755617
#> [6,] -0.004258878 -0.0073959162 0.0031372514 -0.0005659801 0.010453609
#> [7,] 0.002629616 0.0031372514 -0.0162757457 0.0003583097 -0.006454513
#> [8,] 0.009720881 -0.0005659801 0.0003583097 -0.0078649148 -0.023860343
#> [,6] [,7] [,8]
#> [1,] -0.0042588778 0.0026296165 0.0097208807
#> [2,] -0.0073959162 0.0031372514 -0.0005659801
#> [3,] 0.0031372514 -0.0162757457 0.0003583097
#> [4,] -0.0005659801 0.0003583097 -0.0078649148
#> [5,] 0.0104536092 -0.0064545132 -0.0238603435
#> [6,] 0.0181536125 -0.0077005262 0.0013892239
#> [7,] -0.0077005262 0.0399495577 -0.0008794873
#> [8,] 0.0013892239 -0.0008794873 0.0193047908
#>
#> $df
#> [1] 25 25 25 25
#>
#> $Sigmaz
#> z1 z2 z3 z4
#> z1 3.77914773 0.068142045 -0.042073864 -0.155534091
#> z2 0.06814205 0.118334659 -0.050196023 0.009055682
#> z3 -0.04207386 -0.050196023 0.260411932 -0.005732955
#> z4 -0.15553409 0.009055682 -0.005732955 0.125838636
#>
#> $ResidSS
#> [1] 80
#>
#> $Dim
#> [1] 18
#>
#> $Cp
#> [1] 116
#>