Learn R Programming

surveillance (version 1.8-1)

hhh4_update: update a fitted "hhh4" model

Description

Re-fit a "hhh4" model with a modified control list.

Usage

## S3 method for class 'hhh4':
update(object, ..., S = NULL, subset.upper = NULL,
       use.estimates = FALSE, evaluate = TRUE)

Arguments

object
a fitted "hhh4" model.
...
components modifying the original control list for hhh4. Modifications are performed by modifyList(object$control, list(...)).
S
a named list of numeric vectors serving as argument for addSeason2formula, or NULL (meaning no modification of seasonal terms). This argument provides a convenient way of
subset.upper
if a scalar value, restrict the new fit to those epochs of object$control$subset which are <= subset.upper<="" code="">. This argument is used by oneStepAhead.
use.estimates
logical specifying if the coef(object) should be used as starting values for the new fit. This currently only works if the set of parameters is unchanged by the updated model formulation and thus defaults to FALSE.
evaluate
logical indicating if the updated model should be fitted directly (defaults to TRUE). Otherwise, the updated control list is returned.

Value

  • If evaluate = TRUE the re-fitted object, otherwise the updated control list for hhh4.

See Also

hhh4

Examples

Run this code
data("salmonella.agona")
## convert to sts class
salmonella <- disProg2sts(salmonella.agona)

## fit a basic model
fit0 <- hhh4(salmonella,
            list(ar = list(f = ~1), end = list(f = addSeason2formula(~t))))

## update: Poisson -> NegBin1, component seasonality
fit1 <- update(fit0, family = "NegBin1", S = list(end=2, ar=2))

## compare fits
AIC(fit0, fit1)
opar <- par(mfrow=c(2,2))
plot(fit0, type="fitted", names="fit0", par.settings=NULL)
plot(fit1, type="fitted", names="fit1", par.settings=NULL)
plot(fit0, fit1, type="season", components=c("end", "ar"), par.settings=NULL)
par(opar)

Run the code above in your browser using DataLab