Function which calculates the numerical standard error with the spectrum at zero estimator.
nse.spec0(
x,
type = c("ar", "glm", "daniell", "modified.daniell", "tukey-hanning", "parzen",
"triweight", "bartlett-priestley", "triangular", "qs"),
lag.prewhite = 0,
welch = FALSE,
steep = FALSE
)The NSE estimator.
A numeric vector.
Method to use in estimating the spectral density function, among "ar", "glm", "daniell",
"modified.daniell", "tukey-hanning",
"parzen", "triweight",
"bartlett-priestley", "triangular", and "qs". See *Details*.
Default is type = "ar".
Prewhite the series before analysis (integer or NULL). When lag.prewhite = NULL this performs automatic lag selection. Default is lag.prewhite = 0 that is no prewhitening.
Use Welch's method (Welsh, 1967) to estimate the spectral density.
Use steep or sharp version of the kernel (Phillips et al., 2006) (only available for type: "qs","triangular", and "parzen"). lag.prewhite must be set to 0 to use steep version.
David Ardia and Keven Bluteau
Welsh's method use 50% overlap and 8 sub-samples.
The method "ar" estimates the spectral density using an autoregressive model,
"glm" using a generalized linear model Heidelberger & Welch (1981),
"daniell" uses daniell window from the R kernel function,
"modified.daniell" uses daniell window the R kernel function,
"tukey-hanning" uses the tukey-hanning window,
"parzen" uses the parzen window,
"triweight" uses the triweight window,
"bartlett-priestley" uses the Bartlett-Priestley window,
"triangular" uses the triangular window, and
"qs" uses the quadratic-spectral window,
This kernel based variance estimator apply weights to smooth out the spectral density using a kernel and takes the spectral density at frequency zero which is equivalent to the variance of the serie. Bandwidth for the kernel is automatically selected using cross-validatory methods (Hurvich, 1985).
Heidelberger, P., Welch, Peter D. (1981). A spectral method for confidence interval generation and run length control in simulations. Communications of the ACM 24(4), 233-245.
Phillips, P. C., Sun, Y., & Jin, S. (2006). Spectral density estimation and robust hypothesis testing using steep origin kernels without truncation. International Economic Review, 47(3), 837-894.
Welch, P. D. (1967), The use of Fast Fourier Transform for the estimation of power spectra: A method based on time averaging over short, modified periodograms. IEEE Transactions on Audio and Electroacoustics, AU-15(2): 70-73,
Hurvich, C. M. (1985). Data-driven choice of a spectrum estimate: extending the applicability of cross-validation methods. Journal of the American Statistical Association, 80(392), 933-940.
if (FALSE) {
n = 1000
ar = 0.9
mean = 1
sd = 1
set.seed(1234)
x = c(arima.sim(n = n, list(ar = ar), sd = sd) + mean)
nse.spec0(x = x, type = "parzen", lag.prewhite = 0, welch = TRUE, steep = TRUE)
}
Run the code above in your browser using DataLab