- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用带有单个外部变量的 forecast.gts(hts 包)
,该变量为所有单独的时间序列保存相同的值,以便创建 30 天的预测,但是我想要包括另一个外部回归器,它为每个单独的 ts 保存不同的值。
我将问题简化如下:
我有 4 个 ts 可以预测(它们是品牌和非大集团每天花费的保险付费搜索),分为两组:
我有兴趣应用两个外部回归:
所以对于第一个外部回归量,我设法使用 forecast.hts
如下:
library(ggplot2)
library(plyr)
library(hts)
library(ts)
library(data.table)
library(reshape2)
horizon<-30
data1<-dcast(data, Date ~ Brand+Venue, sum , value.var="Spend")
data[is.na(data)] <- 0
abcd<-ts(as.matrix(data1[,2:5]),frequency=7)
#abcd<-abcd+0.000001
Brand <- c("Brand","Brand","NonBrand","NonBrand")
Venue <- rep(c("Google","MSN"), 2)
gcd <- rbind(Brand,Venue)
rownames(gcd) <- c("Brand","Venue")
x <- gts(abcd, groups = gcd)
dates = data.frame(Date=seq.Date(min(data$Date,na.rm =T), max(data$Date,na.rm =T), by = "day"))
dates$enrollment<-ifelse(dates$Date>=as.Date("2013-10-01") & dates$Date<=as.Date("2014-03-31"),1,
ifelse(dates$Date>=as.Date("2014-11-15") & dates$Date<=as.Date("2015-02-15"),1,0))
enrollment_prediction<-seq.Date(max(dates$Date)+1, max(dates$Date)+horizon, by = "day")
enrollment_prediction<-ifelse(enrollment_prediction>=as.Date("2013-10-01") & enrollment_prediction<=as.Date("2014-03-31"),1,
ifelse(enrollment_prediction>=as.Date("2014-11-15") & enrollment_prediction<=as.Date("2015-02-15"),1,0))
train<-cbind(dates[,2])
predict<-cbind(enrollment_prediction)
cost_fcasts <- forecast(x, h = horizon, method = "comb",fmethod = "arima",xreg=train,newxreg=predict)
现在我的问题是:我如何创建另一个新的回归量(二元变量),它将在 2013 年 10 月 22 日期间为所有品牌 ts 分配 1 值并为非品牌 ts 分配 0 值 - 12/21/2013 & 12/24/2013 - 01/27/2014?
数据的子集:
dput(data)
structure(list(Date = structure(c(16104, 16182, 16149, 16190,
16156, 16146, 16108, 16154, 16132, 16149, 16110, 16105, 16120,
16135, 16155, 16126, 16130, 16140, 16136, 16128, 16127, 16129,
16113, 16137, 16178, 16118, 16142, 16107, 16106, 16131, 16126,
16139, 16138, 16157, 16135, 16152, 16148, 16123, 16140, 16120,
16144, 16161, 16155, 16122, 16139, 16129, 16106, 16130, 16106,
16154, 16103, 16125, 16186, 16114, 16142, 16133, 16154, 16109,
16111, 16183, 16180, 16146, 16141, 16151, 16121, 16167, 16116,
16121, 16125, 16105, 16152, 16108, 16118, 16155, 16181, 16132,
16153, 16134, 16165, 16132, 16174, 16134, 16160, 16135, 16171,
16147, 16123, 16152, 16107, 16151, 16103, 16138, 16151, 16106,
16166, 16117, 16107, 16144, 16117, 16145, 16137, 16130, 16157,
16173, 16150, 16184, 16150, 16172, 16159, 16178, 16138, 16168,
16184, 16153, 16159, 16181, 16133, 16129, 16122, 16154, 16176,
16179, 16188, 16125, 16136, 16127, 16150, 16115, 16115, 16162,
16143, 16111, 16131, 16109, 16136, 16119, 16160, 16131, 16156,
16161, 16164, 16151, 16190, 16113, 16165, 16142, 16119, 16152,
16167, 16133, 16139, 16121, 16178, 16133, 16124, 16114, 16108,
16144, 16168, 16118, 16143, 16148, 16119, 16126, 16185, 16111,
16136, 16116, 16158, 16107, 16176, 16189, 16142, 16177, 16169,
16104, 16167, 16115, 16112, 16131, 16112, 16175, 16148, 16140,
16119, 16172, 16125, 16179, 16172, 16122, 16185, 16143, 16173,
16145, 16183, 16180, 16147, 16163, 16170, 16130, 16109, 16170,
16179, 16143, 16104, 16150, 16153, 16157, 16155, 16144, 16120,
16181, 16188, 16105, 16158, 16182, 16115, 16147, 16173, 16153,
16169, 16116, 16113, 16171, 16180, 16127, 16146, 16118, 16177,
16113, 16141, 16120, 16146, 16189, 16169, 16173, 16112, 16157,
16149, 16135, 16121, 16147, 16148, 16111, 16149, 16140, 16134,
16114, 16168, 16187, 16126, 16141, 16108, 16139, 16170, 16103,
16128, 16105, 16112, 16145, 16163, 16109, 16175, 16187, 16122,
16176, 16186, 16141, 16174, 16156, 16129, 16114, 16128, 16127,
16132, 16171, 16169, 16162, 16170, 16103, 16160, 16116, 16104,
16158, 16134, 16137, 16178, 16123, 16174, 16117, 16188, 16159,
16128, 16123, 16145, 16172, 16165, 16166, 16180, 16124, 16174,
16138, 16110, 16164, 16164, 16110, 16137, 16177, 16175, 16171,
16176, 16175, 16177, 16181, 16156, 16110, 16179, 16163, 16168,
16189, 16188, 16183, 16185, 16166, 16190, 16167, 16165, 16124,
16166, 16182, 16164, 16117, 16185, 16187, 16162, 16186, 16190,
16187, 16161, 16184, 16160, 16186, 16159, 16183, 16124, 16158,
16161, 16162, 16182, 16163, 16189, 16184), class = "Date"), Spend = c(15842.58,
4053.33, 12276.37, 3255.13, 34147.63, 10280.15, 1359.05, 10630.05,
19970.06, 8264.08, 633.13, 2018.73, 4336.53, 27650.11, 26951.01,
28489.2, 668.22, 33879.52, 21996.9, 19303.88, 23985.98, 1517.48,
1766.36, 14539.82, 2356.67, 13442.66, 9853.06, 1460.34, 1885.7,
9548.48, 6922.77, 29439.75, 14516.58, 15262.33, 3533.56, 1626.65,
11114.59, 585.64, 9125.84, 17940.8, 3477.37, 342.48, 9852.61,
2936.53, 8459.63, 15603.87, 1745.46, 3913.92, 14721.02, 4547.05,
757.44, 5125.04, 1523.12, 15526.4, 45516.4, 24888.82, 3190.53,
1065.25, 4356.01, 1142.47, 269.77, 38923.51, 39508.12, 690.53,
17041.63, 1513.47, 604.92, 3320.61, 1821.44, 14143.89, 8629.41,
8033.21, 1292.16, 2460.76, 706.36, 2804.23, 11942.11, 3084.68,
65.93, 9886.54, 3934.09, 26347.99, 903.66, 7629.38, 2468.47,
18017.85, 3720.39, 3023.53, 4375.57, 2851.58, 8886.96, 642.01,
6702.67, 4350.53, 1262.83, 496.95, 13424.99, 802.84, 858.65,
22996.32, 2929.39, 11457.34, 213.06, 1136.51, 9664.37, 1168.22,
2212.77, 1170.14, 356.39, 848.81, 3164.11, 3458.27, 3612.13,
2919.57, 7448.95, 1572.38, 8165.08, 1923.62, 15476.18, 27578.67,
3455.62, 279.58, 0, 30040.45, 1530.41, 6577.7, 1725.36, 1396.46,
1321.49, 3878.4, 7021.28, 8853.14, 1283.59, 1682.93, 5563.42,
1697.88, 3841.95, 3508.54, 9989.89, 1374.71, 2466.79, 1450.81,
1246.87, 17256.75, 1184.34, 4911.98, 4279.49, 842.95, 1509.02,
1978.1, 4056.48, 2312.5, 2674.83, 2795.75, 1047.46, 1365.23,
3367.7, 28421.9, 1208.81, 2975.87, 4314.07, 9691.88, 16614.88,
1710.66, 2870, 2287.66, 3298, 3248.6, 443.4, 1647.22, 2901.93,
3610.21, 1956.94, 2885.58, 3195.33, 2173.07, 3748.72, 2734.09,
9179.23, 571.99, 3893.73, 3600.8, 2361.42, 4801.02, 2242.37,
1249.61, 2885.95, 1097.31, 293.9, 2044.25, 1075.1, 1888.26, 413.3,
2594.21, 3729.84, 881.72, 2179.57, 31.98, 637.2, 1133.57, 520.98,
2940.35, 1942.11, 43361.33, 1837.33, 7429.81, 20603.36, 9059.43,
2776.64, 3027.94, 1803.23, 4175.03, 4361.84, 4780.86, 5334.76,
1266.33, 10430.92, 3988.57, 366.93, 3517.32, 294.78, 826.85,
1920, 3048.21, 1966.12, 2332.73, 5522.68, 1855.98, 3034.97, 4473.6,
9379.69, 2278.22, 2403.14, 1256.74, 1367.85, 1887.51, 1914.65,
0, 3268.07, 1899.46, 1456.54, 9883.6, 2106.05, 2364.99, 1895.83,
1836.96, 7785.42, 3784.51, 1379.38, 1542.7, 2937.07, 1620.28,
1658.6, 2033.13, 3081.68, 1435.15, 2945.92, 1802.12, 2084.01,
3324.74, 4623.88, 661.2, 4835.06, 342.56, 1398.99, 1131.91, 328.3,
4903.98, 4993.82, 0, 6923.42, 1591.52, 1692.26, 1607.41, 1898.13,
611.49, 1344.86, 1023.46, 1168.65, 532.7, 17004.37, 655.28, 5582.81,
1116.49, 1811.79, 4365.59, 657.33, 1225.97, 1150.57, 40.46, 1543.24,
1487.07, 7264.13, 528.31, 621, 333.81, 372.11, 446.69, 334.46,
528.69, 1353.67, 1881.9, 1040.74, 969.57, 92.97, 57.16, 611.54,
1104.2, 1478.91, 931.5, 582.02, 973.26, 753.14, 1365.5, 0, 1.61,
318.24, 1116.22, 124.04, 0, 0, 0, 0, 0, 0, 0, 0, 3.75, 26.52,
0, 0, 1.41, 0, 0, 0, 0, 0, 0, 0, 0, 18.57, 0, 2.7, 0, 24.74,
0, 0, 0, 72.7, 0, 0, 0), Brand = c("NonBrand", "Brand", "NonBrand",
"Brand", "NonBrand", "Brand", "NonBrand", "Brand", "NonBrand",
"Brand", "Brand", "Brand", "Brand", "NonBrand", "NonBrand", "NonBrand",
"Brand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "Brand",
"Brand", "NonBrand", "Brand", "NonBrand", "Brand", "NonBrand",
"Brand", "NonBrand", "Brand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "Brand", "Brand", "NonBrand",
"Brand", "Brand", "Brand", "Brand", "Brand", "NonBrand", "NonBrand",
"Brand", "NonBrand", "NonBrand", "NonBrand", "Brand", "Brand",
"NonBrand", "NonBrand", "NonBrand", "Brand", "NonBrand", "Brand",
"Brand", "Brand", "NonBrand", "NonBrand", "Brand", "NonBrand",
"NonBrand", "Brand", "Brand", "Brand", "NonBrand", "NonBrand",
"NonBrand", "Brand", "Brand", "NonBrand", "NonBrand", "Brand",
"NonBrand", "NonBrand", "Brand", "Brand", "NonBrand", "NonBrand",
"Brand", "Brand", "NonBrand", "NonBrand", "Brand", "Brand", "Brand",
"NonBrand", "Brand", "NonBrand", "Brand", "Brand", "Brand", "NonBrand",
"Brand", "NonBrand", "NonBrand", "Brand", "NonBrand", "Brand",
"Brand", "NonBrand", "Brand", "NonBrand", "Brand", "NonBrand",
"Brand", "Brand", "Brand", "Brand", "Brand", "Brand", "NonBrand",
"Brand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "Brand", "Brand", "Brand", "NonBrand",
"Brand", "Brand", "Brand", "NonBrand", "NonBrand", "NonBrand",
"Brand", "Brand", "Brand", "Brand", "Brand", "Brand", "Brand",
"NonBrand", "Brand", "NonBrand", "Brand", "NonBrand", "Brand",
"Brand", "Brand", "Brand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "Brand", "NonBrand", "NonBrand",
"Brand", "NonBrand", "Brand", "NonBrand", "Brand", "Brand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "Brand", "Brand", "Brand",
"Brand", "Brand", "Brand", "Brand", "Brand", "Brand", "NonBrand",
"Brand", "Brand", "Brand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "Brand", "NonBrand", "NonBrand", "Brand",
"Brand", "NonBrand", "NonBrand", "Brand", "Brand", "Brand", "NonBrand",
"NonBrand", "NonBrand", "Brand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "Brand", "NonBrand", "Brand", "NonBrand", "NonBrand",
"Brand", "Brand", "Brand", "Brand", "Brand", "Brand", "NonBrand",
"NonBrand", "Brand", "NonBrand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand",
"Brand", "Brand", "NonBrand", "Brand", "Brand", "NonBrand", "NonBrand",
"Brand", "NonBrand", "NonBrand", "Brand", "Brand", "Brand", "Brand",
"Brand", "Brand", "Brand", "Brand", "Brand", "Brand", "Brand",
"NonBrand", "Brand", "Brand", "Brand", "Brand", "Brand", "NonBrand",
"NonBrand", "NonBrand", "Brand", "Brand", "Brand", "NonBrand",
"Brand", "Brand", "Brand", "Brand", "NonBrand", "NonBrand", "Brand",
"Brand", "Brand", "Brand", "Brand", "Brand", "NonBrand", "Brand",
"Brand", "Brand", "Brand", "Brand", "Brand", "Brand", "Brand",
"Brand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand",
"Brand", "Brand", "Brand", "Brand", "Brand", "Brand", "Brand",
"Brand", "NonBrand", "Brand", "Brand", "NonBrand", "NonBrand",
"Brand", "NonBrand", "NonBrand", "Brand", "Brand", "Brand", "Brand",
"NonBrand", "NonBrand", "NonBrand", "Brand", "NonBrand", "Brand",
"Brand", "Brand", "NonBrand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "Brand",
"NonBrand", "NonBrand", "NonBrand", "Brand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand",
"NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand", "NonBrand"
), Venue = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,
1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L,
1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L,
2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L,
1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L,
2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L,
2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L,
2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L,
2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Google", "MSN"), class = "factor")), .Names = c("Date",
"Spend", "Brand", "Venue"), row.names = c(16L, 24L, 31L, 54L,
69L, 72L, 85L, 100L, 107L, 115L, 118L, 134L, 137L, 156L, 184L,
195L, 198L, 226L, 284L, 289L, 290L, 321L, 345L, 358L, 359L, 361L,
389L, 397L, 418L, 456L, 458L, 478L, 486L, 524L, 550L, 560L, 576L,
588L, 598L, 600L, 625L, 649L, 735L, 775L, 782L, 791L, 891L, 896L,
901L, 907L, 973L, 987L, 1209L, 1266L, 1276L, 1282L, 1304L, 1326L,
1329L, 1350L, 1370L, 1537L, 1773L, 1775L, 1825L, 1921L, 2117L,
2476L, 2478L, 2555L, 2556L, 2726L, 2761L, 2949L, 2974L, 3339L,
3350L, 3438L, 3731L, 3843L, 3887L, 3890L, 3920L, 3922L, 3939L,
3944L, 4021L, 4049L, 4072L, 4105L, 4138L, 4149L, 4174L, 4180L,
4232L, 4261L, 4274L, 4281L, 4290L, 4316L, 4335L, 4417L, 4439L,
4514L, 4565L, 4567L, 4632L, 4778L, 4787L, 4849L, 4889L, 4996L,
5126L, 5199L, 5328L, 5342L, 5455L, 5466L, 5807L, 5932L, 6159L,
6242L, 6611L, 6926L, 6928L, 6934L, 6963L, 6969L, 7018L, 7036L,
7037L, 7039L, 7043L, 7121L, 7183L, 7186L, 7230L, 7237L, 7298L,
7333L, 7358L, 7394L, 7505L, 7515L, 7520L, 7615L, 7648L, 7655L,
7920L, 7964L, 8049L, 8079L, 8093L, 8364L, 8586L, 8596L, 8885L,
8896L, 8906L, 9299L, 9506L, 9561L, 9625L, 9647L, 9688L, 9700L,
9710L, 9722L, 9732L, 9754L, 9794L, 9798L, 9803L, 9868L, 9927L,
9947L, 9951L, 9955L, 9984L, 9987L, 9998L, 10146L, 10169L, 10213L,
10396L, 10409L, 10484L, 10505L, 10658L, 10678L, 10702L, 10710L,
10841L, 10846L, 10932L, 10952L, 11037L, 11048L, 11213L, 11258L,
11276L, 11282L, 11382L, 11432L, 11447L, 11777L, 11936L, 12024L,
12027L, 12079L, 12092L, 12132L, 12173L, 12180L, 12246L, 12446L,
12468L, 12501L, 12704L, 12736L, 12741L, 12780L, 12810L, 12816L,
12852L, 13200L, 13539L, 13659L, 13879L, 13969L, 13998L, 14022L,
14166L, 14537L, 14579L, 14708L, 15241L, 15712L, 15780L, 15784L,
15814L, 15829L, 15862L, 15880L, 15915L, 15941L, 15977L, 15999L,
16166L, 16494L, 16594L, 17368L, 17371L, 17376L, 17387L, 17401L,
17433L, 17447L, 17462L, 17463L, 17476L, 17482L, 17630L, 17797L,
17878L, 18051L, 18151L, 18461L, 18466L, 18488L, 18765L, 18766L,
18780L, 18830L, 18831L, 18884L, 18925L, 19006L, 19022L, 19023L,
19396L, 19510L, 19975L, 20000L, 20001L, 20043L, 20180L, 20587L,
20685L, 20849L, 20885L, 21174L, 21182L, 21325L, 21411L, 21414L,
21443L, 21735L, 21870L, 21969L, 22059L, 22279L, 22405L, 22620L,
22648L, 22892L, 23073L, 23143L, 23992L, 24744L, 25054L, 25460L,
25581L, 26298L, 26656L, 26684L, 26693L, 26858L, 28041L, 29034L,
29345L, 29468L, 29634L, 29657L, 29675L, 29926L, 29967L, 30091L,
30162L, 30203L, 30537L, 30569L, 30573L, 30762L, 30777L, 31110L,
31247L, 31328L, 31684L, 32036L, 32151L, 32192L, 32375L, 32540L,
32759L, 32896L, 33038L, 33643L, 33659L, 34136L, 34471L, 34652L
), class = "data.frame")
最佳答案
我不建议在您的示例中使用 forecast.gts()
,因为针对不同时间序列处理不同的 xreg
仍在开发中。但还有另一种方法可以让您到达那里。
与其直接使用 forecast.gts()
,您需要先使用 forecast::auto.arima
生成预测,然后应用 combinef()
到这些预测以获得协调的预测。
# Create a binary variable called "shutdown"
shutdown <- ifelse(dates$Date >= as.Date("2013-10-22") &
dates$Date <= as.Date("2013-12-21"), 0,
ifelse(dates$Date >= as.Date("2013-12-24") &
dates$Date <= as.Date("2014-01-27"), 0, 1))
pred.shutdown <- rep(1, horizon) # Assume it's open in the future
brand.xregs <- data.frame(enrollment = train)
pbrand.xregs <- data.frame(enrollment = predict)
nonbrand.xregs <- data.frame(enrollment = train, shutdown = shutdown)
pnonbrand.xregs <- data.frame(enrollment = predict, shutdown = pred.shutdown)
basef <- matrix(, nrow = horizon, ncol = 4) # bottom level
for (i in 1:2) { # brand
basef[, i] <- forecast(auto.arima(abcd[, i], xreg = brand.xregs),
h = horizon, xreg = pbrand.xregs)$mean
}
for (i in 3:4) { # non brand
basef[, i] <- forecast(auto.arima(abcd[, i], xreg = nonbrand.xregs),
h = horizon, xreg = pnonbrand.xregs)$mean
}
aggx <- aggts(x, levels = 0:2)
aggbasef <- matrix(, nrow = horizon, ncol = ncol(aggx)) # aggregated level
for (i in 1:ncol(aggx)) { # brand
aggbasef[, i] <- forecast(auto.arima(aggx[, i]), h = horizon)$mean
}
allbasef <- cbind(aggbasef, basef) # All base forecasts across levels
rf <- combinef(allbasef, groups = x$groups)
希望这会有所帮助。
关于r - 预测将 forecast.gts 中的 xreg 参数与每个时间序列具有不同值的多个外部变量一起使用(hts 包),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27734095/
我的问题:非常具体。我正在尝试想出解析以下文本的最简单方法: ^^domain=domain_value^^version=version_value^^account_type=account_ty
好吧,这就是我的困境: 我正在为 Reddit 子版 block 开发常见问题解答机器人。我在 bool 逻辑方面遇到了麻烦,需要一双更有经验的眼睛(这是我在 Python 中的第一次冒险)。现在,该
它首先遍历所有 y 值,然后遍历所有 x 值。我需要 X 和 y 同时改变。 For x = 3 To lr + 1 For y = 2 To lr anyl.Cells(x, 1)
假设我有一个包含 2 列的 Excel 表格:单元格 A1 到 A10 中的日期和 B1 到 B10 中的值。 我想对五月日期的所有值求和。我有3种可能性: {=SUM((MONTH(A1:A10)=
如何转换 Z-score来自 Z-distribution (standard normal distribution, Gaussian distribution)到 p-value ?我还没有找到
我正在重写一些 Javascript 代码以在 Excel VBA 中工作。由于在这个网站上搜索,我已经设法翻译了几乎所有的 Javascript 代码!但是,有些代码我无法准确理解它在做什么。这是一
我遇到过包含日期格式的时间戳日期的情况。然后我想构建一个图表,显示“点击”项目的数量“每天”, //array declaration $array1 = array("Date" => 0); $a
我是scala的新手! 我的问题是,是否有包含成员的案例类 myItem:Option[String] 当我构造类时,我需要将字符串内容包装在: Option("some string") 要么 So
我正在用 PHP 创建一个登录系统。我需要用户使用他或她的用户名或电子邮件或电话号码登录然后使用密码。因为我知道在 Java 中我们会像 email==user^ username == user 这
我在 C++ 项目上使用 sqlite,但是当我在具有文本值的列上使用 WHERE 时出现问题 我创建了一个 sqlite 数据库: CREATE TABLE User( id INTEGER
当构造函数是显式时,它不用于隐式转换。在给定的代码片段中,构造函数被标记为 explicit。那为什么在 foo obj1(10.25); 情况下它可以工作,而在 foo obj2=10.25; 情况
我知道这是一个主观问题,所以如果需要关闭它,我深表歉意,但我觉得它经常出现,让我想知道是否普遍偏爱一种形式而不是另一种形式。 显然,最好的答案是“重构代码,这样你就不需要测试是否存在错误”,但有时没有
这两个 jQuery 选择器有什么区别? 以下是来自 w3schools.com 的定义: [attribute~=value] 选择器选择带有特定属性,其值包含特定字符串。 [attribute*=
为什么我们需要CSS [attribute|=value] Selector根本当 CSS3 [attribute*=value] Selector基本上完成相同的事情,浏览器兼容性几乎相似?是否存在
我正在解决 regx 问题。我已经有一个像这样的 regx [0-9]*([.][0-9]{2})。这是 amont 格式验证。现在,通过此验证,我想包括不应提供 0 金额。比如 10 是有效的,但
我正在研究计算机科学 A 考试的样题,但无法弄清楚为什么以下问题的正确答案是正确的。 考虑以下方法。 public static void mystery(List nums) { for (
好的,我正在编写一个 Perl 程序,它有一个我收集的值的哈希值(完全在一个完全独立的程序中)并提供给这个 Perl 脚本。这个散列是 (string,string) 的散列。 我想通过 3 种方式对
我有一个表数据如下,来自不同的表。仅当第三列具有值“债务”并且第一列(日期)具有最大值时,我才想从第四列中获取最大值。最终值基于 MAX(DATE) 而不是 MAX(PRICE)。所以用简单的语言来说
我有一个奇怪的情况,只有错误状态保存到数据库中。当“状态”应该为 true 时,我的查询仍然执行 false。 我有具有此功能的 Controller public function change_a
我有一个交易表(针对所需列进行了简化): id client_id value 1 1 200 2 2 150 3 1
我是一名优秀的程序员,十分优秀!