stat_hs {CPAT}R Documentation

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")



The data vector


Set to TRUE to return the estimated location of the change point


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


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


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


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 \hat{\sigma}^2_{T,t} = T^{-1}\left( \sum_{s = 1}^t \left(X_s - \bar{X}_t\right)^2 + \sum_{s = t + 1}^{T}\left(X_s - \tilde{X}_{T - t}\right)^2\right), where \bar{X}_t = t^{-1}\sum_{s = 1}^t X_s and \tilde{X}_{T - t} = (T - t)^{-1} \sum_{s = t + 1}^{T} X_s; if custom_var is not NULL, this argument is ignored


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)


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)


For a data set x_t with n observations, the test statistic is

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

where \hat{u}_t = x_t - \bar{x} (\bar{x} is the sample mean), a_n = (2 \log \log n)^{1/2}, b_n = a_n^2 - \frac{1}{2} \log \log \log n - \log \Gamma (1/2), A_n = b_n / a_n^2, B_n = b_n^2/a_n^2, \hat{\Delta} = \hat{\sigma}^2 = n^{-1} \sum_{t = 1}^{n} \hat{u}_t^2, and \mathcal{LM}(s) = n (n - s)^{-1} s^{-1} \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 \hat{\Delta} = \hat{\gamma}(0) + 2 \sum_{j = 1}^{\lfloor \sqrt{n} \rfloor} (1 - \frac{j}{\sqrt{n}}) \hat{\gamma}(j) with \hat{\gamma}(j) = \frac{1}{n}\sum_{t = 1}^{n - j} \hat{u}_t \hat{u}_{t + j}.

This statistic was presented in (Hidalgo and Seo 2013).


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)


Hidalgo J, Seo MH (2013). “Testing for structural stability in the whole sample.” Journal of Econometrics, 175(2), 84 - 93. ISSN 0304-4076, doi: 10.1016/j.jeconom.2013.02.008,


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

[Package CPAT version 0.1.0 Index]