0

我正在使用adf.test我的数据来检查平稳性。我希望将测试的 pvalue 存储在一个新变量中,以便我可以将其用于进一步的处理。

基本上我想做这样的事情:

x <- adf.test(Timeseries_1)$pvalue

但这不起作用!有什么帮助吗?

继续上述内容,我试图从准确性检查中提取 MAPE 的值,但出现以下错误。

> etsfit <- ets(TS_1)
> accuracy(etsfit)

> if(accuracy(etsfit)$MAPE<10){
+ fcast <- forecast(etsfit)
+ plot(fcast)}else{print("Transformation needed")}

Error in accuracy(etsfit)$MAPE : $ operator is invalid for atomic vectors

> if(accuracy(etsfit)["MAPE"]<10){
+ fcast <- forecast(etsfit)
+ plot(fcast)}else{print("Transformation needed")}

Error in if (accuracy(etsfit)["MAPE"] < 10) {:missing value where TRUE/FALSE needed
4

1 回答 1

0

想出了答案。以为会有用。

names(adf.test(Timeseries_1)) #to extract the pvalue of this test
if(adf.test(Timeseries_1)$p.value < 0.05){print("Time series is stationary")}
于 2019-02-18T14:02:18.053 回答