我正在关注与 fable R 相关的先前答案以及使用 box_cox 函数来转换响应变量。当我试图获得模型的准确性时,发生了错误。此外,当我使用预测功能时,系列仍然会发生变化。谢谢
Library(fpp3)
lambda2 <- tsibbledata::PBS %>%
aggregate_key(Concession, Cost = sum(Cost)) %>%
features(Cost, features = guerrero)
lambda2
#> # A tibble: 3 x 2
#> Concession lambda_guerrero
#> <chr*> <dbl>
#> 1 Concessional 0.252
#> 2 General 0.658
#> 3 <aggregated> 0.364
tsibbledata::PBS %>%
aggregate_key(Concession, Cost = sum(Cost)) %>%
# Add lambda to the dataset, matching based on the key variable
left_join(lambda2, by = "Concession") %>%
autoplot(box_cox(Cost, lambda_guerrero))
tsibbledata::PBS %>%
aggregate_key(Concession, Cost = sum(Cost)) %>%
# Add lambda to the dataset, matching based on the key variable
left_join(lambda2, by = "Concession") %>%
autoplot(box_cox(Cost, lambda_guerrero)) +
facet_grid(rows = vars(Concession), scales = "free_y")
act<-tsibbledata::PBS %>%
aggregate_key(Concession, Cost = sum(Cost),Scripts=sum(Scripts))
fut<-new_data(act, 10) %>% mutate(Scripts=mean(act$Scripts))
fit<-act %>%
# Add lambda to the dataset, matching based on the key variable
left_join(lambda2, by = "Concession") %>%
model( arima=ARIMA(box_cox(Cost,lambda_guerrero)~Scripts))
accuracy(fit)
#> Error: Problem with `mutate()` input `fit`.
#> x Can't convert a call to a string
#> i Input `fit` is `map(fit, accuracy, measures = measures, ...)`.
fit %>% forecast(fut )
#> A fable: 30 x 6 [1M]
#> Key: Concession, .model [3]
#> Concession .model Month `box_cox(Cost, lambda_guerrero)` .mean Scripts
#> <chr> <chr> <mth> <dist> <dbl> <dbl>
#> 1 Concessional arima 2008 Jul N(521, 2.3) 521. 7752813.
#> 2 Concessional arima 2008 Aug N(521, 3.8) 521. 7752813.
#> 3 Concessional arima 2008 Sep N(522, 4.8) 522. 7752813.
#> 4 Concessional arima 2008 Oct N(525, 5.8) 525. 7752813.
#> 5 Concessional arima 2008 Nov N(528, 6.8) 528. 7752813.
#> 6 Concessional arima 2008 Dec N(530, 7.7) 530. 7752813.
#> 7 Concessional arima 2009 Jan N(530, 8.7) 530. 7752813.
#> 8 Concessional arima 2009 Feb N(524, 9.5) 524. 7752813.
#> 9 Concessional arima 2009 Mar N(525, 10) 525. 7752813.
#> 10 Concessional arima 2009 Apr N(524, 11) 524. 7752813.
#> ... with 20 more rows