[R] ADF test
Hi all, Hope you people do not feel irritated for repeatedly sending mail on Time series. Here I got another problem on the same, and hope I would get some answer from you. I have following dataset: data[,1] [1] 4.96 4.95 4.96 4.96 4.97 4.97 4.97 4.97 4.97 4.98 4.98 4.98 4.98 4.98 4.99 4.99 5.00 5.01 [19] 5.01 5.00 5.01 5.01 5.01 5.01 5.02 5.01 5.02 5.02 5.03 5.03 5.03 5.03 5.03 5.04 5.04 5.04 [37] 5.04 5.04 5.04 5.05 5.05 5.06 5.06 5.06 5.07 5.07 5.07 5.07 5.08 5.07 5.08 5.08 5.09 5.10 [55] 5.10 5.09 5.10 5.10 5.10 5.10 5.10 5.10 5.10 5.10 5.11 5.11 5.11 5.11 5.11 5.11 5.11 5.12 [73] 5.12 5.12 5.12 5.13 5.14 5.14 5.14 5.14 5.14 5.15 5.15 5.15 5.15 5.14 5.15 5.15 5.15 5.16 [91] 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.17 5.17 5.17 5.17 5.17 5.18 5.18 5.18 [109] 5.18 5.18 5.19 5.19 5.20 5.20 5.20 5.20 5.20 5.21 5.21 5.21 5.21 5.21 5.21 5.22 5.22 5.23 [127] 5.23 5.23 5.23 5.24 5.24 5.24 5.25 5.24 5.24 5.25 5.26 5.26 5.26 5.26 5.26 5.26 5.26 5.27 [145] 5.27 5.26 5.27 5.27 5.28 5.29 5.29 5.29 5.29 5.30 5.30 5.30 5.31 5.31 5.31 5.32 5.32 5.33 [163] 5.33 Now I want to conduct a test for stationarity using ADF test : adf.test((data[,1]), stationary, 0) Augmented Dickey-Fuller Test data: (data[, 1]) Dickey-Fuller = -3.7351, Lag order = 0, p-value = 0.02394 alternative hypothesis: stationary But surprisingly it leads towards rejestion of NULL [p-value is less than 0.05], i.e. indicates a possible stationary series. However ploting a graph of actual data set it doesn't seem so. Am I making any mistakes ? Can anyone give me any suggestion? Regards, Megh - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ADF test
Hi Megh i hope you have confused with 'what is my NULL hypothesis' ? i suggest you to take any ideal dataset about which you know that whether it is stationary or not ? apply the test to know what is the NULL hypothesis used in any software :) usually in many softwares the NULL hypothesis is in negative sense. Please everybody comment on this :) hoping that you series is return series and not price series :). Thus applying adf test for your series :) my test show that your series is not stationary at all as my correlalogram comes as follows. 1 0.998283718 0.997582959 0.99703921 0.99665648 0.996548006 0.99647617 0.995925698 0.995317271 0.994746317 0.994727781 0.99508777 0.99501576 0.99437404 0.993338292 0.992684933 0.992310313 @@@ m Although if i assume that your series is a price series and defining return = 100*ln(pt/pt-1). Returns become as follows 0 -0.201816416 0.201816416 0 0.201409937 0 0 0 0 0.201005093 0 0 0 0 0.200601873 0 0.200200267 0.199800266 0 -0.199800266 0.199800266 0 0 0 0.199401861 -0.199401861 0.199401861 0 0.199005041 0 0 0 0 0.198609797 0 0 0 0 0 0.19821612 0 0.197824001 0 0 0.19743343 0 0 0 0.197044399 -0.197044399 0.197044399 0 0.196656897 0.196270917 0 -0.196270917 0.196270917 0 0 0 0 0 0 0 0.195886449 0 0 0 0 0 0 0.195503484 0 0 0 0.195122013 0.194742028 0 0 0 0 0.194363521 0 0 0 -0.194363521 0.194363521 0 0 0.193986482 0 0 0 0 0 0 0 0 0 0 0.193610903 0 0 0 0 0.193236775 0 0 0 0 0.192864091 0 0.192492841 0 0 0 0 0.192123018 0 0 0 0 0 0.191754613 0 0.191387618 0 0 0 0.191022026 0 0 0.190657827 -0.190657827 0 0.190657827 0.190295015 0 0 0 0 0 0 0.18993358 0 -0.18993358 0.18993358 0 0.189573516 0.189214815 0 0 0 0.188857469 0 0 0.18850147 0 0 0.18814681 0 0.187793482 0 then the value of autocorrelations i.e. correlalogram comes as approx 1 0.089252308 0.058227292 0.017934984 0.025264591 -0.014925678 -0.004668544 0.014890995 0.001625333 0.010669589 -0.010587179 -0.03000206 -0.011863654 0.00772247 0.024272208 -0.019521244 -0.035998575 -0.061608877 -0.048401231 -0.008594859 which show that the values are quite likely to make series stationary :) data[1:10,] V1 V2 1 4.96 0.000 2 4.95 -0.2018164 3 4.96 0.2018164 4 4.96 0.000 5 4.97 0.2014099 6 4.97 0.000 7 4.97 0.000 8 4.97 0.000 9 4.97 0.000 10 4.98 0.2010051 adf.test(data[,1]) Augmented Dickey-Fuller Test data: data[, 1] Dickey-Fuller = -1.1052, Lag order = 5, p-value = 0.9188 alternative hypothesis: stationary adf.test(data[,2]) Augmented Dickey-Fuller Test data: data[, 2] Dickey-Fuller = -6.2265, Lag order = 5, p-value = 0.01 alternative hypothesis: stationary Warning message: p-value smaller than printed p-value in: adf.test(data[, 2]) this explains everything clearly :) your NULL hypothesis is Series is not stationary - hence hypothesis in negative sense prooved by taking ideal data data1-rnorm(1) #normal data adf.test(data1) Augmented Dickey-Fuller Test data: data1 Dickey-Fuller = -21.2118, Lag order = 21, p-value = 0.01 alternative hypothesis: stationary Warning message: p-value smaller than printed p-value in: adf.test(data1) HTH Megh Dal [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 08/16/2007 04:27 PM To r-help@stat.math.ethz.ch cc Subject [R] ADF test Hi all, Hope you people do not feel irritated for repeatedly sending mail on Time series. Here I got another problem on the same, and hope I would get some answer from you. I have following dataset: data[,1] [1] 4.96 4.95 4.96 4.96 4.97 4.97 4.97 4.97 4.97 4.98 4.98 4.98 4.98 4.98 4.99 4.99 5.00 5.01 [19] 5.01 5.00 5.01 5.01 5.01 5.01 5.02 5.01 5.02 5.02 5.03 5.03 5.03 5.03 5.03 5.04 5.04 5.04 [37] 5.04 5.04 5.04 5.05 5.05 5.06 5.06 5.06 5.07 5.07 5.07 5.07 5.08 5.07 5.08 5.08 5.09 5.10 [55] 5.10 5.09 5.10 5.10 5.10 5.10 5.10 5.10 5.10 5.10 5.11 5.11 5.11 5.11 5.11 5.11 5.11 5.12 [73] 5.12 5.12 5.12 5.13 5.14 5.14 5.14 5.14 5.14 5.15 5.15 5.15 5.15 5.14 5.15 5.15 5.15 5.16 [91] 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.17 5.17 5.17 5.17 5.17 5.18 5.18 5.18 [109] 5.18 5.18 5.19 5.19 5.20 5.20 5.20 5.20 5.20 5.21 5.21 5.21 5.21 5.21 5.21 5.22 5.22 5.23 [127] 5.23 5.23 5.23 5.24 5.24 5.24 5.25 5.24 5.24 5.25 5.26 5.26 5.26 5.26 5.26 5.26 5.26 5.27 [145] 5.27 5.26 5.27 5.27 5.28 5.29 5.29 5.29 5.29 5.30 5.30 5.30 5.31 5.31 5.31 5.32 5.32 5.33 [163] 5.33 Now I want to conduct a test for stationarity using ADF test : adf.test((data[,1]), stationary, 0) Augmented Dickey-Fuller Test data: (data[, 1]) Dickey-Fuller = -3.7351, Lag order = 0, p-value = 0.02394 alternative hypothesis: stationary But surprisingly it leads towards rejestion of NULL [p-value is less than 0.05], i.e. indicates a possible stationary series. However ploting a graph of actual data set it doesn't seem so. Am I making any mistakes ? Can anyone give me any suggestion? Regards, Megh
Re: [R] ADF test
The option alternative in adf.test() takes the value 'stationary' or 'explosive'. The value 'explosive' is used to test if the series is stationary about a linear time trend. This means that a constant and trend are to be included in the DF or ADF test regression. In the case here the series is trended. The question is if the trend is stochastic or deterministic. Have a look at the following analysis t=1:length(x) plot(t,x) trend = lm(x~t) abline(lm(x~t)) summary(trend) library(urca) x = ts(x, start=1, end = length(x), frequency=1) x.ct = ur.df(x,lags=0,type='trend') plot(x.ct) library(tseries) adf.test(x,alternative = explosive , k=0) summary(ur.df(x,lags=0,type='trend') which analyses your data using two different libraries. (x is your data and both procs. produce the same DF test). I should remark that your data are rounded and this possibly acts against a full analysis. Some knowledge of the data generating process might suggest a more appropriate way of testing for stationarity. On 16/08/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Megh i hope you have confused with 'what is my NULL hypothesis' ? i suggest you to take any ideal dataset about which you know that whether it is stationary or not ? apply the test to know what is the NULL hypothesis used in any software :) usually in many softwares the NULL hypothesis is in negative sense. Please everybody comment on this :) hoping that you series is return series and not price series :). Thus applying adf test for your series :) my test show that your series is not stationary at all as my correlalogram comes as follows. 1 0.998283718 0.997582959 0.99703921 0.99665648 0.996548006 0.99647617 0.995925698 0.995317271 0.994746317 0.994727781 0.99508777 0.99501576 0.99437404 0.993338292 0.992684933 0.992310313 @@@ m Although if i assume that your series is a price series and defining return = 100*ln(pt/pt-1). Returns become as follows 0 -0.201816416 0.201816416 0 0.201409937 0 0 0 0 0.201005093 0 0 0 0 0.200601873 0 0.200200267 0.199800266 0 -0.199800266 0.199800266 0 0 0 0.199401861 -0.199401861 0.199401861 0 0.199005041 0 0 0 0 0.198609797 0 0 0 0 0 0.19821612 0 0.197824001 0 0 0.19743343 0 0 0 0.197044399 -0.197044399 0.197044399 0 0.196656897 0.196270917 0 -0.196270917 0.196270917 0 0 0 0 0 0 0 0.195886449 0 0 0 0 0 0 0.195503484 0 0 0 0.195122013 0.194742028 0 0 0 0 0.194363521 0 0 0 -0.194363521 0.194363521 0 0 0.193986482 0 0 0 0 0 0 0 0 0 0 0.193610903 0 0 0 0 0.193236775 0 0 0 0 0.192864091 0 0.192492841 0 0 0 0 0.192123018 0 0 0 0 0 0.191754613 0 0.191387618 0 0 0 0.191022026 0 0 0.190657827 -0.190657827 0 0.190657827 0.190295015 0 0 0 0 0 0 0.18993358 0 -0.18993358 0.18993358 0 0.189573516 0.189214815 0 0 0 0.188857469 0 0 0.18850147 0 0 0.18814681 0 0.187793482 0 then the value of autocorrelations i.e. correlalogram comes as approx 1 0.089252308 0.058227292 0.017934984 0.025264591 -0.014925678 -0.004668544 0.014890995 0.001625333 0.010669589 -0.010587179 -0.03000206 -0.011863654 0.00772247 0.024272208 -0.019521244 -0.035998575 -0.061608877 -0.048401231 -0.008594859 which show that the values are quite likely to make series stationary :) data[1:10,] V1 V2 1 4.96 0.000 2 4.95 -0.2018164 3 4.96 0.2018164 4 4.96 0.000 5 4.97 0.2014099 6 4.97 0.000 7 4.97 0.000 8 4.97 0.000 9 4.97 0.000 10 4.98 0.2010051 adf.test(data[,1]) Augmented Dickey-Fuller Test data: data[, 1] Dickey-Fuller = -1.1052, Lag order = 5, p-value = 0.9188 alternative hypothesis: stationary adf.test(data[,2]) Augmented Dickey-Fuller Test data: data[, 2] Dickey-Fuller = -6.2265, Lag order = 5, p-value = 0.01 alternative hypothesis: stationary Warning message: p-value smaller than printed p-value in: adf.test(data[, 2]) this explains everything clearly :) your NULL hypothesis is Series is not stationary - hence hypothesis in negative sense prooved by taking ideal data data1-rnorm(1) #normal data adf.test(data1) Augmented Dickey-Fuller Test data: data1 Dickey-Fuller = -21.2118, Lag order = 21, p-value = 0.01 alternative hypothesis: stationary Warning message: p-value smaller than printed p-value in: adf.test(data1) HTH Megh Dal [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 08/16/2007 04:27 PM To r-help@stat.math.ethz.ch cc Subject [R] ADF test Hi all, Hope you people do not feel irritated for repeatedly sending mail on Time series. Here I got another problem on the same, and hope I would get some answer from you. I have following dataset: data[,1] [1] 4.96 4.95 4.96 4.96 4.97 4.97 4.97 4.97 4.97 4.98 4.98 4.98 4.98 4.98 4.99 4.99 5.00 5.01 [19] 5.01 5.00 5.01 5.01 5.01
[R] adf test: trend, no drift - rep: invalid 'times' argument
Hello! I am applying the ADF.test function from package uroot to a time series of data. When I apply the full test, incorporating drift and trend terms, the regressor estimate of the drift term is not significantly different from zero. So I apply the test to a model without drift term, with deterministic trend only. But then I always get the following error: summary(ADF.test(wts=ts(seasons$summer, start=1850, frequency=1), itsd=c(0,1,c(0)), regvar=0, selectlags=list(mode=c(1,2,3 Error in rep(NA, ncol(table)) : invalid 'times' argument Error in summary(ADF.test(wts = ts(seasons$summer, start = 1850, frequency = 1), : error in evaluating the argument 'object' in selecting a method for function 'summary' I have no idea why this error occurs. Any suggestions will be appreciated. Regards, Martin - http://auto-motor-und-sport.bg/ С бензин в кръвта! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] adf test and cross-correlation with missing values
Dear List, I have multiple time series, all of which (excepting 1) have missing values. These run for ~30 years, with monthly sampling. I need to determine stationarity, and have tried to use the Augmented Dickey-Fuller test (adf.test), but this cannot handle missing values. The same problem occurs when attempting cross-correlation (ccf). Could someone please suggest any suitable functions in R to check for stationarity and to look at cross-correlation when NAs are present in a time series (and also, which packages these would be in) - or, do I have to interpolate the missing values first in order to perform these tests on my time series? Thankyou, Lillian. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html