[R] Dickey Fuller test of a time series (problem)

Wolfgang Koller wolfgang.koller at wu-wien.ac.at
Fri Mar 20 15:51:09 CET 2009


The argument 'x' of adf.test should not only be a vector but also a 
numeric vector (see ?adf.test). Have a closer look at your data and 
how they are stored. What does  is.numeric(x)  give? I guess that 
originally your data are stored as a data frame. Converting a 
data.frame to a vector is not done properly by c(), as the following 
example shows:
z <- rnorm(289)
x <- data.frame(z)
adf.test(x,k=1)   # produces an error
y <- c(x)
is.numeric(y)     # FALSE
adf.test(y,k=1)   # produces an error
k <- 1
y <- x[,1]           #  or y <- x$z
adf.test(y,k=1)   # this works well

At 10:31 20.03.2009, you wrote:
>Hi all,
>
>I tried to do a Dickey Fuller test with R using adf.test with a time 
>series of german stock prices. I have 10 stocks from 1985 to 2009 
>with monthly stock prices. So if you do the math I have 289 values 
>for each stock.
>
>I tried to do the test for each stock alone and had the 289 values 
>of my first stock listed in R.
>When I tried to do the test with command adf.test(x, k=1) the 
>following warning displayed:
>
>Fehler in embed(y, k) : 'x' is not a vector or matrix   (Fehler means error)
>
>so I tried to write x as a vector with command: z<-c(x)
>
>I retried the test with adf.test(z, k=1) and the following error appeared:
>
>Fehler in embed(y, k) : wrong embedding dimension
>
>I tried quite a lot of other things but I cannot get why the test 
>isn't working.
>
>I'm really no expert on this matter so please help me out as the 
>test if the time series is stationary is crucial for my work.
>
>
>Thank you very much indeed
>
>Matthias
>         [[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