hhh4_formula: Specify Formulae in a Random Effects HHH Model

Description Usage Arguments Note See Also Examples

Description

The special functions fe and ri are used to specify (unit-specific) effects of covariates and a random intercept term, respectively, in formulae used in the function hhh4.

Usage

1
2
3
4
  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, omiting 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

This function should only be used in formula objects for hhh4, and is not intended for direct calling.

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

See Also

addSeason2formula, usage of formulae in the vignette and in examples of hhh4.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# some calls of the fitting function 'hhh4': 
# see vignette("hhh4") for further details

data("influMen")
fluMen <- disProg2sts(influMen)
meningo <- fluMen[, "meningococcus"]

## Ex: univariate time series of meningococcal infections in Germany
# Negative binomial model with
# endemic component: Intercept + S = 1 sine/cosine pair
# autoregressive component: Intercept

f.S1 <- addSeason2formula(f = ~ 1, S = 1, period = 52)
hhh4(meningo, list(
    ar = list(f = ~ 1),
    end = list(f = f.S1), 
    family = "NegBin1"
))


## Ex: disease-specific intercept in influenza/meningococcal time series
# Negative binomial model with
# autoregressive component: disease-specific intercepts
# neighbour-driven component: only transmission from flu to men
# endemic component: S=3 and S=1 sine/cosine pairs for flu and men, respectively

Wflumen <- neighbourhood(fluMen)
Wflumen["meningococcus","influenza"] <- 0
Wflumen
f.end <- addSeason2formula(f = ~ -1 + fe(1, which = c(TRUE,TRUE)), 
                           S = c(3, 1), period = 52)
f.end
m <- list(ar = list(f = ~ -1 + fe(1, unitSpecific = TRUE)),
          ne = list(f = ~ 1, weights = Wflumen),
          end = list(f = f.end),
          family = "NegBinM")
hhh4(fluMen, control = m)


## Not run: 
## Ex: (correlated) random intercepts for influenza in Southern Germany
# Negative binomial model with
# autoregressive component: Intercept
# neighbour-driven component: random intercepts
# endemic component: random intercepts + trend + S = 3 sine/cosine pairs

data("fluBYBW")
f.end <- addSeason2formula(f = ~ -1 + ri(type = "iid", corr="all") +
                                 I((t-208)/100), S = 3, period = 52)
wji <- neighbourhood(fluBYBW)/rowSums(neighbourhood(fluBYBW))
model.B2 <- list(ar = list(f = ~ 1),
                 ne = list(f = ~ -1 + ri(type = "iid", corr="all"), 
                           weights = wji),
                 end = list(f = f.end, offset = population(fluBYBW)),
                 family = "NegBin1", verbose = TRUE)
hhh4(fluBYBW, model.B2)

## End(Not run)

jimhester/surveillance documentation built on May 19, 2019, 10:33 a.m.