[R] Using ADF.Test
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Wed Jun 10 12:59:17 CEST 2009
On Wed, 10 Jun 2009, matifou wrote:
> ehxpieterse wrote:
>>
>> Hi,
>>
>> I am quite new to R and would appreciate some guidance, if possible.
>>
>> I have imported a csv file: spread <- read.csv("Spread.csv")
>>
>> I get the following error when I try to run adf.test:
>>> adf.test(spread,alternative = c("stationary", "explosive"),0)
>> Error in embed(y, k) : 'x' is not a vector or matrix
>>
>> Why is this?
>
> What does class(spread) give?
"data.frame", almost certainly, which is not a vector or a matrix. The
original poster should access the relevant column, e.g. by spread[,1] or
spread$foo etc. or (even better) turn it into a proper "ts" object!
> You should try as.vector(spread) and see what happens
If spread is a 1-column data.frame, then that won't change anything.
That's because is.vector(as.vector(...)) is not necessarily TRUE. Consider
x <- cars[, 1, drop=FALSE]
is.vector(x)
is.vector(as.vector(x))
identical(x, as.vector(x))
Z
> --
> View this message in context: http://www.nabble.com/Using-ADF.Test-tp23940824p23959465.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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