2
$\begingroup$

I am studying how to use the pettitt.test function from the trend package in R to detect change-point in a time-series. However, after testing this function on some example datasets, I noticed that sometimes the p-value is larger than one. Below is an example.

library(trend)

# Example vector
vec <- c(-0.2, -0.2, -1.8, -0.3, 1.5, -0.2, -0.2, 1.2, -1, 1.2, -1, -0.5, 1.1, -1.2)

pettitt.test(vec)
        Pettitt's test for single change-point detection

data:  vec
U* = 17, p-value = 1.109
alternative hypothesis: two.sided
sample estimates:
probable change point at time K 
                             10 

I thought the p-value should be a number from 0 to 1. Are there any reasons why this function generates a p-value larger than 1?

$\endgroup$
2
+50
$\begingroup$

The true p-value is a probability, so you are correct that it must be between zero and one. However, according to the documentation for the trend package, this test uses an approximate p-value$^\dagger$:

$$\hat{p} = 2 \cdot \exp \Bigg( -\frac{6 K^2}{T^3+T^2} \Bigg).$$

The documentation notes that this approximation is only good for $\hat{p} \leqslant \tfrac{1}{2}$. In this case the value is not even within the allowable bounds, so it is clear that the approximation is not good!


$^\dagger$ Another problem is that the reported p-value in the output does not match the formula reported in the documentation. In your output you have U* = 17, K = 10 and T = 17, which should give the approximate p-value p-value = 1.631. However, the reported p-value = 1.109 matches a value of K = 17, not K = 10. This suggests that there may be a problem either with the documentation or the function itself.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.