Deviance information criterion from posterior mean residual deviance and effective parameters

Compares models fitted to the same data and likelihood by adding a penalty for complexity to the fit. D_res is the posterior mean of the residual deviance, and D_fit is the residual deviance at the posterior means of the fitted values. Their difference is p_D, the effective number of parameters, which is the sum over data points of each point's posterior mean deviance less its deviance at the mean fitted value. The sum of D_res and p_D is the criterion, and lower values suggest a more parsimonious model. HE-FM-AIC-001 charges 2 for each estimated parameter at one maximised likelihood, whereas p_D comes from the posterior and need not be a whole number.

Signature

p_D = D_res - D_fit; DIC = D_res + p_D
Inputs
InputsDefinitionUnit
D_resPosterior mean of the residual deviance of the modeldimensionless, compared with the number of independent data points
D_fitResidual deviance computed with each fitted value replaced by its posterior mean, summed over data pointsdimensionless
Output
p_DSum over data points of the posterior mean deviance less the deviance at the mean fitted valuedimensionless
DICPosterior mean residual deviance plus the effective number of parametersdimensionless

Function

Bayesian analysis function for a posterior and its decision summaries

Takes a prior distribution for an unknown model input, a likelihood and the observed data and returns the posterior distribution with the summaries a health technology assessment reads, such as a posterior mean, an expected value of perfect information and a model comparison statistic. The posterior is proportional to likelihood times prior, and HE-FN-BAD-001 gives the normalised form. Live records already hold the common conjugate updates, the beta for a probability in HE-FM-BETA-002, the normal for a treatment effect in HE-FM-BAD-001 and the Dirichlet for a transition row in HE-FM-DIRI-002. The posterior mean of HE-FM-BETA-002 is also the average of the prior mean and the trial proportion weighted by alpha_0 + beta_0 and n (derived). Posterior draws feed the acceptability curve HE-FM-CEAC-001 and EVPI from draws HE-FM-EVPI-002. This package adds the gamma update for an event rate, exact EVPI when incremental net benefit is linear in a beta probability, and the deviance information criterion. Notation follows the Bayesian Analysis article.

Computational function

  • Computational function: binomial arm counts and fitted draws to residual deviance, effective parameters and DIC

    Takes the observed events and patients per trial arm and a table of retained posterior draws of the fitted event counts, and returns the residual deviance per arm, each arm's contribution to p_D, their sum and the criterion. It applies equation 4 of TSD 2 to each arm in each draw, averages over draws, repeats the calculation at the mean fitted count and then applies HE-FM-BAYA-003. The Math / Code line holds two arms with the arm means already taken, and the R and Python versions take any number of arms and draws.

    Inputs and outputs: r_1 and r_2 are observed events, n_1 and n_2 patients, with events above 0 and below patients in the Math / Code line, and at least 0 and at most patients in Excel, R and Python; rb_1 and rb_2 are the posterior mean fitted events, each above zero and below the arm's patients; dm_1 and dm_2 are the posterior mean residual deviances of the arms; dev_1 and dev_2 are the deviances at the fitted means; pd_1 and pd_2 are the arm contributions to p_D; D_res, p_D and DIC are as in HE-FM-BAYA-003.

    Assumption: A binomial likelihood with each trial arm contributing one independent data point, and draws retained after burn-in from converged chains.

    Worked example (Two illustrative arms and four fixed draws): Arm 1 has 10 events in 100 patients with fitted draws 9, 11, 13 and 9, and arm 2 has 20 events in 100 with fitted draws 18, 21, 22 and 20. A real analysis uses thousands of draws. r_1 = 10; n_1 = 100; rb_1 = 10.5; dm_1 = 0.299116; r_2 = 20; n_2 = 100; rb_2 = 20.25; dm_2 = 0.140761 give dev_1 = 0.026985; dev_2 = 0.003882; pd_1 = 0.272131; pd_2 = 0.136879; D_res = 0.439877; p_D = 0.409010; DIC = 0.848887.

    Excel: One helper column per arm and one row per draw, with each cell =2*(IF(Events>0,Events*LN(Events/Fit),0)+IF(Patients>Events,(Patients-Events)*LN((Patients-Events)/(Patients-Fit)),0)), where Events and Patients are the arm's cells and Fit is the fitted draw in that row. AVERAGE over each column gives the arm's mean deviance, and the same formula at AVERAGE of the fitted draws gives its deviance at the mean. Name the sums ResDevFromTable and FitDevFromTable, then =ResDevFromTable-FitDevFromTable for EffParamsFromTable and =ResDevFromTable+EffParamsFromTable for DICFromTable.

    R: dic_binom <- function(r, n, draws) { dev <- function(f) 2 * (ifelse(r > 0, r * log(r / f), 0) + ifelse(n > r, (n-r) * log((n-r) / (n-f)), 0)); dm <- rowMeans(matrix(apply(draws, 1, dev), nrow = length(r))); pd <- dm-dev(colMeans(draws)); list(D_res = sum(dm), p_D = sum(pd), DIC = sum(dm) + sum(pd)) }

    Python: import numpy as np def dic_binom(r, n, draws): r, n, draws = np.asarray(r, float), np.asarray(n, float), np.asarray(draws, float) def dev(f): a = np.where(r > 0, r * np.log(np.where(r > 0, r, 1) / f), 0.0) b = np.where(n > r, (n-r) * np.log(np.where(n > r, n-r, 1) / (n-f)), 0.0) return 2 * (a + b) dm = np.mean([dev(f) for f in draws], axis=0) pd = dm-dev(draws.mean(axis=0)) return dict(D_res=dm.sum(), p_D=pd.sum(), DIC=dm.sum() + pd.sum())

    The Math / Code line has no value for an arm with no events or with every patient an event, because it then takes the log of zero. In Excel, R and Python such an arm contributes only its other term, and a single draw gives p_D of 0. In R and Python draws has one row per draw and one column per arm. A fitted draw of 0 with events above zero, or equal to the patients with non-events above zero, returns an infinite deviance in R and Python, with p_D and DIC then infinite or NaN, and #DIV/0! in Excel, and needs a sampler that keeps fitted events inside those limits.

    Test (illustrative table): =ROUND(DICFromTable,3)=0.849 returns TRUE for the table above. Doubling or halving the cell returns FALSE.

    Test (a second route): =ABS(DICFromTable-(2*ResDevFromTable-FitDevFromTable))<0.0001 returns TRUE, and returns FALSE if DICFromTable holds the residual deviance alone, 0.440.

    Common error (deviance of the mean read as the mean of the deviance): Taking 0.030867, the deviance at the mean fitted counts, as D_res gives p_D of zero and hides the whole 0.409, because the deviance is not linear in the fitted count.

    Source: Dias S, Welton NJ, Sutton AJ, Ades AE. NICE DSU Technical Support Document 2: A generalised linear modelling framework for pairwise and network meta-analysis of randomised controlled trials. University of Sheffield; August 2011, last updated September 2016. Section 2.1.2, equation 4.

    dev_1 = 2 * (r_1 * log(r_1 / rb_1) + (n_1 - r_1) * log((n_1 - r_1) / (n_1 - rb_1))); dev_2 = 2 * (r_2 * log(r_2 / rb_2) + (n_2 - r_2) * log((n_2 - r_2) / (n_2 - rb_2))); pd_1 = dm_1 - dev_1; pd_2 = dm_2 - dev_2; D_res = dm_1 + dm_2; p_D = pd_1 + pd_2; DIC = D_res + p_D

