Create data to be used when fitting a model with fit_hts

create_hts_data(.data, formula)

Arguments

.data

tsibble

formula

formula with hts() term

Value

data.frame

Examples

data_w_groups <- create_hts_data(
  .data = malaria_africa_ts,
  formula = pr ~ avg_lower_age + hts(who_subregion, country)
  )
data_w_groups
#> # A tsibble: 1,046 x 17 [1D]
#> # Key:       country [46]
#>    who_region who_subregion country date       month_num positive examined
#>    <fct>      <fct>         <fct>   <date>         <dbl>    <dbl>    <int>
#>  1 AFRO       AFRO-W        Angola  1989-06-01       120     15.8       50
#>  2 AFRO       AFRO-W        Angola  2005-11-01       372     82        111
#>  3 AFRO       AFRO-W        Angola  2006-04-01       300    102        197
#>  4 AFRO       AFRO-W        Angola  2006-11-01       384     41        347
#>  5 AFRO       AFRO-W        Angola  2006-12-01       396    173        734
#>  6 AFRO       AFRO-W        Angola  2007-01-01       276    216        828
#>  7 AFRO       AFRO-W        Angola  2007-02-01       288     42         71
#>  8 AFRO       AFRO-W        Angola  2007-03-01       300    119        448
#>  9 AFRO       AFRO-W        Angola  2011-01-01       324      1        239
#> 10 AFRO       AFRO-W        Angola  2011-02-01       336    148       1132
#> # … with 1,036 more rows, and 10 more variables: pr <dbl>, avg_lower_age <dbl>,
#> #   continent_id <fct>, country_id <fct>, year <int>, month <int>,
#> #   avg_upper_age <dbl>, species <fct>, .who_subregion_id <int>,
#> #   .country_id <int>