Why Score Predictions With Deviance?
A validation score should measure how well predictions describe outcomes that were not used to fit the model. Deviance provides one such measure for generalized linear models (GLMs): it compares the fitted model’s likelihood with the best fit that could be achieved for those same observations. That best-fitting reference is called the saturated model, which gives each observation its own fitted mean.
A smaller deviance means the predictions are closer, in the model’s likelihood scale, to that saturated reference. Deviance is not a dollar error, and its numerical size depends on the response family, the observations, and any weights. Thus, it is most directly useful for comparing predictions on the same validation data under the same response family and scoring convention.
For an exponential-dispersion model with dispersion parameter \(\phi\), the likelihood-ratio statistic is commonly written as \(D/\phi\), where \(D\) is the unscaled deviance. This tutorial reports \(D\) unless a scaled quantity is explicitly requested. When comparing models within the same family and with the same fixed \(\phi\), scaling by \(\phi\) does not change which model has the smaller score.
Three Family-Specific Deviances
The response family determines the unit deviance. The formulas below use a fitted mean \(\hat{\mu}_i\) for each validation response \(y_i\). With case weights \(w_i\), multiply each unit-deviance term by \(w_i\). Without weights, take \(w_i=1\).
For a Poisson model, \(y_i\) is a nonnegative count and \(\hat{\mu}_i>0\) is its predicted mean count. If the model predicts a frequency rate \(\hat{\lambda}_i\) for exposure \(e_i\), the predicted count mean is \(\hat{\mu}_i=e_i\hat{\lambda}_i\). Score the observed count against that mean. Equivalently, if scoring observed frequency \(y_i/e_i\), the corresponding exposure-weighted form uses weight \(e_i\).
The Gamma formula applies to strictly positive responses, such as positive claim severities under a Gamma GLM. It does not directly score zero observations: the logarithm is undefined at \(y_i=0\), and a standard Gamma response is positive. A dataset containing zeros therefore requires a model and scoring rule appropriate to those zeros, rather than substituting zero into this formula.
For a Tweedie model with variance function proportional to \(\mu^p\), the commonly used compound Poisson-Gamma setting has \(1<p<2\). Responses are nonnegative, so zero outcomes are permitted.
For \(y_i=0\) and \(1<p<2\), the first two terms are zero, giving the unit deviance \(2\hat{\mu}_i^{\,2-p}/(2-p)\). The exponent \(p\) is part of the scoring specification: it must be stated or otherwise fixed to calculate the Tweedie deviance.
Why Deviance Measures Distance From Saturated Fit
The formulas arise from comparing log likelihoods. For a specified family, the saturated model chooses its mean for observation \(i\) to equal the observed response, \(y_i\). The fitted model instead uses \(\hat{\mu}_i\). Twice the difference between the saturated log likelihood and the fitted log likelihood, summed over observations, gives the likelihood-ratio deviance. Terms that depend only on the observed data cancel in this difference.
For example, suppose independent validation counts follow Poisson distributions with means \(\hat{\mu}_i\). Their log likelihood, omitting no parameter-dependent terms, is \(-\sum_i \hat{\mu}_i+\sum_i y_i\log(\hat{\mu}_i)-\sum_i\log(y_i!)\). The saturated Poisson log likelihood uses mean \(y_i\). Subtracting the fitted log likelihood from the saturated log likelihood cancels the factorial terms; multiplying the difference by two gives the Poisson deviance formula. For a zero count, the saturated log-likelihood contribution involving \(y_i\log(y_i)\) is interpreted by its limit as zero, which explains the stated zero convention.
This construction explains both the reference point and an important limitation: the saturated model is a benchmark on the observed validation responses, not a feasible prediction rule for future risks. A low deviance indicates that the model predicts these validation outcomes relatively well on the chosen likelihood scale; it does not establish that the model is calibrated, stable over time, or appropriate for every business use.
Calculating and Interpreting Validation Deviance
Worked Example: Poisson Count Predictions With Exposure
A hypothetical portfolio validation sample has three policy records. Their exposures are \(0.5\), \(1\), and \(2\) policy-years, and the fitted claim-frequency rates are \(2\), \(1\), and \(2\) claims per policy-year. The observed claim counts are \(0\), \(2\), and \(3\). Calculate the unscaled Poisson deviance.
Method. Convert each predicted rate to a predicted count mean using \(\hat{\mu}_i=e_i\hat{\lambda}_i\). The means are \(0.5(2)=1\), \(1(1)=1\), and \(2(2)=4\). The observed counts and means are therefore \((0,1)\), \((2,1)\), and \((3,4)\).
For the first record, the zero-count convention gives \(2[0\log(0/1)-(0-1)]=2\).
For the second record, the contribution is \(2[2\log(2/1)-(2-1)]=2[1.386294-1]=0.772588\).
For the third record, the contribution is \(2[3\log(3/4)-(3-4)]=2[3(-0.287682)+1]=0.273908\).
Summing gives \(D=2+0.772588+0.273908=3.046496\), or 3.046 to three decimals. This score is positive because the predicted means do not equal all three observed counts. The check is that each contribution is nonnegative and that a record with \(y=0,\hat{\mu}=1\) contributes \(2\), not an undefined logarithm.
Common mistake avoided: using the frequency rate as the Poisson mean. The second record’s predicted count mean happens to equal its rate because exposure is one, but the first and third means must be adjusted for their exposures.
Worked Example: Gamma Severity Predictions
A hypothetical insurer evaluates two strictly positive severity observations, measured in dollars. The observed severities are \(1{,}000\) and \(600\), and the predicted means are \(800\) and \(800\). Calculate their total unscaled Gamma deviance.
Method. For each observation, use \(2[(y-\hat{\mu})/\hat{\mu}-\log(y/\hat{\mu})]\). For the first observation, \(y/\hat{\mu}=1{,}000/800=1.25\) and \((y-\hat{\mu})/\hat{\mu}=200/800=0.25\). Its contribution is \(2[0.25-\log(1.25)]=2[0.25-0.223144]=0.053713\).
For the second observation, \(y/\hat{\mu}=600/800=0.75\) and \((y-\hat{\mu})/\hat{\mu}=-200/800=-0.25\). Its contribution is \(2[-0.25-\log(0.75)]=2[-0.25+0.287682]=0.075364\).
The total is \(0.053713+0.075364=0.129077\), or 0.1291 to four decimals. Both contributions are nonnegative, as expected; either would be zero if its observed severity equalled its predicted mean.
Common mistake avoided: reversing the ratio inside the logarithm without also changing the rest of the formula. The Gamma unit deviance uses \(\log(y/\hat{\mu})\) with the displayed sign and first term.
Worked Example: Tweedie Score Including a Zero Loss
A hypothetical portfolio is scored using a Tweedie variance power \(p=1.5\). For three validation units, losses and predicted means are expressed in thousands of dollars and are \((0,1)\), \((4,4)\), and \((1,2)\). Calculate the unscaled deviance.
Method. With \(p=1.5\), the unit deviance simplifies to \(4[\sqrt{\hat{\mu}}-2\sqrt{y}+y/\sqrt{\hat{\mu}}]\). This follows by substituting \(p=1.5\) into the general Tweedie formula. For the zero loss with \(\hat{\mu}=1\), the terms involving \(y\) are zero, so the contribution is \(4\sqrt{1}=4\).
For \(y=4,\hat{\mu}=4\), the contribution is \(4[2-2(2)+4/2]=4[0]=0\). For \(y=1,\hat{\mu}=2\), it is \(4[\sqrt{2}-2+1/\sqrt{2}]\). Since \(\sqrt{2}=1.414214\) and \(1/\sqrt{2}=0.707107\), this is \(4[1.414214-2+0.707107]=4(0.121321)=0.485282\).
Thus, \(D=4+0+0.485282=4.485282\), or 4.485 to three decimals. The second record contributes zero because it is predicted exactly; the zero loss is valid for this Tweedie specification and contributes a finite positive amount.
Common mistake avoided: treating the Tweedie zero observation as if the Gamma logarithm applied. The Tweedie formula has a finite zero-response contribution when \(1<p<2\).
Practical Interpretation and Exam Traps
When reporting validation deviance, state the response, family, any weights, the Tweedie power where relevant, and whether the score is scaled or unscaled. These details make the score reproducible and prevent comparisons of unlike quantities. In particular, a Poisson score for counts and a Gamma score for severity are not directly comparable just because one is numerically smaller.
Deviance also depends on the validation sample composition. Scores can change when observations or weights change, even if the predictions for a subset of risks remain identical. For policy frequency, for example, scoring counts with their exposure-adjusted means reflects the amount of time each policy was observed. Applying weights inconsistently changes the implicit contribution of records.
A frequent exam error is to use a familiar-looking formula without checking the response family. The Poisson expression handles zero counts by a limit convention; the Gamma expression requires positive observations; and the Tweedie expression needs its variance power. Another error is to interpret zero deviance as proof that a model will predict future experience perfectly: it only says that the model’s fitted means match the scored responses in the data being evaluated.
Check Your Understanding
Use unscaled deviance unless a question says otherwise. Round numerical answers to four decimals.
- A Poisson validation record has observed count \(y=1\) and predicted mean \(\hat{\mu}=2\). Calculate its deviance contribution. (Answer: 0.6137)
- A frequency model predicts \(0.25\) claims per policy-year for a record with exposure \(2\) policy-years. The observed count is \(0\). What is the Poisson predicted count mean and deviance contribution? (Answer: Mean \(0.5\); deviance \(1.0000\))
- A Gamma model has observed severity \(1{,}200\) and predicted mean \(1{,}000\). Calculate the deviance contribution. (Answer: 0.0354)
- For Tweedie power \(p=1.5\), an observation is zero and its predicted mean is \(4\). Calculate its unit deviance. (Answer: 8.0000)
- Two Poisson validation observations have \((y,\hat{\mu})=(0,1)\) and \((2,1)\). Calculate their total deviance. (Answer: 2.7726)