# Change point detection test using Pettitt-Mann-Whitney test?

I am getting two change point with same p-value (or 90.27% probability) in an interval of two years i.e., 1955 and 1958. Here the trend is increasing from 1901-1955 and 1958-2015.

How it could be possible? and what does it mean?

Should I take the first value as change point i.e, 1955 or second year as change point i.e, 1958 in such cases?

I have checked my code and it works fine. Below is my data

Year    Data    Ut  Prob
1   191.89  108 4.45940303
2   57.184  16  0.100073744
3   112.02  68  1.792232071
4   96.05   98  3.686538374
5   191.39  204 15.02081446
6   78.151  172 10.92626049
7   117.13  234 19.27771729
8   178.03  332 35.02033144
9   101.6   372 41.79692472
10  68.958  316 32.33124248
11  48.074  208 15.56678409
12  66.232  136 6.978494947
13  86.971  134 6.781827085
14  100.47  170 10.68765281
15  58.407  80  2.472028581
16  91.912  94  3.396805213
17  54.382  0   0
18  72.667  -44 0.754327188
19  95.452  -16 0.100073744
20  114.08  42  0.687541456
21  69.88   -12 0.05630381
22  138.62  68  1.792232071
23  88.103  72  2.007092252
24  42.95   -42 0.687541456
25  65.864  -118    5.300170706
26  109.94  -68 1.792232071
27  53.79   -166    10.21694621
28  84.944  -180    11.90190259
29  74.81   -222    17.5315226
30  87.395  -220    17.24590247
31  54.302  -316    32.33124248
32  141.98  -234    19.27771729
33  154.83  -146    7.998817007
34  45.744  -258    22.92087214
35  47.541  -368    41.11920281
36  49.924  -472    58.16043715
37  89.169  -462    56.60379769
38  87.078  -462    56.60379769
39  93.684  -442    53.42404584
40  66.248  -512    64.12997636
41  99.016  -478    59.08285492
42  86.027  -490    60.90017572
43  78.354  -520    65.26971723
44  134.93  -444    53.74572209
45  80.344  -470    57.85100413
46  77.389  -506    63.2627629
47  115.51  -446    54.06661391
48  65.553  -528    66.39007375
49  179.1   -428    51.15160834
50  94.205  -404    47.18379494
51  70.522  -454    55.34204811
52  60.766  -542    68.30264148
53  68.548  -602    75.76552335
54  68.189  -666    82.35621377
55  49.296  -772    90.27962348
56  175.48  -676    83.25839621
57  82.691  -694    84.79765887
58  65.647  -772    90.27962348
59  160.99  -678    83.43477464
60  86.379  -688    84.296554
61  89.544  -676    83.25839621
62  117.75  -612    76.88930109
63  83.574  -628    78.61478742
64  70.179  -680    83.6098077
65  113.89  -624    78.19179205
66  70.674  -672    82.90159042
67  102.04  -630    78.82419228
68  130.7   -556    70.15217102
69  86.536  -562    70.92506309
70  129.87  -492    61.19936563
71  93.761  -470    57.85100413
72  86.867  -474    58.46889796
73  76.619  -512    64.12997636
74  86.506  -520    65.26971723
75  68.147  -586    73.89522537
76  100.61  -548    69.10313152
77  130.01  -476    58.77637451
78  326.19  -362    40.10185246
79  88.228  -356    39.08408044
80  94.356  -330    34.68297579
81  125.51  -262    23.54537208
82  51.851  -362    40.10185246
83  78.824  -390    44.83692981
84  267.2   -278    26.08574789
85  76.587  -318    32.66599865
86  242.27  -208    15.56678409
87  138.58  -130    6.396029739
88  179.94  -28 0.306159667
89  68.853  -86 2.851204283
90  82.235  -108    4.45940303
91  98.755  -76 2.233719045
92  159.6   16  0.100073744
93  92.636  34  0.451101233
94  50.22   -68 1.792232071
95  104.4   -22 0.189117603
96  112.12  32  0.399694491
97  66.022  -42 0.687541456
98  82.528  -62 1.492177234
99  151.59  24  0.225025103
100 61.641  -62 1.492177234
101 65.632  -142    7.583363709
102 142.87  -58 1.307072614
103 158.58  32  0.399694491
104 118.78  98  3.686538374
105 81.074  74  2.118939965
106 77.881  40  0.623820181
107 103 84  2.721932807
108 71.574  38  0.56316932
109 88.899  46  0.82417114
110 67.359  -22 0.189117603
111 65.015  -106    4.299339333
112 68.332  -168    10.45120788
113 91.957  -152    8.639939296
114 106.04  -104    4.142006793
115 186.11  0   0


