【发布时间】:2018-06-11 18:09:33
【问题描述】:
我观察到两种方法的结果是不同的。为什么是这样?我知道lm 发生了什么,但无法弄清楚tslm 的幕后发生了什么。
> library(forecast)
> set.seed(2)
> tts <- ts(100*runif(1200)+seq(1:1200)*0.1, frequency=12, start=c(2000,1))
> lm(tts~time(tts))
Call:
lm(formula = tts ~ time(tts))
Coefficients:
(Intercept) time(tts)
-2400.365 1.225
> tslm(tts~trend)
Call:
tslm(formula = tts ~ trend)
Coefficients:
(Intercept) trend
48.9350 0.1021
【问题讨论】:
-
你注意到 12 * 0.1021 = 1.225 了吗?
-
通常,时间序列数据的值是自相关的(即依赖的)。这违反了正确执行线性回归 (
lm) 所需的独立性假设。因此lm不是自相关的合适方法。在 google 上快速搜索会找到此链接 otexts.org/fpp/4/8,您可以在其中找到更多信息。
标签: r regression time-series forecasting