首页 > 解决方案 > 时间序列中拟合的奇数季节图

问题描述

我有一个时间序列,称为bicoal.tons存储 1920 年至 1968 年的煤炭生产信息。

Time Series:
Start = 1920 
End = 1968 
Frequency = 1 
 [1] 569 416 422 565 484 520 573 518 501 505 468 382 310 334 359 372 439 446 349 395
[21] 461 511 583 590 620 578 534 631 600 438 516 534 467 457 392 467 500 493 410 412
[41] 416 403 422 459 467 512 534 552 545

plot(time_series)

在此处输入图像描述

由于该数据是每年测量一次,decompose()或者stl()不能用于提取季节性图(因为频率 = 1)。所以我所做的是使用 Factor 函数设置一个虚拟变量。我计算了图中的完整周期数(=9)并使用length(time_series),在原始图上拟合了回归。

v <- Factor(c(rep(1:5,9),1,2,3,4))
fits <- rlm(time_series~cbind(v))
plot(time_series)
lines(as.vector(time(time_series)),fitted(fits),lty=2)

在此处输入图像描述

如图所示,季节性拟合(虚线)具有完全相同的幅度,这显然不是一个很好的拟合。有没有办法解决这个问题?

标签: r

解决方案


推荐阅读