fit_hts: Fit a hierarchical time series model

Description Usage Arguments Value How to allow weighting of observations? Examples

View source: R/hts-fit.R

Description

Fit a hierarchical time series model

Usage

1
2
3
4
5
6
7
8
9
fit_hts(
  formula,
  .data,
  special_index,
  family,
  verbose = TRUE,
  keep_data = TRUE,
  ...
)

Arguments

formula

formula must contain fixed effect terms and hts()

.data

a tsibble

special_index

The variable that represents time in your data

family

character.

verbose

default TRUE, whether to display message

keep_data

attach the data used to fit the model to the final model object?

...

list of options to pass to inlabru::bru, see ?inlabru::bru to see these options.

Value

inlabru model

How to allow weighting of observations?

To weight your observations, say when using empirical logit, you must provide a vector of variances, for each observation, which represents the uncertainty of measurement. You can do this, provided the family = "gaussian", add the argument, scale = vec, to fit_hts, where vec is a vector of variances for each observation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
m <- fit_hts(
#inputs are  the levels of hierarchy, in order of decreasing size
formula = pr ~ avg_lower_age + hts(who_subregion, country),
.data = malaria_africa_ts,
family = "gaussian",
special_index = month_num
)

## End(Not run)

njtierney/yahtsee documentation built on Feb. 5, 2022, 8:25 p.m.