我有高频商品价格数据,我需要分析。我的目标是不假设任何季节性成分,而只是确定一个趋势。这里是我在R中遇到问题的地方,我知道有两个主要的函数可以分析这个时间序列:分解()和stl()。问题是,它们都采用一个频率参数大于或等于2的ts对象类型。有什么方法可以假设每个单位时间的频率为1,并且仍然使用R来分析这个时间序列?我担心如果我假设频率大于每单位时间1,并且使用频率参数计算季节性,那么我的预测将取决于这个假设。
names(crude.data)=c('Date','Time','Price')
names(crude.data)
freq = 2
win.graph()
plot(crude.data$Time,crude.data$Price, type="l")
crude.data$Price = ts(crude.data$Price,frequency=freq) 我希望频率是1单位时间,但然后分解()和stl()不工作!
dim(crude.data$Price)
decom = decompose(crude.data$Price)
win.graph()
plot(decom$random[2:200],type="line")
acf(decom$random[freq:length(decom$random-freq)])谢谢。
发布于 2010-03-29 06:10:37
stl()和decompose()都用于季节性分解,因此必须有季节性成分。如果你只是想估计一个趋势,那么任何非参数平滑方法都将完成这项工作。例如:
fit <- loess(crude.data$Price ~ crude.data$Time)
plot(cbind(observed=crude.data$Price,trend=fit$fitted,random=fit$residuals),main="")https://stackoverflow.com/questions/2535740
复制相似问题