nse.nw: Newey-West NSE estimators.

Description Usage Arguments Value References Examples

Description

Calculate the variance of the mean with the Newey West (1987, 1994) HAC estimator.

This is a wrapper around lrvar from the sandwich package.

Usage

1
nse.nw(x, prewhite = FALSE)

Arguments

x

A numeric vector or matrix.

prewhite

A bool indicating if the time-serie will be prewhitened before analysis.

Value

The variance estimator in the univariate case or the variance-covariance matrix estimator in the multivariate case.

References

Andrews, Donald WK. "Heteroskedasticity and autocorrelation consistent covariance matrix estimation." Econometrica: Journal of the Econometric Society 59.03 (1991): 817-858.

Newey, Whitney K., and Kenneth D. West. "A simple, positive semi-definite, heteroskedasticity and autocorrelationconsistent covariance matrix.", Econometrica: Journal of the Econometric Society 55.03 (1987) : 703-708.

Newey, Whitney K., and Kenneth D. West. "Automatic lag selection in covariance matrix estimation." The Review of Economic Studies 61.4 (1994): 631-653.

Zeileis, Achim. "Econometric computing with HC and HAC covariance matrix estimators." (2004).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
n = 1000
ar = c(0.9,0.6)
mean = c(1,5)
sd = c(10,2)
 
Ts1 = as.vector(arima.sim(n = n, list(ar = ar[1]), sd = sd[1]) + mean[1])
Ts2 = as.vector(arima.sim(n = n, list(ar = ar[2]), sd = sd[2]) + mean[2])
Ts = cbind(Ts1,Ts2)
 
nse::nse.nw(x = Ts1)
nse::nse.nw(x = Ts)
nse::nse.nw(x = Ts1, prewhite = TRUE)
nse::nse.nw(x = Ts, prewhite = TRUE)

AmurG/nse documentation built on May 5, 2019, 4:56 a.m.