and the line graph

However, the slope is less negative post-1955 than pre-1955. What does this indicate, if I am doing it correctly.

• If I understand your first sentence correctly, you appear to misinterpret what a p-value is. – Glen_b -Reinstate Monica Apr 11 '16 at 7:59
• For same p-value there should be same probability. If p-value is 0.0973 then there is 90.27% probability that the results are true. That is what wrote in in my first sentence. – Mario Apr 11 '16 at 8:19
• Thanks for clarifying. I interpreted your meaning correctly then -- that interpretation ("there is 90.27% probability that the results are true") is incorrect. (It's a common error.) – Glen_b -Reinstate Monica Apr 11 '16 at 8:24
• Okay, it means that there are 9.73% probability of type-1 error. Is that correct? – Mario Apr 11 '16 at 8:37
• No, sorry, that's only correct if the null hypothesis is true. But the null hypothesis is unlikely to actually be true. If the null is not true, then the probability of a type I error is zero. – Glen_b -Reinstate Monica Apr 11 '16 at 9:22

The $U_t$ values are based on (centered) sums of ranks. They're integers, so they can be the same -- and indeed you do have two $U_t$ values the same.

However, it is not clear how you're assigning p-values to those $U_t$ values.

Pettitt's 1979 paper [1] does not assign p-values to every point; it effectively assigns a p-value to the largest $\mid U_t\mid$, because for continuous data it uses an asymptotic approximation - a scaled* version of $U_t$ is asymptotically a Brownian bridge - and so approximate p-values can be obtained from the Kolmogorov distribution (the limiting distribution of $K_n=\sqrt{n}D_n$ in a Kolmogorov-Smirnov test).

* the scale factor is a simple function of the number of observations.

It seems that you're calculating a p-value for every point by using Pettitt's calculation at equation 2.12 in the paper (a further approximation to the asymptotic approximation) for each time point as if each $\mid U_t\mid$ were the maximum -- but then only the p-value that goes with the largest $\mid U_t\mid$ value carries any meaning as a p-value. Which is to say, the only p-value there that you can interpret is the smallest one.

I'm not at all sure why a computer program would use equation 2.12 rather than actually just compute the Kolmogorov distribution to high accuracy (and so only have one level of approximation); 2.12 is designed for ease of hand calculation.

In addition, you describe the data as having a trend (from just the raw appearance of the plot of the data, I don't think there's clear evidence that it really does, outside the possible location-shift you're testing for, but sometimes trend can be hard to spot, so perhaps you have some other reason to think there is additional trend there); if there were such a trend the Pettitt test would not be valid.

[1] Pettitt, A.N. (1979),
"A nonparametric approach to the change-point problem."
Applied Statistics, 28, p126-135.

• Yeah, exactly, I am calculating the Ut value for each point and following the same paper. There are same Ut values for two different years for this time series. Hence, I need to choose one year from these two. Now Pettittt test is carried out for change point detection i.e., to find out when the trend is changing it's direction, then why did you wrote that Pettitt test would not be valid for such trend in data. I can see that at 0.1 significance level change point is not causing the trend direction to reverse, I need to increase significance level from 0.1 to 0.05. – Mario Apr 11 '16 at 11:40
• 1. Your desire to choose one of the two points with the largest $|U_t|$ value is understood; but the test doesn't distinguish them. $\quad$ 2. Tony Pettitt explicitly assumed no trend before the change point and no trend after it. See the opening sentence of his paper: > "Consider a sequence of random variables $X_1, X_2, ...,X_T$ then the sequence is said to have a change-point at $\tau$ if $X_t$ for $t=1,...,\tau$ have a common distribution function $F_1(x)$ and $X_t$ for $t=\tau+1,...,T$ have a common distribution function $F_2(x)$, and $F_1(x)\neq F_2(x)$." – Glen_b -Reinstate Monica Apr 11 '16 at 17:15
• Then what does change point mean? If there is no trend at all (there may be significant trend sometimes) pre and post the change point, why one would do the change point detection. This test is extensively used in climatic studies to find the change point in rainfall time series. And it has been found many times that after change point trend got increased or decreased, sometime significantly. – Mario Apr 11 '16 at 17:57
• The distribution after is different from before (in a way that Mann-Whitney is able to detect -- so it will pick up changes that lead to being stochastically larger). For example, it will pick up a level-shift (suddenly typical temperatures jump by 0.5 degrees) or a scale-shift (suddenly typical rainfall drops by 10%). But either side of that single jump-point, everything is flat (not constant, but drawn from a distribution that doesn't change from period to period except for that one time; after is different from before). The paper is not ambiguous on this point. – Glen_b -Reinstate Monica Apr 11 '16 at 18:21