njtierney / yahtsee

Yet Another Hierachical Time Series Extension and Expansion
http://yahtsee.njtierney.com/
Other
2 stars 1 forks source link

Provide a way to add an overall/global random effect #28

Open njtierney opened 3 years ago

njtierney commented 3 years ago

It would look something like this in terms of inlabru code from the example

inlabru::bru(
formula = pr ~ avg_lower_age + Intercept + 
  overall(month_num,
          model = "ar1",
          constr = FALSE) +
  who_region(month_num, 
             model = "ar1", 
             group = .who_region_id,
             constr = FALSE) + 
  who_subregion(month_num, 
                model = "ar1", 
                group = .who_subregion_id, 
                constr = FALSE) + 
  country(month_num, 
          model = "ar1", 
          group = .country_id, 
          constr = FALSE),
    family = "gaussian",
    data = malaria_africa_ts,
    options = list(
      control.compute = list(config = TRUE),
      control.predictor = list(compute = TRUE, link = 1)
      )
      )

One approach we (@goldingn) discussed was an interface like so:

hts_fit(y ~ x + hts(g3, g2, g1, overall = TRUE)

Another interface could be:

hts_fit(y ~ x + hts(g3, g2, g1) + overall()

And another way that this could work is to add another column that is just uniform values (like, all "overall"), and then to include that in the hts call. We could add some syntactic sugar to make that easier for users.