[R] error while extracting the p-value from adf.test

R. Michael Weylandt michael.weylandt at gmail.com
Fri Mar 22 15:27:20 CET 2013


On Fri, Mar 22, 2013 at 2:03 PM, Yuan, Rebecca
<rebecca.yuan at bankofamerica.com> wrote:
> Hello all,
>
> I tried to extract the p-value from adf.test in tseries; however, I got the error message such as
>
>> ht=adf.test(list.var$aa)
>> ht$p-value
> Error in ht$p - value : non-numeric argument to binary operator
>> ht
>
>         Augmented Dickey-Fuller Test
>
> data:  list.var$aa
> Dickey-Fuller = -2.3147, Lag order = 4, p-value = 0.4461
> alternative hypothesis: stationary
>
>> ht$data
> [1] "list.var$aa"
>> ht$p-value
> Error in ht$p - value : non-numeric argument to binary operator
>> ht$p
> NULL
>
> I do not have problem extracting the data in ht, but why not p-value? Is that because the "-" between "p" and "value"?

Basically yes: x$p-value  parses as x[["p", exact = FALSE]] - value
instead of x[["p-value", exact = FALSE]] because `p-value` is not a
syntactic name. I think a more common name for R would be p.value
which is perfectly fine.

MW


>
> Thanks,
>
> Rebecca
>
>
>
>
> ----------------------------------------------------------------------
> This message, and any attachments, is for the intended r...{{dropped:5}}
>
> ______________________________________________
> 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