我正在尝试将每个地区和每个季度的预测加在一起。我试图总结一个特定的变量,但这没有用。我也尝试过对区域进行分组,但我相信要让它起作用,你需要以某种方式聚合。我正在尝试将两个预测加在一起,同时还能够使用准确度()查看准确度的变化。到目前为止,我还没有真正找到一个好的方法来做到这一点。
tourism %>%
filter(Quarter >= yearquarter("2008 Q1")) %>%
filter(Purpose == "Holiday" & State == "New South Wales") %>%
filter(Region %in% c("North Coast NSW", "South Coast", "Sydney")) %>%
mutate(Demand = case_when(
Region == "Sydney" ~ 0.03*Trips*5,
Region == "South Coast"~0.04*Trips*2,
Region == "North Coast NSW" ~ 0.04 *Trips*2
)) -> D
DTR <- D %>% filter(Quarter <= yearquarter("2016 Q4"))
DTE <- D %>% filter(Quarter >= yearquarter("2017 Q1"))
m <- DTR %>%
model(m.auto = ETS(Demand),
m.AAM = ETS(Demand ~ error("A") + trend("A") + season("M")),
m.AAdM = ETS(Demand ~ error("A") + trend("Ad") + season("M")))
m %>%
glance()
m %>%
select(m.auto) %>%
glance()
m.auto <- m %>%
select(m.auto)
f <- m %>%
select(m.auto) %>%
forecast(h = 4)
rbind(m.auto %>% accuracy(),
f %>% accuracy(data = D))
这是预测表:
structure(list(Region = c("North Coast NSW", "North Coast NSW",
"North Coast NSW", "North Coast NSW", "South Coast", "South Coast",
"South Coast", "South Coast", "Sydney", "Sydney", "Sydney", "Sydney"
), State = c("New South Wales", "New South Wales", "New South Wales",
"New South Wales", "New South Wales", "New South Wales", "New South Wales",
"New South Wales", "New South Wales", "New South Wales", "New South Wales",
"New South Wales"), Purpose = c("Holiday", "Holiday", "Holiday",
"Holiday", "Holiday", "Holiday", "Holiday", "Holiday", "Holiday",
"Holiday", "Holiday", "Holiday"), .model = c("m.auto", "m.auto",
"m.auto", "m.auto", "m.auto", "m.auto", "m.auto", "m.auto", "m.auto",
"m.auto", "m.auto", "m.auto"), Quarter = structure(c(17167, 17257,
17348, 17440, 17167, 17257, 17348, 17440, 17167, 17257, 17348,
17440), fiscal_start = 1, class = c("yearquarter", "vctrs_vctr"
)), Demand = structure(list(structure(list(mu = 64.5267676142378,
sigma = 7.45649497452699), class = c("dist_normal", "dist_default"
)), structure(list(mu = 45.7869538723355, sigma = 5.39507245782213), class = c("dist_normal",
"dist_default")), structure(list(mu = 42.4573776516376, sigma = 5.09748859911909), class = c("dist_normal",
"dist_default")), structure(list(mu = 53.9721361044215, sigma = 6.59826306707935), class = c("dist_normal",
"dist_default")), structure(list(mu = 61.7503906560609, sigma = 6.75515872707897), class = c("dist_normal",
"dist_default")), structure(list(mu = 35.6173573447291, sigma = 3.97232150452371), class = c("dist_normal",
"dist_default")), structure(list(mu = 27.1314815258956, sigma = 3.08272534449931), class = c("dist_normal",
"dist_default")), structure(list(mu = 38.1701802125742, sigma = 4.41547997477935), class = c("dist_normal",
"dist_default")), structure(list(mu = 95.1714054395916, sigma = 8.18541561715263), class = c("dist_normal",
"dist_default")), structure(list(mu = 85.2330580025708, sigma = 8.18541582507749), class = c("dist_normal",
"dist_default")), structure(list(mu = 79.7805187916752, sigma = 8.18541603300235), class = c("dist_normal",
"dist_default")), structure(list(mu = 77.9011650250759, sigma = 8.18541646640782), class = c("dist_normal",
"dist_default"))), vars = "Demand", class = c("distribution",
"vctrs_vctr", "list")), .mean = c(64.5267676142378, 45.7869538723355,
42.4573776516376, 53.9721361044215, 61.7503906560609, 35.6173573447291,
27.1314815258956, 38.1701802125742, 95.1714054395916, 85.2330580025708,
79.7805187916752, 77.9011650250759)), row.names = c(NA, -12L), key = structure(list(
Region = c("North Coast NSW", "South Coast", "Sydney"), State = c("New South Wales",
"New South Wales", "New South Wales"), Purpose = c("Holiday",
"Holiday", "Holiday"), .model = c("m.auto", "m.auto", "m.auto"
), .rows = structure(list(1:4, 5:8, 9:12), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, 3L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), index = structure("Quarter", ordered = TRUE), index2 = "Quarter", interval = structure(list(
year = 0, quarter = 1, month = 0, week = 0, day = 0, hour = 0,
minute = 0, second = 0, millisecond = 0, microsecond = 0,
nanosecond = 0, unit = 0), .regular = TRUE, class = c("interval",
"vctrs_rcrd", "vctrs_vctr")), response = "Demand", dist = "Demand", model_cn = ".model", class = c("fbl_ts",
"tbl_ts", "tbl_df", "tbl", "data.frame"))
如果您需要更多信息,请告诉我。