lmHAC: Heteroskedasticty and autocorrelation consistent covariance...

Description Usage Arguments Value Note References Examples

View source: R/dlsem.r

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

1

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.

Note

If group is not NULL, the HAC covariance matrix is computed within each group. Residuals are assumed to be temporally ordered within each group.

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

1
2
3
4
5
6
7
8
9
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)

dlsem documentation built on April 17, 2020, 1:14 a.m.