Learn R Programming

trend (version 0.0.1)

pettitt.test: Pettitt's test for change-point-detection

Description

Performes a nonparametric U-test after Pettitt in order to test for a shift in the central tendcency of a time series. The H0-hypothesis is: no change is tested against the HA-Hypothesis: change.

Usage

pettitt.test(x)

Arguments

x
a vector or a time series object of class "ts"

Value

  • An object of class "htest"
  • methoda character string indicating the chosen test
  • data.namea character string giving the name(s) of the data
  • statisticthe maximum K of the absolute values of the U-statistics
  • estimateprobable change point at time step tau
  • nobsnumber of total observations
  • alternativea character string describing the alternative hypothesis
  • p.valuethe p-value for the test

Warning

The current function is for complete observations only. The approximate probability is good for $p \le 0.5$.

Details

The test is conducted in accordance to Pettitt's proposed method. First a vector that comprises the U-Statistics is calculated: $$U_{i} = \sum_{k=1}^i{~\sum_{j=i+1}^n{ \textnormal{sgn}(x_k - x_j)}}$$ for $(1 \le i \le n )$. For a two-sided test, the maximum of the absolute obtained U-statistics is taken as the test statistic K: $$K = \max \left| U_i \right|$$ Finally, the approximate probability for a two-sided test is calculated according to $$2 \exp^{-6K^2 / (T^3 + T^2)}$$

References

CHR (ed., 2010): Das Abflussregime des Rheins und seiner Nebenfluesse im 20. Jahrhundert, Report no I-22 of the CHR, p. 172. Pettitt, A. N., (1979). A non-parametric approach to the change point problem. Journal of the Royal Statistical Society Series C, Applied Statistics 28, 126-135.

See Also

efp sctest.efp

Examples

Run this code
data(maxau) ; plot(maxau[,"s"])
s.res <- pettitt.test(maxau[,"s"])
n <- s.res$nobs
i <- s.res$estimate
s.1 <- mean(maxau[1:i,"s"])
s.2 <- mean(maxau[(i+1):n,"s"])
s <- ts(c(rep(s.1,i), rep(s.2,(n-i))))
tsp(s) <- tsp(maxau[,"s"])
lines(s, lty=2)
print(s.res)


data(PagesData) ; pettitt.test(PagesData)

Run the code above in your browser using DataLab