我是时间序列分析的新手,我正在尝试一些在一些教程中看到的代码。我用股票价格作为时间序列数据。
library(quantmod)
aapl=getSymbols("AAPL",from="2015-01-01",auto.assign=F)
is.ts(aapl)
ts.aapl=as.ts(aapl)
is.ts(ts.aapl)
x=Cl(ts.aapl)
head(x)
plot(decompose(s))
plot(stl(x))但它显示出这些错误
> plot(decompose(x))
Error in decompose(x) : time series has no or less than 2 periods
> plot(stl(x))
Error in stl(x) : series is not periodic or has less than two periods错误是由于缺乏季节性和趋势吗?
发布于 2016-08-17 20:42:36
这一错误很可能是由于您的x是一个不规则的时间序列:存在时间间隔,例如在2015-01-03,2015-01-04没有数据。您必须实现您自己版本的decompose,例如,遵循以下方法:
https://stackoverflow.com/questions/12623027/how-to-analyse-irregular-time-series-in-r
https://datascience.stackexchange.com/questions/13415
复制相似问题