{"id":10240,"date":"2010-03-30T10:55:44","date_gmt":"2010-03-30T16:55:44","guid":{"rendered":"http:\/\/rankexploits.com\/musings\/?p=10240"},"modified":"2010-03-30T10:55:44","modified_gmt":"2010-03-30T16:55:44","slug":"how-do-we-know-that-temperature-is-i1-and-not-i2","status":"publish","type":"post","link":"https:\/\/rankexploits.com\/musings\/2010\/how-do-we-know-that-temperature-is-i1-and-not-i2\/","title":{"rendered":"How Do We Know That Temperature is I(1) and not I(2)?"},"content":{"rendered":"<p>I\u00e2\u20ac\u2122m not going to go through all the math that has been posted elsewhere on unit roots.  This will be much more practical.\u00c2\u00a0 I\u00e2\u20ac\u2122ll treat the climate system as a black box that just adds noise to  the input signal.\u00c2\u00a0  I can add more complexity like time constants for a two box model later.\u00c2\u00a0 As a first pass, I\u00e2\u20ac\u2122ll use white noise and see what  happens.  First I\u00e2\u20ac\u2122ll create the synthetic time series A,A1 and A2 with  0, 1 and 2 unit roots respectively.  I\u00e2\u20ac\u2122m also going to use just the  Phillips-Perron test for unit roots.\u00c2\u00a0 I&#8217;m using R for Windows version 2.10.1 and the PP test is from the tseries package.\u00c2\u00a0 The PP test has a null hypothesis that the series has a unit root.\u00c2\u00a0 A p value of less than 0.05 means the null hypothesis is rejected (no unit root) with a confidence of greater than 95%.<\/p>\n<p>One can easily create a time series with one unit root by integrating, or cumulatively summing, a white noise series.  The code in R for this is:<\/p>\n<blockquote>\n<p style=\"text-align: left\">A&lt;-rnorm (n)<\/p>\n<p style=\"text-align: left\">A1&lt;-cumsum (A)<\/p>\n<\/blockquote>\n<p>Where n is an integer defining the length of the time series, rnorm is Gaussian noise with mean zero and standard deviation one and cumsum is A1(n) = A(n) + A1(n-1).   Similarly, an I(2) time series can be created by cumulatively summing an I(1) series.  Differences are created using diff(X).\u00c2\u00a0 The series are centered to as  close to a mean of zero as I can  get before summing to minimize trends in the summed series  and scaled to similar ranges.\u00c2\u00a0 The length of each series is 1000 points.<\/p>\n<p><a href=\"http:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Synthetic-Time-Series.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-10237\" src=\"http:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Synthetic-Time-Series-500x478.png\" alt=\"\" width=\"500\" height=\"478\" srcset=\"https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Synthetic-Time-Series-500x478.png 500w, https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Synthetic-Time-Series-300x287.png 300w, https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Synthetic-Time-Series.png 700w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>A2 is black, A1 is blue and A is red.<\/p>\n<p>Testing A2, A and A1 for unit roots:<\/p>\n<blockquote><p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2<br \/>\nDickey-Fuller Z(alpha) = 0.0049, Truncation lag parameter = 7, p-value<br \/>\n= 0.99<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A2) : p-value greater than printed p-value<\/p>\n<p>&gt; A2d1&lt;-diff(A2)<\/p>\n<p>&gt;pp.test(A2d1)<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2d1<br \/>\nDickey-Fuller Z(alpha) = -13.204, Truncation lag parameter = 7, p-value<br \/>\n= 0.3732<br \/>\nalternative hypothesis: stationary<\/p>\n<p>&gt; A2d2&lt;-diff(A2d1)<\/p>\n<p>&gt;pp.test(A2d2)<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2d2<br \/>\nDickey-Fuller Z(alpha) = -921.257, Truncation lag parameter = 7,<br \/>\np-value = 0.01<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A2d2) : p-value smaller than printed p-value<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A<br \/>\nDickey-Fuller Z(alpha) = -923.5331, Truncation lag parameter = 7,<br \/>\np-value = 0.01<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A) : p-value smaller than printed p-value<\/p>\n<p>&gt; pp.test(A1)<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A1<br \/>\nDickey-Fuller Z(alpha) = -13.4424, Truncation lag parameter = 7,<br \/>\np-value = 0.3599<br \/>\nalternative hypothesis: stationary<\/p>\n<p>&gt; A1d1&lt;-diff(A1)<\/p>\n<p>&gt;pp.test(A1d1)<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A1d1<br \/>\nDickey-Fuller Z(alpha) = -922.0155, Truncation lag parameter = 7,<br \/>\np-value = 0.01<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A1d1) : p-value smaller than printed p-value<\/p><\/blockquote>\n<p>The PP test results are as expected.\u00c2\u00a0 A2 has to be differenced twice and A1 once before the PP test rejects the unit root hypothesis.\u00c2\u00a0 But a  cumulative sum is a low pass filter.  Does the temperature series look  like data from a low pass filter?  Not really.  If the climate is  chaotic, then one expects to see variation at all time scales even when  the input isn\u00e2\u20ac\u2122t changing.\u00c2\u00a0 I&#8217;ll add some noise, a fraction of series A, to A2 and see the effect of the noise and the series length on the test results.<\/p>\n<blockquote><p>&gt;A2n&lt;-A2+0.1*A<\/p><\/blockquote>\n<p><a href=\"http:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/noisy-series.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-10239\" src=\"http:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/noisy-series-500x479.png\" alt=\"\" width=\"500\" height=\"479\" srcset=\"https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/noisy-series-500x479.png 500w, https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/noisy-series-300x287.png 300w, https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/noisy-series.png 700w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<blockquote><p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2n<br \/>\nDickey-Fuller Z(alpha) = -0.0466, Truncation lag parameter = 7, p-value<br \/>\n= 0.99<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A2n) : p-value greater than printed p-value<\/p><\/blockquote>\n<p>The full series with noise still has at least one unit root.  But what are the results for a shorter segment?<\/p>\n<blockquote><p>&gt;pp.test(A2n[1:100])<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2n[1:100]<br \/>\nDickey-Fuller Z(alpha) = -9.8403, Truncation lag parameter = 3, p-value<br \/>\n= 0.545<br \/>\nalternative hypothesis: stationary<\/p>\n<p>&gt; pp.test(A2[1:100])<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2[1:100]<br \/>\nDickey-Fuller Z(alpha) = -2.2552, Truncation lag parameter = 3, p-value<br \/>\n= 0.9602<br \/>\nalternative hypothesis: stationary<\/p><\/blockquote>\n<p>The first 100 points still fails to reject the presence of a unit root for both the original and the noisy series, but the p-value for the noisy series is less than that for the noise free series.\u00c2\u00a0 Now I\u00e2\u20ac\u2122ll test the first difference.<\/p>\n<blockquote><p>&gt; A2nd1&lt;-diff(A2n)<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2nd1[1:100]<br \/>\nDickey-Fuller Z(alpha) = -119.0049, Truncation lag parameter = 3,<br \/>\np-value = 0.01<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A2nd1[1:100]) : p-value smaller than printed p-value<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2nd1[1:200]<br \/>\nDickey-Fuller Z(alpha) = -252.2832, Truncation lag parameter = 4,<br \/>\np-value = 0.01<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A2nd1[1:200]) : p-value smaller than printed p-value<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2nd1[1:500]<br \/>\nDickey-Fuller Z(alpha) = -722.274, Truncation lag parameter = 5,<br \/>\np-value = 0.01<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A2nd1[1:500]) : p-value smaller than printed p-value<\/p>\n<p>Phillips-Perron Unit Root Test<\/p>\n<p>data:  A2nd1[1:1000]<br \/>\nDickey-Fuller Z(alpha) = 4430.345, Truncation lag parameter = 7,<br \/>\np-value = 0.99<br \/>\nalternative hypothesis: stationary<\/p>\n<p>Warning message:<br \/>\nIn pp.test(A2nd1[1:1000]) : p-value greater than printed p-value<\/p><\/blockquote>\n<p>I need nearly the full series to fail to reject the presence of a second unit root.<\/p>\n<p>To see how things compare, here\u00e2\u20ac\u2122s a plot of the first 124 points of the synthetic noisy series in black and the GISS anomaly from 1880-2003, scaled to the same range, in red:<\/p>\n<p><a href=\"http:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Noisy-series-plus-GISStemp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-10238\" src=\"http:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Noisy-series-plus-GISStemp-500x479.png\" alt=\"\" width=\"500\" height=\"479\" srcset=\"https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Noisy-series-plus-GISStemp-500x479.png 500w, https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Noisy-series-plus-GISStemp-300x287.png 300w, https:\/\/rankexploits.com\/musings\/wp-content\/uploads\/2010\/03\/Noisy-series-plus-GISStemp.png 700w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>In answer to the title question, we don\u00e2\u20ac\u2122t know that the temperature series is I(1) and not I(2) because it\u00e2\u20ac\u2122s too short and too noisy.  In terms of whether there\u00e2\u20ac\u2122s a trend or not, I think there are more suitable tools available based on control chart theory like CUSUM or EWMA charts that are designed to test for the presence of small trends or variations from the mean in short series.  That\u00e2\u20ac\u2122s another subject, though and besides I don\u00e2\u20ac\u2122t have a package to do EWMA control charts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u00e2\u20ac\u2122m not going to go through all the math that has been posted elsewhere on unit roots. This will be much more practical.\u00c2\u00a0 I\u00e2\u20ac\u2122ll treat the climate system as a black box that just adds noise to the input signal.\u00c2\u00a0 I can add more complexity like time constants for a two box model later.\u00c2\u00a0 As &hellip; <a href=\"https:\/\/rankexploits.com\/musings\/2010\/how-do-we-know-that-temperature-is-i1-and-not-i2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How Do We Know That Temperature is I(1) and not I(2)?<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[451,272],"class_list":["post-10240","post","type-post","status-publish","format-standard","hentry","category-data-comparisons","tag-statistics","tag-unit-root"],"_links":{"self":[{"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/posts\/10240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/comments?post=10240"}],"version-history":[{"count":0,"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/posts\/10240\/revisions"}],"wp:attachment":[{"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/media?parent=10240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/categories?post=10240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rankexploits.com\/musings\/wp-json\/wp\/v2\/tags?post=10240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}