Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hhh4_formula

Specify Formulae in a Random Effects HHH Model


Description

The special functions fe and ri are used to specify unit-specific effects of covariates and random intercept terms, respectively, in the component formulae of hhh4.

Usage

fe(x, unitSpecific = FALSE, which = NULL, initial = NULL)

ri(type = c("iid","car"), corr = c("none", "all"),
   initial.fe = 0, initial.var = -.5, initial.re = NULL)

Arguments

x

an expression like sin(2*pi*t/52) involving the time variable t, or just 1 for an intercept. In general this covariate expression might use any variables contained in the control$data argument of the parent hhh4 call.

unitSpecific

logical indicating if the effect of x should be unit-specific. This is a convenient shortcut for which = rep(TRUE, nUnits), where nUnits is the number of units (i.e., columns of the "sts" object).

which

vector of logicals indicating which unit(s) should get an unit-specific parameter. For units with a FALSE value, the effect term for x will be zero in the log-linear predictor. Note especially that setting a FALSE value for the intercept term of a unit, e.g., ar = list(f = ~-1 + fe(1, which=c(TRUE, FALSE))) in a bivariate hhh4 model, does not mean that the (autoregressive) model component is omitted for this unit, but that \log(λ_1) = α_1 and \log(λ_2) = 0, which is usually not of interest. ATM, omitting an autoregressive effect for a specific unit is not possible.
If which=NULL, the parameter is assumed to be the same for all units.

initial

initial values (on internal scale!) for the fixed effects used for optimization. The default (NULL) means to use zeroes.

type

random intercepts either follow an IID or a CAR model.

corr

whether random effects in different components (such as ar and end) should be correlated or not.

initial.fe

initial value for the random intercept mean.

initial.var

initial values (on internal scale!) for the variance components used for optimization.

initial.re

initial values (on internal scale!) for the random effects used for optimization. The default NULL are random numbers from a normal distribution with zero mean and variance 0.001.

Note

These special functions are intended for use in component formulae of hhh4 models and are not exported from the package namespace.

If unit-specific fixed or random intercepts are specified, an overall intercept must be excluded (by -1) in the component formula.

See Also

hhh4 model specifications in vignette("hhh4"), vignette("hhh4_spacetime") or on the help page of hhh4.


surveillance

Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

v1.19.1
GPL-2
Authors
Michael H<f6>hle [aut, ths] (<https://orcid.org/0000-0002-0423-6702>), Sebastian Meyer [aut, cre] (<https://orcid.org/0000-0002-1791-9449>), Michaela Paul [aut], Leonhard Held [ctb, ths], Howard Burkom [ctb], Thais Correa [ctb], Mathias Hofmann [ctb], Christian Lang [ctb], Juliane Manitz [ctb], Andrea Riebler [ctb], Daniel Saban<e9>s Bov<e9> [ctb], Ma<eb>lle Salmon [ctb], Dirk Schumacher [ctb], Stefan Steiner [ctb], Mikko Virtanen [ctb], Wei Wei [ctb], Valentin Wimmer [ctb], R Core Team [ctb] (A few code segments are modified versions of code from base R)
Initial release
2021-03-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.