surveillance (version 1.12.1)

hhh4_calibration: Test Calibration of a hhh4 Model

Description

The calibrationTest-method for "hhh4" models tests the calibration of the model fit, i.e., if the observed counts are from the fitted Poisson/NegBin distribution.

Usage

## S3 method for class 'hhh4':
calibrationTest(x,
                subset = x$control$subset, units = seq_len(x$nUnit), ...)

Arguments

x
an object of class "hhh4".
subset
subset of time points for which to test calibration. Defaults to the subset used for fitting the model.
units
integer or character vector selecting the units for which to test calibration. It indexes colnames(x$stsObj). By default all units are taken into account.
...
arguments passed to calibrationTest.default, e.g., which to select a scoring rule.

Value

Examples

Run this code
data("measlesWeserEms")

## fit a hhh4 model
measlesModel <- list(
    end = list(f = addSeason2formula(~0 + ri(type="iid"))),
    ar = list(f = ~1),
    ne = list(f = ~1, weights = W_powerlaw(maxlag = 5)),
    family = "NegBin1")
measlesFit <- hhh4(measlesWeserEms, control = measlesModel)

## plot fitted mean components
plot(measlesFit, units = NULL)

## overall calibration test
calibrationTest(measlesFit) # default is DSS (not suitable for low counts)
calibrationTest(measlesFit, which = "rps")
calibrationTest(measlesFit, which = "logs")
                
## test calibration for the second year in a specific district
calibrationTest(measlesFit, subset = 53:104, units = "03452", which = "rps")

Run the code above in your browser using DataCamp Workspace