testBreakpoint: Test a time series for a breakpoint in the mean with...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/testBreakpoint.R

Description

Following the test of Pettitt (1979), a time series is tested for a single, abrupt breakpoint concerning a shift in the mean.

Usage

1
testBreakpoint(x, alpha = 0.05)

Arguments

x

numeric vector. Missing values are not allowed and it is assumed that the frequency, at which the observation took place, is constant.

alpha

real number. Defines the significance level.

Details

The test by Pettitt (1979) relies on the non-parametric Mann-Whitney U-test for assessing whether two samples are drawn from the same distribution. The null hypothesis H0 is stated as 'no change in level' and the alternative hypothesis HA as 'change in level'; only the two-sided test is implemented here.

Value

List with entries

i

integer. The index of the most probable breakpoint in x, i.e. i=argmax(t)|U(t)|.

p.value

real number. The p-value, i.e. the probability of not observing a breakpoint at i.

k

real number. k=|U(i)|.

critical.value

real number. The value of x for which P(K<x)=1-alpha.

reject.HO

logical. Reject the null hypothesis, i.e. k ≥ critical.value?

u

numeric vector. U(t) corresponding to the values in x.

Author(s)

Original code provided by Pascal H.

References

Pettitt, A. N. (1979). "A non-parametric approach to the change-point problem". Applied Statistics.

Examples

1
2
3
4
5
6
7
8
9
x <- c(rnorm(20,2,0.15),rnorm(20,3,0.15))
p <- testBreakpoint(x,alpha=0.05)
par(mfrow = c(2,1))

plot(x,type='l',xlab='time',ylab='observation')
abline(v=p$index,col='red')
plot(abs(p$u),type='l',xlab='time',ylab='abs(u)')
abline(h=p$critical.value,lty=2)
abline(v=p$index,col='red')

hydro-giub/hydroBE documentation built on Sept. 20, 2019, 9:27 a.m.