Skip to contents

Formula: with \(r_i\) the midranks of x, \(U_k = 2\sum_{i\le k} r_i - k(n+1)\), statistic \(U^* = \max_k |U_k|\), change point at the maximising \(k\), and \(p = \min(1, 2 e^{-6 U^{*2} / (n^3 + n^2)})\). The rank form is algebraically the Mann-Whitney form but O(n) per split. The approximation is only trustworthy for \(p \le 0.5\), hence the clamp.

Usage

Pettitt(x)

Arguments

x

Series in time order.

Value

List with statistic, p_value, changepoint (1-based), U, n, method.

References

Pettitt (1979), JRSS C 28:126-135. Paywalled; the coded form was read from Pohlert's CRAN package trend (R/pettitt.test.R), which follows Verstraeten et al. (2006).

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Pettitt(V)
#> $statistic
#> [1] 16
#> 
#> $p_value
#> [1] 0.1389669
#> 
#> $changepoint
#> [1] 4
#> 
#> $U
#> [1]  -7 -12 -15 -16 -15 -12  -7   0
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Pettitt single change-point test"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"