Replies: 1 comment 1 reply
-
|
First, your library(fpp3)
#> ── Attaching packages ──────────────────────────────────────────── fpp3 1.0.3 ──
#> ✔ tibble 3.3.1 ✔ tsibble 1.2.0
#> ✔ dplyr 1.2.1 ✔ tsibbledata 0.4.1
#> ✔ tidyr 1.3.2 ✔ ggtime 0.2.0
#> ✔ lubridate 1.9.5 ✔ feasts 0.5.0
#> ✔ ggplot2 4.0.3 ✔ fable 0.5.0
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> ✖ lubridate::date() masks base::date()
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ tsibble::intersect() masks base::intersect()
#> ✖ tsibble::interval() masks lubridate::interval()
#> ✖ dplyr::lag() masks stats::lag()
#> ✖ tsibble::setdiff() masks base::setdiff()
#> ✖ tsibble::union() masks base::union()
recent_production <- aus_production |> filter(year(Quarter) >= 1992)
beer_fit <- recent_production |> model(ARIMA(Beer))
# Generate future sample paths
beer_fc <- beer_fit |>
generate(times = 1000, h = 32)
# Aggregate to annual for complete years
beer_fc <- beer_fc |>
as_tibble() |>
mutate(year = year(Quarter)) |>
group_by(.rep, year) |>
summarise(
nquarters = n(),
.sim = sum(.sim),
.groups = "drop"
) |>
filter(nquarters == 4L) |>
select(-nquarters)Next you need to convert the simulated values into a distributional object, so you can create a fable: Here is the result, plotted with the historical data. Again, only complete years are used. Created on 2026-06-26 with reprex v2.1.1 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a flow variable (quarterly GPD).
And I want to make annual forecasts; in particular, I want to predict the next 8 years (4*8=32 quarters ahead)
I generate 1000 paths for each horizon-quarter.
So for each of the 32 horizon-quarters, I get 1000 values.
My goal is to calculate the quantiles annually; that is for each of the 8 years.
Should I add up the 1000 values by year before calculating the annual quantiles?
I display a hypothetical example from your nice book but I am not sure if my code below is correct
I am not sure how to proceed after this code
Beta Was this translation helpful? Give feedback.
All reactions