stat_hs function

Compute the Hidalgo-Seo Statistic

Compute the Hidalgo-Seo Statistic

This function computes the Hidalgo-Seo statistic for a change in mean model.

stat_hs(dat, estimate = FALSE, corr = TRUE, get_all_vals = FALSE, custom_var = NULL, use_kernel_var = FALSE, kernel = "ba", bandwidth = "and")

Arguments

  • dat: The data vector

  • estimate: Set to TRUE to return the estimated location of the change point

  • corr: If TRUE, the long-run variance will be computed under the assumption of correlated residuals; ignored if custom_var

    is not NULL or use_kernel_var is TRUE

  • get_all_vals: If TRUE, return all values for the statistic at every tested point in the data set

  • custom_var: Can be a vector the same length as dat consisting of variance-like numbers at each potential change point (so each entry of the vector would be the "best estimate" of the long-run variance if that location were where the change point occured) or a function taking two parameters x and k that can be used to generate this vector, with x representing the data vector and k the position of a potential change point; if NULL, this argument is ignored

  • use_kernel_var: Set to TRUE to use kernel methods for long-run variance estimation (typically used when the data is believed to be correlated); if FALSE, then the long-run variance is estimated using c("hatsigmaT,t2=T1left(\n\\hat{\\sigma}^2_{T,t} = T^{-1}\\left(\n", "sums=1tleft(XsbarXtright)2+\n\\sum_{s = 1}^t \\left(X_s - \\bar{X}_t\\right)^2 +\n", "sums=t+1Tleft(Xs\n\\sum_{s = t + 1}^{T}\\left(X_s -\n", "tildeXTtright)2right)\\tilde{X}_{T - t}\\right)^2\\right)"), where Xˉt=t1s=1tXs\bar{X}_t = t^{-1}\sum_{s = 1}^t X_s and c("tildeXTt=(Tt)1\n\\tilde{X}_{T - t} = (T - t)^{-1}\n", "sums=t+1TXs\\sum_{s = t + 1}^{T} X_s"); if custom_var is not NULL, this argument is ignored

  • kernel: If character, the identifier of the kernel function as used in cointReg (see getLongRunVar); if function, the kernel function to be used for long-run variance estimation (default is the Bartlett kernel in cointReg)

  • bandwidth: If character, the identifier for how to compute the bandwidth as defined in cointReg (see getBandwidth); if function, a function to use for computing the bandwidth; if numeric, the bandwidth value to use (the default is to use Andrews' method, as used in cointReg)

Returns

If both estimate and get_all_vals are FALSE, the value of the test statistic; otherwise, a list that contains the test statistic and the other values requested (if both are TRUE, the test statistic is in the first position and the estimated change point in the second)

Details

For a data set xtx_t with nn observations, the test statistic is

max1sn1(LM(s)Bn)/An \max_{1 \leq s \leq n - 1} (\mathcal{LM}(s) - B_n)/A_n

where u^t=xtxˉ\hat{u}_t = x_t - \bar{x} (xˉ\bar{x} is the sample mean), an=(2loglogn)1/2a_n = (2 \log \log n)^{1/2}, c("bn=an2frac12loglog\nb_n = a_n^2 - \\frac{1}{2} \\log \\log\n", "lognlogGamma(1/2)\\log n - \\log \\Gamma (1/2)"), An=bn/an2A_n = b_n / a_n^2, c("Bn=\nB_n =\n", "bn2/an2b_n^2/a_n^2"), c("hatDelta=hatsigma2=n1sumt=1n\n\\hat{\\Delta} = \\hat{\\sigma}^2 = n^{-1} \\sum_{t = 1}^{n}\n", "hatut2\\hat{u}_t^2"), and c("mathcalLM(s)=n(ns)1s1\n\\mathcal{LM}(s) = n (n - s)^{-1} s^{-1}\n", "hatDelta1left(sumt=1shatutright)2\\hat{\\Delta}^{-1} \\left( \\sum_{t = 1}^{s} \\hat{u}_t\\right)^2").

If corr is FALSE, then the residuals are assumed to be uncorrelated. Otherwise, the residuals are assumed to be correlated and c("\\hat{\\Delta} = \\hat{\\gamma}(0) + 2 \\sum_{j = 1}^{\\lfloor \\sqrt{n}\n", "\\rfloor} (1 - \\frac{j}{\\sqrt{n}}) \\hat{\\gamma}(j)") with c("hatgamma(j)\n\\hat{\\gamma}(j)\n", "=frac1nsumt=1njhatuthatut+j= \\frac{1}{n}\\sum_{t = 1}^{n - j} \\hat{u}_t \\hat{u}_{t + j}").

This statistic was presented in if(!exists(".Rdpack.currefs")) .Rdpack.currefs <-new.env();Rdpack::insert_citeOnly(keys="hidalgoseo13",package="CPAT",cached_env=.Rdpack.currefs) .

Examples

CPAT:::stat_hs(rnorm(1000)) CPAT:::stat_hs(rnorm(1000), corr = FALSE)

References

if(!exists(".Rdpack.currefs")) .Rdpack.currefs <-new.env();Rdpack::insert_all_ref(.Rdpack.currefs)

  • Maintainer: Curtis Miller
  • License: MIT + file LICENSE
  • Last published: 2018-12-25

Useful links