r - 时间序列中拟合的奇数季节图
问题描述
我有一个时间序列,称为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)
如图所示,季节性拟合(虚线)具有完全相同的幅度,这显然不是一个很好的拟合。有没有办法解决这个问题?
解决方案
推荐阅读
- sql - 比较日期,一张表,mssql
- ios - 如何在 Swift 中使用正则表达式设置信用卡 PAN NUMBER 的模式?
- excel - WorksheetFunction 所需的对象
- java - 我的 appium 测试在一台设备上运行了两次,但我需要在两台设备上并行运行它
- java - 在 Java 中使用供应商传递方法引用
- c# - 孙子(及以后)项目的属性不被读取
- php - PHP选择具有相同ID的不同列
- arrays - 将 numpy.ndarray 中的两个单元格连接到一个单元格中
- json - vue js 数据设计策略 - 来自 API 的复杂 JSON 对象或具有 PK/FK 关系的简单 JSON 对象
- graalvm - GraalVM Polyglot 无法加载 Java 类