Try this function

Implementations

  • Excel

    Effective parameters and deviance information criterion in two cells

    With named cells ResDevMean and ResDevFit, the formulas return EffectiveParams and DICValue.

    =ResDevMean-ResDevFit; =ResDevMean+EffectiveParams

Assumptions

  • Same likelihood and data across models compared by DIC

    The models share one likelihood and one data set, such as fixed and random effects models or fixed effect models with and without covariates, the uses Dias and colleagues name.

  • Posterior summaries taken after convergence for DIC

    D_res and the posterior means of the fitted values come from retained draws after burn-in on chains that have converged.

  • Fit taken at the mean of the fitted values for DIC

    D_fit uses the mean of the fitted values, as Dias and colleagues propose. WinBUGS takes the fit at the mean of the parameters, so its p_D and DIC can differ, except under a normal likelihood.

Worked examples

  • Fixed effect model in the Blocker example

    Table 2 of TSD 2 reports D_res of 46.8 against 44 data points, p_D of 23.0 and DIC of 69.8. D_fit of 23.8 is D_res less p_D (derived).

    D_res = 46.8; D_fit = 23.8; p_D = 23.0; DIC = 69.8
  • Random effects model in the Blocker example

    Table 2 of TSD 2 reports D_res of 41.9, p_D of 28.1 and DIC of 70.0. D_fit of 13.8 is D_res less p_D (derived). The better fit is offset by more effective parameters, and TSD 2 says the DIC suggests little to choose between the two models.

    D_res = 41.9; D_fit = 13.8; p_D = 28.1; DIC = 70.0

Common errors

  • Model chosen on residual deviance alone without the complexity penalty

    In the Blocker example the random effects model has the lower D_res, 41.9 against 46.8, yet its DIC is 70.0 against 69.8 because p_D is 28.1 against 23.0. Reading D_res alone hides the extra complexity.

  • Posterior mean deviance read as absolute model fit

    Dias and colleagues state that the posterior mean deviance without the saturated deviance removed is useful only for comparing models. Comparison with the number of data points, such as 46.8 against 44, needs the residual deviance.

Sources

  • TSD 2 on residual deviance, effective parameters and the deviance information criterion

    Dias S, Welton NJ, Sutton AJ, Ades AE. NICE DSU Technical Support Document 2: A generalised linear modelling framework for pairwise and network meta-analysis of randomised controlled trials. University of Sheffield; August 2011, last updated September 2016. Section 2.1.2, Model fit and model comparison, equation 4 and pp. 13-15, which defines the residual deviance, each point's contribution to pD as the posterior mean of its residual deviance minus the deviance at the posterior mean of the fitted values, and the DIC as the sum of the posterior mean residual deviance and p_D, with lower values suggesting a more parsimonious model.

    View source →

  • TSD 2 Blocker example values for the deviance information criterion

    Dias S, Welton NJ, Sutton AJ, Ades AE. NICE DSU Technical Support Document 2: A generalised linear modelling framework for pairwise and network meta-analysis of randomised controlled trials. University of Sheffield; August 2011, last updated September 2016. Section 2.1.3, Table 2, p. 16, which reports the fixed effect model with residual deviance 46.8, pD 23.0 and DIC 69.8 and the random effects model with 41.9, 28.1 and 70.0, compared with 44 data points, based on 20,000 iterations on 3 chains after a burn-in of 10,000.

    View source →

Canonical Identity

This formula is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).

Author: Dr Darrin Baines · Publisher: Intelligent Parameters Ltd · Identifier: https://healtheconomics.wiki/formula/deviance-information-criterion-from-posterior-mean-residual-deviance-and-effective-parameters

Deviance information criterion from posterior mean residual deviance and effective parameters | HealthEconomics.wiki