Determines the optimal and data-driven moving average lag $q$.
Usage
qn(x)
Arguments
x
a numeric vector or univariate time series.
Value
qnthe optimal moving average lag $q$.
Details
For univariate time series $x[t]$, the moving average filter is defined as
$$mhat[t] = \sum x[t]/(2q+1)$$ for $q + 1 \le t \le n + q$. The optimal and
data-driven moving average lag $q$ can be determined by using the rule-of-thumb
estimator proposed in Section 3 of D. Qiu et al. (2013). It is determined by
sample size $n$, variance $\gamma(0)$ and curvature $m''$ of the univariate
series, where $m''$ is the second derivative of an unknown nonparameteric trend
function $m(t)$. To obtain the preliminary estimators of variance $\gamma(0)$ and
curvature $m''$, $m(t)$ can be initially fitted by a cubic polynomial model.
See L. Yang and R. Tscherning (1999) for more details. For the case when $q > n$,
the optimal moving average lag $q$ is set to be an integer part of $n^{4/5}/2$.
References
D. Qiu, Q. Shao, and L. Yang (2013), Efficient inference for autoregressive coeficient in
the presence of trend. Journal of Multivariate Analysis 114, 40-53.
L. Yang, R. Tscherning (1999), Multivariate bandwidth selection for local linear
regression. Journal of the Royal Statistical Society. Series B. Statistical
Methodology 61, 793-815.