Learn R Programming

dlsem (version 2.4.6)

lmHAC: Heteroskedasticty and autocorrelation consistent covariance matrix

Description

The heteroskedasticty and autocorrelation consistent (HAC) covariance matrix of least square estimates (Newey & West, 1978) is applied to an object of class lm. A single group factor may be taken into account.

Usage

lmHAC(x, group = NULL)

Arguments

x

An object of class lm.

group

The name of the group factor (optional). If NULL, no groups are considered.

Value

An object of class hac and lm. The HAC covariance matrix is stored into the component vcov of the object, which is taken into account by the summary and the vcov methods. The HAC covariance matrix has the attribute max.lag, indicating the maximum lag of autocorrelation, which is automatically computed based on fit to data.

References

W. K. Newey, and K. D. West (1978). A simple, positive semi-definite, heteroskedasticity and autocorrelation consistent covariance matrix. Econometrica, 55(3), 703-708.

Examples

Run this code
# NOT RUN {
data(industry)

m0 <- lm(Consum ~ -1+Region+ecq(Job,0,5,x.group=Region), data=industry)
summary(m0)
confint(m0)

m0_hac <- lmHAC(m0,group="Region")
summary(m0_hac)
confint(m0_hac)
# }

Run the code above in your browser using DataLab