Learn R Programming

robcp (version 0.2.5)

sigma2: Autocorrelation

Description

Estimates the long run variance respectively covariance matrix of the supplied time series.

Usage

sigma2(x, b_n)

Arguments

x

vector or matrix with each column representing a time series (numeric).

b_n

Must be greater than 0. default is \(n^{1/3}\) with \(n\) being the number of observations.

Value

long run variance \(sigma^2\) respectively \(\Sigma\) (numeric)

Details

The long run variance equals \(n\) times the asymptotic variance of the arithmetic mean of a short range dependent time series, where \(n\) is the length of the time series. It is used to standardize CUSUM Tests.

The long run variance is estimated by a kernel estimator using the bandwidth \(b_n = n^{1/3}\) and the flat top kernel $$k(x) = x * 1_{|x| < 0.5} + (2 - |x|) * 1_{0.5 < |x| < 1}$$. In the one dimensional case this results in:

$$\hat{\sigma}^2 = (1 / n) \sum_{i = 1}^n (x[i] - mean(x))^2 + (2 / n) \sum_{h = 1}^{b_n} \sum_{i = 1}^{n - h} (x[i] - mean(x)) * (x[i + h] - mean(x)) * k(h / b_n).$$

If x is a multivariate timeseries the \(k,l\)-element of \(\Sigma\) is estimated by

$$\hat{\Sigma}^{(k,l)} = (1 / n) \sum_{i,j = 1}^{n}(x[i]^{(k)} - mean(x)^{(k)}) * (x[j]^{(l)} - mean(x)^{(l)}) * k((i-j) / b_n).$$

See Also

psi, h_cumsum, teststat, pKSdist, huber_cusum

Examples

Run this code
# NOT RUN {
Z <- c(rnorm(20), rnorm(20, 2))
sigma2(Z)
# }

Run the code above in your browser using DataLab