avm.vcov: Estimate Covariance Matrix of Ordinary Least Squares...

View source: R/avm.vcov.R

avm.vcovR Documentation

Estimate Covariance Matrix of Ordinary Least Squares Estimators Using Error Variance Estimates from an Auxiliary Variance Model

Description

The function simply calculates

\mathrm{Cov}{\hat{\beta}}=(X'X)^{-1}X'\hat{\Omega}X(X'X)^{-1}

, where X is the design matrix of a linear regression model and \hat{\Omega} is an estimate of the diagonal variance-covariance matrix of the random errors, whose diagonal elements have been obtained from an auxiliary variance model fit with alvm.fit or anlvm.fit.

Usage

avm.vcov(object, as_matrix = TRUE)

Arguments

object

Either an object of class "alvm.fit" or an object of class "anlvm.fit"

as_matrix

A logical. If TRUE (the default), a p \times p matrix is returned, where p is the number of columns in X. Otherwise, a numeric vector of length p is returned.

Value

Either a numeric matrix or a numeric vector, whose (diagonal) elements are \widehat{\mathrm{Var}}(\hat{\beta}_j), j=1,2,\ldots,p.

References

\insertAllCited

See Also

alvm.fit, anlvm.fit, avm.fwls. If a matrix is returned, it can be passed to coeftest for implementation of a quasi-t-test of significance of the \beta coefficients.

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
myalvm <- alvm.fit(mainlm = mtcars_lm, model = "linear",
   varselect = "qgcv.linear")
myvcov <- avm.vcov(myalvm)
lmtest::coeftest(mtcars_lm, vcov. = myvcov)


skedastic documentation built on May 29, 2024, 12:20 p.m.