Learn R Programming

lavaSearch2 (version 1.4)

vcov2: Extract the Variance Covariance Matrix of the Model Parameters

Description

Extract the variance covariance matrix of the model parameters from a Gaussian linear model.

Usage

vcov2(object, ...)

# S3 method for lm vcov2(object, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for gls vcov2(object, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for lme vcov2(object, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for lvmfit vcov2(object, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for lm2 vcov2(object, param = NULL, data = NULL, ...)

# S3 method for gls2 vcov2(object, param = NULL, data = NULL, ...)

# S3 method for lme2 vcov2(object, param = NULL, data = NULL, ...)

# S3 method for lvmfit2 vcov2(object, param = NULL, data = NULL, ...)

Arguments

object

a linear model or a latent variable model

...

arguments to be passed to sCorrect.

param

[optional] the fitted parameters.

data

[optional] the data set.

bias.correct

[logical] should the standard errors of the coefficients be corrected for small sample bias? Only relevant if the sCorrect function has not yet be applied to the object.

Value

A matrix.

Details

If argument p or data is not null, then the small sample size correction is recomputed to correct the influence function.

See Also

sCorrect to obtain lm2, gls2, lme2, or lvmfit2 objects.

Examples

Run this code
# NOT RUN {
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 model
e.lm <- lm(formula.lvm,data=d)
vcov.tempo <- vcov2(e.lm, bias.correct = TRUE)
vcov.tempo[rownames(vcov(e.lm)),colnames(vcov(e.lm))]/vcov(e.lm)

## latent variable model
e.lvm <- estimate(lvm(formula.lvm),data=d)
vcov.tempo <- vcov2(e.lvm, bias.correct = FALSE)
vcov.tempo/vcov(e.lvm)

# }

Run the code above in your browser using DataLab