在 CARET 中使用时间片方法进行模型解释
Model interpretation using timeslice method in CARET
假设您要评估一个简单的 glm 模型来预测经济数据系列。
考虑以下代码:
library(caret)
library(ggplot2)
data(economics)
h <- 7
myTimeControl <- trainControl(method = "timeslice",
initialWindow = 24*h,
horizon = 12,
fixedWindow = TRUE)
fit.glm <- train(unemploy ~ pce + pop + psavert,
data = economics,
method = "glm",
preProc = c("center", "scale","BoxCox"),
trControl = myTimeControl)
假设训练公式中使用的协变量是对其他模型获得的值的预测。
这个简单的模型给出了以下结果:
Generalized Linear Model
574 samples
3 predictor
Pre-processing: centered (3), scaled (3), Box-Cox transformation (3)
Resampling: Rolling Forecasting Origin Resampling (12 held-out with a fixed
window)
Summary of sample sizes: 168, 168, 168, 168, 168, 168, ...
Resampling results:
RMSE Rsquared
1446.335 0.2958317
除了得到不好的结果(这只是一个例子)。
不知是否正确:
- 将上述结果视为仅使用 24*h=24*7 个样本训练并在每 horizon=12 个样本后重新训练的 GLM 在整个数据集上获得的结果
- 如何在 horizon 从 1 增长到 12 时评估 RMSE(如此处 http://robjhyndman.com/hyndsight/tscvexample/ 所报告)?
如果我显示 fit.glm 摘要,我将获得:
Call:
NULL
Deviance Residuals:
Min 1Q Median 3Q Max
-5090.0 -1025.5 -208.1 833.4 4948.4
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7771.56 64.93 119.688 < 2e-16 ***
pce 5750.27 1153.03 4.987 8.15e-07 ***
pop -1483.01 1117.06 -1.328 0.185
psavert 2932.38 144.56 20.286 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 2420081)
Null deviance: 3999514594 on 573 degrees of freedom
Residual deviance: 1379446256 on 570 degrees of freedom
AIC: 10072
Number of Fisher Scoring iterations: 2
显示的参数是指最后训练的 GLM 还是 "average" 参数?
我希望我已经足够清楚了。
这种重采样方法与其他方法一样。使用训练数据的不同子集来估计 RMSE。请注意,它显示“Summary of sample sizes: 168, 168, 168, 168, 168, 168, ...
”。最终模型使用 all 的训练数据集。
Rob 的结果与这些结果之间的差异主要是由于平均绝对误差 (MAE) 和均方根误差 (RMSE) 之间的差异
假设您要评估一个简单的 glm 模型来预测经济数据系列。 考虑以下代码:
library(caret)
library(ggplot2)
data(economics)
h <- 7
myTimeControl <- trainControl(method = "timeslice",
initialWindow = 24*h,
horizon = 12,
fixedWindow = TRUE)
fit.glm <- train(unemploy ~ pce + pop + psavert,
data = economics,
method = "glm",
preProc = c("center", "scale","BoxCox"),
trControl = myTimeControl)
假设训练公式中使用的协变量是对其他模型获得的值的预测。 这个简单的模型给出了以下结果:
Generalized Linear Model
574 samples
3 predictor
Pre-processing: centered (3), scaled (3), Box-Cox transformation (3)
Resampling: Rolling Forecasting Origin Resampling (12 held-out with a fixed
window)
Summary of sample sizes: 168, 168, 168, 168, 168, 168, ...
Resampling results:
RMSE Rsquared
1446.335 0.2958317
除了得到不好的结果(这只是一个例子)。 不知是否正确:
- 将上述结果视为仅使用 24*h=24*7 个样本训练并在每 horizon=12 个样本后重新训练的 GLM 在整个数据集上获得的结果
- 如何在 horizon 从 1 增长到 12 时评估 RMSE(如此处 http://robjhyndman.com/hyndsight/tscvexample/ 所报告)?
如果我显示 fit.glm 摘要,我将获得:
Call:
NULL
Deviance Residuals:
Min 1Q Median 3Q Max
-5090.0 -1025.5 -208.1 833.4 4948.4
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7771.56 64.93 119.688 < 2e-16 ***
pce 5750.27 1153.03 4.987 8.15e-07 ***
pop -1483.01 1117.06 -1.328 0.185
psavert 2932.38 144.56 20.286 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 2420081)
Null deviance: 3999514594 on 573 degrees of freedom
Residual deviance: 1379446256 on 570 degrees of freedom
AIC: 10072
Number of Fisher Scoring iterations: 2
显示的参数是指最后训练的 GLM 还是 "average" 参数? 我希望我已经足够清楚了。
这种重采样方法与其他方法一样。使用训练数据的不同子集来估计 RMSE。请注意,它显示“Summary of sample sizes: 168, 168, 168, 168, 168, 168, ...
”。最终模型使用 all 的训练数据集。
Rob 的结果与这些结果之间的差异主要是由于平均绝对误差 (MAE) 和均方根误差 (RMSE) 之间的差异