如何解决在将combinf函数用于分层或分组时间序列时,如何考虑时间相关权重以进行预测对帐?
我正在使用R包combinef()
的{{1}}函数来使不连续的分层/分组时间序列预测保持一致。
hts
函数通过为“ weights”参数提供矢量,允许对不同的输入时间序列使用自定义权重。
该向量的每个值代表特定时间序列的权重因子。
与时间无关的权重因子将应用于整个时间序列。
我想知道combinef()
函数是否允许考虑时间相关的权重,例如通过提供矩阵而不是权重向量。
这是使用与时间无关的权重向量的有效示例:
combinef()
但是我想做这样的事情:
library(hts)
#incoherent forecasts
custom_forecasts_incoherent <- data.frame(Total = (seq(5,50,5) + seq(10,100,10))*1.1,A = seq(5,5),B = seq(10,10))
print(custom_forecasts_incoherent)
> print(custom_forecasts_incoherent)
Total A B
1 16.5 5 10
2 33.0 10 20
3 49.5 15 30
4 66.0 20 40
5 82.5 25 50
6 99.0 30 60
7 115.5 35 70
8 132.0 40 80
9 148.5 45 90
10 165.0 50 100
#ordinary least squares
custom_forecasts_coherent_ols <- combinef(custom_forecasts_incoherent,nodes = list(2),weights = NULL,algorithms = "lu",keep = "all"
) %>% as.data.frame %>% setNames(colnames(custom_forecasts_incoherent))
print(custom_forecasts_coherent_ols)
> print(custom_forecasts_coherent_ols)
Total A B
1 16 5.5 10.5
2 32 11.0 21.0
3 48 16.5 31.5
4 64 22.0 42.0
5 80 27.5 52.5
6 96 33.0 63.0
7 112 38.5 73.5
8 128 44.0 84.0
9 144 49.5 94.5
10 160 55.0 105.0
#custom weights using vector
weights_vec <- c(0.5,1,1)
> print(weights_vec)
[1] 0.5 1.0 1.0
custom_forecasts_coherent_custom_weights <- combinef(custom_forecasts_incoherent,weights = weights_vec,keep = "all"
) %>% as.data.frame %>% setNames(colnames(custom_forecasts_incoherent))
print(custom_forecasts_coherent_custom_weights)
> print(custom_forecasts_coherent_custom_weights)
Total A B
1 15.75 5.375 10.375
2 31.50 10.750 20.750
3 47.25 16.125 31.125
4 63.00 21.500 41.500
5 78.75 26.875 51.875
6 94.50 32.250 62.250
7 110.25 37.625 72.625
8 126.00 43.000 83.000
9 141.75 48.375 93.375
10 157.50 53.750 103.750
我有多个用例来确定与时间相关的对帐权重。 如果不执行逐步对帐(在上面的示例中为10次迭代),这怎么可能?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。