# Computing/retrieving the Deviance Information Criterion (DIC)

As a criterion for model fit and model comparison, the DIC can be retrieved using an R-function in the bayzRfunc.R file (see Using R and R Coda for loading the bayzRfunc.R functions).
The DIC is not (yet) available for output from discrete trait (threshold) models.

## Notes on interpreting DIC

The 'best' model as indicated by the DIC is simply the one with **lowest DIC**, irrespective of the number of parameters.
The DIC is comparable to the AIC (Aikaikes Information Criterion) in that there is already a penalty included for number of parameters fitted, and it is possible that larger, more complex, models show worse (higher) DIC.
This would reflect that the more complex model does not improve the fit sufficiently in order to support estimating the additional parameters. Like AIC, DIC also allows to select a 'best' model for non-nested models.

## Computing DIC in R

There are two DIC functions supplied in the bayzRfunc.R package:

- dic1("jobname","trait"): appropriate to compute the DIC for a single trait model, or for multi-trait models where all residuals have been modelled independently. The trait can be a single name to compute DIC for one trait (e.g. "weight"), or can be a list of names to compute and combine DIC for multiple traits (e.g., c("fat","milk","protein")).
- dic2("jobname"): appropriate to compute the DIC for multi-trait models that have used a resid.* ~ norm lvec specification. This version automatically computes the DIC for all traits combined.

In the output the DIC is broken down in a fit statistic and an estimate of the number of parameters (pD).