0

As I am pretty new to fable for R, I was wondering if it is also possible to forecast a rate instead of counts within a grouped time series.

Here is a short example of the tsibble I created:

   head(data)
   # A tsibble: 6 x 5 [1Y]
   # Key:       sex, age [1]
   year sex   age   counts      pop
  <dbl> <chr> <chr>  <dbl>    <dbl>
1  2005 m     <50     1294 25986547
2  2006 m     <50     1417 26261652
3  2007 m     <50     1690 25712000
4  2008 m     <50     1827 25385000
5  2009 m     <50     1973 25037000
6  2010 m     <50     2076 24678000

as you can see there are two groups: sex(m/f) and agecategories(<50, 50-55,55-60,...). pop stands for population and counts is the number of a certain event per year (2005-2018).

I added an incidence column by

data%>%mutate(incidence=(counts/pop))

Now I would like to fit an arima model for incidence:

# Fit model 
+     model(arima = ARIMA(incidene)) %>%
+     # reconcile
+     mutate(mint = min_trace(incidence)) %>%
+     # forecasts
+     forecast(h = 10)

However, I don't know how to get the incidence-forecast for the top series group? For count data I would use:

# create aggregates
+     aggregate_key(sex * age, value = (sum(counts))

but this just includes a sum of counts which is not applicable for incidence rates...

Maybe someone could help me out?

Thanks in advance!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
DerV
  • 13
  • 4

1 Answers1

1

You're on the right track with aggregate_key(), which is the first step of hierarchical reconciliation with fable. You can use aggregate_key() to compute aggregations of counts = sum(counts) and pop = sum(pop), and then compute the incidence = counts / pop using mutate().

Edit: However as ratios are not preserved in aggregation, the ratio itself cannot easily be reconciled.

  • However, as I use min_trace for reconciliation, the forecasted value of the incidence does differ significantly to the "normal" reconciliation without min_trace...what i mean is: looking at my data/plot the forecasted value starts way above the last non-predicted observation compared to the regular reconciliation. Is there a reason for this? – DerV May 04 '20 at 21:23
  • Good observation. Hierarchical forecast reconciliation applies to series which aggregate via sums, and so reconciling incidence is not as simple (due to ratios not being summable). You could instead reconcile counts and pop, and use these forecasts to compute the incidence ratio. – Mitchell O'Hara-Wild May 05 '20 at 01:36