[R] Scaling Statistical

Rui Barradas ruipbarradas at sapo.pt
Sun Jun 23 22:54:00 CEST 2013


Hello,

Sorry, I forgot to Cc the list.

Rui Barradas

Em 23-06-2013 21:44, Rui Barradas escreveu:
> Hello,
>
> See if the following does what you want.
>
> lapply(seq_len(obsv), function(i) adf.test(df[df$ID == i, 3]))
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 23-06-2013 19:12, Olga Musayev escreveu:
>> Short question: Is it possible to use statistical tests, like the
>> Augmented
>> Dickey-Fuller test, in functions with for-loops? If not, are there any
>> alternative ways to scale measures?
>>
>> Detailed explanation: I am working with time-series, and I want to flag
>> curves that are not stationary and which display pulses, trends, or level
>> shifts.
>>
>>> df
>>
>> DATE          ID VALUE2012-03-06    1   5.672012-03-07    1
>> 3.452012-03-08    1   4.562012-03-09    1   20.302012-03-10    1
>> 5.102012-03-06    2   5.672012-03-07    2   3.452012-03-08    2
>> 4.562012-03-09    2   5.282012-03-10    2   5.102012-03-06    3
>> 5.672012-03-07    3   7.802012-03-08    3   8.792012-03-09    3
>> 9.432012-03-10    3   10.99
>>
>>   You can see, object 2 is stationary, but 3 exhibits a trend and 1 has a
>> pulse at 3/09.
>>
>> What I want, in pseudo-code:
>>
>> flag<- list()
>> for (i in 1:length(obsv)) {
>>       if adf.test(i) FAIL {
>>             append(flag, i)
>>             }}
>>
>> What I have so far:
>>
>>> library(tseries)
>>> adf.test(df[which(df$ID==1), 3])
>> Augmented Dickey-Fuller Test
>>
>> data:  dataDickey-Fuller = 11.1451, Lag order = 16, p-value = 0.01null
>> hypothesis: non-stationary
>>> adf.test(df[which(df$ID==2), 3])
>> Augmented Dickey-Fuller Test
>>
>> data:  dataDickey-Fuller = 11.1451, Lag order = 16, p-value = 0.99
>> alternative hypothesis: stationary
>>
>>> adf.test(df[which(df$ID==3), 3])Augmented Dickey-Fuller Test
>>
>> data:  dataDickey-Fuller = 11.1451, Lag order = 16, p-value = 0.04null
>> hypothesis: non-stationary
>>
>>   How can I use this output in a for-loop? Thank you in advance!
>>
>>     [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>>



More information about the R-help mailing list