## We will generate some data and pretend that the Predictors are being held fixed
library(MASS)
R <- matrix(.5, 3, 3); diag(R) <- 1
Beta <- c(.2, .3, .4)
rm(list = ".Random.seed", envir = globalenv()); set.seed(123)
X <- mvrnorm(n = 200, mu = rep(0, 3), Sigma = R, empirical = TRUE)
y <- X %*% Beta + .64*scale(rnorm(200))
seBetaFixed(X, y)
# $covBeta
# b1 b2 b3
# b1 0.003275127 -0.001235665 -0.001274303
# b2 -0.001235665 0.003037100 -0.001491736
# b3 -0.001274303 -0.001491736 0.002830157
#
# $seBeta
# b1 b2 b3
# 0.05722872 0.05510989 0.05319922
## you can also supply covariances instead of raw data
seBetaFixed(cov.x = cov(X), cov.xy = cov(X, y), var.y = var(y), Nobs = 200)
# $covBeta
# b1 b2 b3
# b1 0.003275127 -0.001235665 -0.001274303
# b2 -0.001235665 0.003037100 -0.001491736
# b3 -0.001274303 -0.001491736 0.002830157
#
# $seBeta
# b1 b2 b3
# 0.05722872 0.05510989 0.05319922
Run the code above in your browser using DataLab