vcovHAC: Heteroskedasticty and autocorrelation consistent covariance... In dlsem: Distributed-Lag Linear Structural Equation Models

Description

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

Usage

 `1` ```vcovHAC(x, group = NULL) ```

Arguments

 `x` An object of class `lm` or `dlsem`. `group` The name of the group factor (optional). If `NULL`, no groups are considered.

Value

A matrix if `x` is of class `lm`, or, if `x` is of class `dlsem`, a list of matrices, one for each regression model. Each matrix has the attribute `max.lag`, indicating the maximum lag of autocorrelation, automatically computed based on fit to data. If `group` is not `NULL`, this is computed within each group.

Note

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``` ```data(industry) m0 <- lm(Consum ~ -1+Region+quec.lag(Job,0,5,x.group=Region), data=industry) # traditional covariance matrix S <- vcov(m0) # HAC covariance matrix S_hac <- vcovHAC(m0,group="Region") # comparison of standard errors cbind(traditional=sqrt(diag(S)),hac=sqrt(diag(S_hac))) ```

Example output

```Loading required package: graph

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

The following objects are masked from 'package:base':

Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, basename, cbind, colMeans, colSums, colnames,
dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
intersect, is.unsorted, lapply, lengths, mapply, match, mget,
order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
union, unique, unsplit, which, which.max, which.min

Region1                                6.40615073  6.92023281
Region2                                5.93683392  6.66213635
Region3                                7.25925699  8.31215085
Region4                                7.33081795  8.63348557
Region5                                7.33584368  8.50646415
Region6                                6.67594033 10.03832277
Region7                                7.68156340 11.43634646
Region8                                4.97581770  5.93481885
Region9                                4.43846357  4.25452702
Region10                               6.27941589  6.95906473
quec.lag(Job, 0, 5, x.group = Region)  0.01001767  0.01198433
```

dlsem documentation built on Oct. 30, 2019, 11:40 a.m.