【发布时间】:2022-01-21 02:52:39
【问题描述】:
我有一个时间序列,我想用它创建一个回归模型,时间序列如下所示:
Date Value PREDICTOR1 PREDICTOR2 PREDICTOR3 PREDICTOR4 PREDICTOR5 PREDICTOR6 PREDICTOR7 PREDICTOR8 PREDICTOR9 PREDICTOR10 PREDICTOR11 PREDICTOR12
<date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 2021-09-02 74 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
2 2021-09-03 74.4 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
3 2021-09-07 73.9 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
4 2021-09-08 73.7 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
5 2021-09-09 73.8 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
6 2021-09-10 73.7 0.1 3.7 3.8 0.6 1.5 63.2 2.6 -51900 1.6
从中我训练了一个模型:
fit <- df %>%
model(
tslm = TSLM(Value ~ PREDICTOR1+ PREDICTOR2+ PREDICTOR3+ PREDICTOR4+ PREDICTOR5 +PREDICTOR6+ PREDICTOR7+ PREDICTOR8 +PREDICTOR9 +PREDICTOR10 +PREDICTOR11 +PREDICTOR12)
)
但我收到报告的结果:
> report(fit)
# A tibble: 3,409 x 16
id .model r_squared adj_r_squared sigma2 statistic p_value df log_lik AIC AICc BIC CV deviance df.residual rank
<int> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int>
1 1 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
2 2 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
3 3 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
4 4 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
5 5 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
6 6 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
7 7 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
8 8 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
9 9 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
10 10 tslm NaN NaN NaN NaN NaN 1 Inf -Inf -Inf -Inf NaN 0 0 1
所以它为 df (>3000) 中的每一行数据创建了一个模型,所有这些数据都无法使用。
有人有提示吗?
附: 我是第一次吗
【问题讨论】:
-
对时间序列的每一行应用线性模型以使其只有一个观察值是没有意义的。您需要更多的观察来获得系数并应用预测。有时,当您对数据集进行分组并且您有嵌套的小标题或数据框时,是的,这可能是可行的。但在这里我认为情况并非如此。
-
是的,我不知道为什么要为每行应用 1 个模型,这不是我的意图,我做错了什么?
-
你是对的@AnoushiravanR,数据集充满了组!!!
-
但取消分组后问题仍然存在
标签: r regression forecasting