R/bsm.simple.R
bsm.simple.Rd
Generates \(\beta\) estimates for MLE using a conditioning approach.
bsm.simple(x, y, z)
An \(N \times (P + F)\) design matrix, where \(F\) is the number of columns conditioned on. This is equivalent to the multiplication of \(xyzb\).
The \(N \times (Q - F)\) matrix of observations, where \(F\) is the number of columns conditioned on. This is equivalent to the multiplication of \(Yz_a\).
A \((Q - F) \times L\) design matrix, where \(F\) is the number of columns conditioned on.
A list with the following components:
The least-squares estimate of \(\beta\).
The \((P + F) \times L\) matrix with the \(ij\)th element being the standard error of \(\hat{\beta}_ij\).
The \((P + F) \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 - F) \times (Q - F)\) matrix \(\hat{\Sigma}_z\).
The \(Q \times Q\) residual sum of squares and crossproducts matrix.
The technique used to calculate the estimates is described in section 9.3.3.
# Taken from section 9.3.3 to show equivalence to methods.
data(mouths)
x <- cbind(1, mouths[, 5])
y <- mouths[, 1:4]
z <- cbind(1, c(-3, -1, 1, 3), c(-1, 1, 1, -1), c(-1, 3, -3, 1))
yz <- y %*% solve(t(z))
yza <- yz[, 1:2]
xyzb <- cbind(x, yz[, 3:4])
lm(yza ~ xyzb - 1)
#>
#> Call:
#> lm(formula = yza ~ xyzb - 1)
#>
#> Coefficients:
#> [,1] [,2]
#> xyzb1 24.93713 0.82680
#> xyzb2 -2.27175 -0.35044
#> xyzb3 0.18897 0.19136
#> xyzb4 -1.24459 0.06324
#>
bsm.simple(xyzb, yza, diag(2))
#> $Beta
#> [,1] [,2]
#> [1,] 24.9371256 0.8268033
#> [2,] -2.2717454 -0.3504386
#> [3,] 0.1889661 0.1913639
#> [4,] -1.2445893 0.0632445
#>
#> $SE
#> [,1] [,2]
#> [1,] 0.5205837 0.09051471
#> [2,] 0.7935186 0.13797033
#> [3,] 0.7732514 0.13444644
#> [4,] 1.1123569 0.19340725
#>
#> $T
#> [,1] [,2]
#> [1,] 47.9022397 9.1344632
#> [2,] -2.8628761 -2.5399562
#> [3,] 0.2443787 1.4233468
#> [4,] -1.1188759 0.3270017
#>
#> $Covbeta
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.271007398 0.005297044 -0.273389373 -0.005343601 0.1199197919
#> [2,] 0.005297044 0.008192913 -0.005343601 -0.008264923 0.0023439227
#> [3,] -0.273389373 -0.005343601 0.629671752 0.012307409 -0.1262809490
#> [4,] -0.005343601 -0.008264923 0.012307409 0.019035812 -0.0024682563
#> [5,] 0.119919792 0.002343923 -0.126280949 -0.002468256 0.5979177242
#> [6,] 0.002343923 0.003625334 -0.002468256 -0.003817641 0.0116867527
#> [7,] 0.064067145 0.001252241 -0.083442521 -0.001630947 -0.0272399259
#> [8,] 0.001252241 0.001936835 -0.001630947 -0.002522578 -0.0005324249
#> [,6] [,7] [,8]
#> [1,] 0.0023439227 0.0640671449 0.0012522406
#> [2,] 0.0036253343 0.0012522406 0.0019368347
#> [3,] -0.0024682563 -0.0834425209 -0.0016309470
#> [4,] -0.0038176405 -0.0016309470 -0.0025225780
#> [5,] 0.0116867527 -0.0272399259 -0.0005324249
#> [6,] 0.0180758456 -0.0005324249 -0.0008234991
#> [7,] -0.0005324249 1.2373378647 0.0241847013
#> [8,] -0.0008234991 0.0241847013 0.0374063642
#>
#> $df
#> [1] 23
#>
#> $Sigmaz
#> [,1] [,2]
#> [1,] 3.88871861 0.07600794
#> [2,] 0.07600794 0.11756112
#>
#> $Cx
#> [,1] [,2] [,3] [,4]
#> [1,] 0.06969067 -0.07030320 0.030837868 0.016475130
#> [2,] -0.07030320 0.16192268 -0.032473666 -0.021457588
#> [3,] 0.03083787 -0.03247367 0.153757004 -0.007004859
#> [4,] 0.01647513 -0.02145759 -0.007004859 0.318186526
#>