ds_score_hhh4: Calculate Dawid-Sebastiani score

View source: R/dawid_sebastiani.R

ds_score_hhh4R Documentation

Calculate Dawid-Sebastiani score

Description

Calculate Dawid-Sebastiani score for a prediction returned by predictive_moments.

Usage

ds_score_hhh4(pred, detailed = FALSE, scaled = TRUE)

Arguments

pred

the prediction as returned by longterm_prediction_hhh4 (and potentially aggregated using aggregate_prediction)

detailed

detailed or less detailed output?

scaled

if detailed == FALSE: scale DSS with 2d?

Details

The Dawid-Sebastiani score is defined as

DSS = log(|\Sigma|) + t(Y_obs - \mu) \Sigma^{-1} (Y_obs - \mu)

where \mu and \Sigma are the predictive mean and variance, repectively. Y_obs represents the observation that has materialized.

Value

If detailed == FALSE: the (potentially scaled) Dawid-Sebastiani score. If detailed == TRUE: a vector containing the following elements:

  • dawid_sebastiani the un-scaled Dawid-Sebastiani score

  • term1 value of the log-determinant entering into the unn-scaled Dawid-Sebastiani score

  • term2 value of the quadratic form entering into the un-scaled Dawid-Sebastiani score

  • scaled_dawid_sebastiani the scaled Dawid-Sebastiani score

  • determinant_sharpness the determinant sharpness (scaled version of term1)

Examples

## a simple univariate example:
data("salmonella.agona")
## convert old "disProg" to new "sts" data class
salmonella <- disProg2sts(salmonella.agona)
# specify and fit model: fixed geometric lag structure
# with weight 0.8 for first lag
control_salmonella <- list(end = list(f = addSeason2formula(~ 1)),
                           ar = list(f = addSeason2formula(~ 1),
                                     par_lag = 0.8, use_distr_lag = TRUE),
                           family = "NegBinM", subset = 6:312)
fit_salmonella <- hhh4_lag(salmonella, control_salmonella)
pred_salmonella <- predictive_moments(fit_salmonella, t_condition = 260,
                                      52, return_Sigma = TRUE)
ds_score_hhh4(pred_salmonella, detailed = TRUE)


jbracher/hhh4addon documentation built on Feb. 16, 2024, 1:45 a.m.