vcov2 {lavaSearch2} | R Documentation |
Variance-Covariance With Small Sample Correction
Description
Extract the variance-covariance matrix from a latent variable model.
Similar to stats::vcov
but with small sample correction.
Usage
vcov2(object, robust, cluster, as.lava, ...)
## S3 method for class 'lvmfit'
vcov2(
object,
robust = FALSE,
cluster = NULL,
as.lava = TRUE,
ssc = lava.options()$ssc,
...
)
## S3 method for class 'lvmfit2'
vcov2(object, robust = FALSE, cluster = NULL, as.lava = TRUE, ...)
## S3 method for class 'lvmfit2'
vcov(object, robust = FALSE, cluster = NULL, as.lava = TRUE, ...)
Arguments
object |
a |
robust |
[logical] should robust standard errors be used instead of the model based standard errors? Should be |
cluster |
[integer vector] the grouping variable relative to which the observations are iid. |
as.lava |
[logical] if |
... |
additional argument passed to |
ssc |
[character] method used to correct the small sample bias of the variance coefficients: no correction ( |
Details
When argument object is a lvmfit
object, the method first calls estimate2
and then extract the variance-covariance matrix.
Value
A matrix with as many rows and columns as the number of coefficients.
See Also
estimate2
to obtain lvmfit2
objects.
Examples
#### simulate data ####
n <- 5e1
p <- 3
X.name <- paste0("X",1:p)
link.lvm <- paste0("Y~",X.name)
formula.lvm <- as.formula(paste0("Y~",paste0(X.name,collapse="+")))
m <- lvm(formula.lvm)
distribution(m,~Id) <- Sequence.lvm(0)
set.seed(10)
d <- lava::sim(m,n)
#### linear models ####
e.lm <- lm(formula.lvm,data=d)
#### latent variable models ####
e.lvm <- estimate(lvm(formula.lvm),data=d)
vcov0 <- vcov(e.lvm)
vcovSSC <- vcov2(e.lvm)
vcovSSC/vcov0
vcovSSC[1:4,1:4]/vcov(e.lm)