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{β}}=(X'X)^{-1}X'\hat{Ω}X(X'X)^{-1}

, where X is the design matrix of a linear regression model and \hat{Ω} 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{β}_j), j=1,2,…,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 β 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 Nov. 10, 2022, 5:43 p.m.