4

我有需要分析的高频商品价格数据。我的目标是不假设任何季节性成分,而只是确定趋势。这是我在使用 R 时遇到问题的地方。我知道有两个主要函数可以用来分析这个时间序列:decompose() 和 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,但是 decompose() 和 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)])

谢谢你。

4

1 回答 1

16

两者stl()decompose()都用于季节性分解,因此您必须具有季节性成分。如果您只想估计趋势,那么任何非参数平滑方法都可以完成这项工作。例如:

fit <- loess(crude.data$Price ~ crude.data$Time)
plot(cbind(observed=crude.data$Price,trend=fit$fitted,random=fit$residuals),main="")
于 2010-03-29T06:10:37.027 回答