stat_de function

Compute the Darling-Erdös Statistic

Compute the Darling-Erdös Statistic

This function computes the Darling-Erdös statistic.

stat_de(dat, a = log, b = log, estimate = FALSE, use_kernel_var = FALSE, custom_var = NULL, kernel = "ba", bandwidth = "and", get_all_vals = FALSE)

Arguments

  • dat: The data vector
  • a: The function that will be composed with l(x)=(2logx)1/2l(x) = (2 \log x)^{1/2}
  • b: The function that will be composed with c("u(x)=2logx+frac12loglogxfrac12log\nu(x) = 2 \\log x + \\frac{1}{2} \\log \\log x - \\frac{1}{2} \\log\n", "pi\\pi")
  • estimate: Set to TRUE to return the estimated location of the change point
  • 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")
  • 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
  • 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)
  • get_all_vals: If TRUE, return all values for the statistic at every tested point in the data set

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 changg point in the second)

Details

If AˉT(τ,tT)\bar{A}_T(\tau, t_T) is the weighted and trimmed CUSUM statistic with weighting parameter τ\tau and trimming parameter tTt_T (see stat_Vn), then the Darling-Erdös statistic is

l(aT)AˉT(1/2,1)u(bT) l(a_T) \bar{A}_T(1/2, 1) - u(b_T)

with l(x)=2logxl(x) = \sqrt{2 \log x} and c("u(x)=2logx+frac12log\nu(x) = 2 \\log x + \\frac{1}{2} \\log\n", "logxfrac12logpi\\log x - \\frac{1}{2} \\log \\pi") (logx\log x is the natural logarithm of xx). The parameter a corresponds to aTa_T and b to bTb_T; these are both log by default.

See if(!exists(".Rdpack.currefs")) .Rdpack.currefs <-new.env();Rdpack::insert_citeOnly(keys="horvathricemiller19",package="CPAT",cached_env=.Rdpack.currefs) to learn more.

Examples

CPAT:::stat_de(rnorm(1000)) CPAT:::stat_de(rnorm(1000), use_kernel_var = TRUE, bandwidth = "nw", kernel = "bo")

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