Likelihood Ratio Test Calculator
Inputs
- Inputs: full-model log-likelihood -214.35, reduced-model log-likelihood -221.80, 2 restrictions.
- G = 2 x (-214.35 - (-221.80)) = 14.90.
- Under the null that the restrictions hold, G follows a chi-square distribution with 2 degrees of freedom, giving p = 0.0006.
- The fuller model fits significantly better - the restrictions are rejected at the 5% level.
Two models, one nested inside the other, and a question: do the extra parameters earn their keep? The likelihood ratio test answers by comparing maximised log-likelihoods - twice the improvement from relaxing the restrictions is the statistic G, chi-square under the null. This calculator takes the two log-likelihoods and the number of restrictions, and returns G with its p-value: the test behind deviance tables, logistic regression model chi-squares and most likelihood-based model selection.
Worked examples
Restrictions rejected
(-214.35 · -221.8 · 2)
| Likelihood ratio statistic G | 14.90 |
| p-value | 0.0006 |
| Degrees of freedom | 2 |
| Log-likelihood improvement | 7.45 |
Restrictions retained
(-1050.2 · -1053.1 · 3)
| Likelihood ratio statistic G | 5.80 |
| p-value | 0.1218 |
| Degrees of freedom | 3 |
| Log-likelihood improvement | 2.90 |
One decisive restriction
(-89.44 · -97.02 · 1)
| Likelihood ratio statistic G | 15.16 |
| p-value | <0.0001 |
| Degrees of freedom | 1 |
| Log-likelihood improvement | 7.58 |
Nested models and restrictions
The test applies when the smaller model is the larger one with some parameters pinned down - set to zero, set equal, set to a hypothesised value. The number of pins is the degrees of freedom. Wilks (1938) proved that under the null hypothesis that the pins are correct, G = 2(LL_full - LL_reduced) converges to a chi-square distribution with that many degrees of freedom, whatever the model - one of the most useful limit results in statistics, because it turns any two fitted likelihoods into a test with no further machinery.
The price of that generality is fitting both models, which the Wald test avoids by fitting only the full one and the score test by fitting only the reduced one. The three classical tests agree asymptotically and differ in finite samples, with the likelihood ratio usually the best behaved of the three - the one whose chi-square approximation holds up longest as samples shrink.
- G = 2 x (log-likelihood of full model - log-likelihood of reduced model)
- Degrees of freedom: the number of restrictions
- Requires both models fitted to exactly the same data
- The deviance difference in GLMs is this statistic
Wilks' theorem in practice
The first worked example is a clean rejection: the full model's log-likelihood of -214.35 against the reduced model's -221.80 is an improvement of 7.45 points for 2 restrictions, so G = 14.90 and p = 0.0006. Improvements of that size do not happen by fitting noise - two free parameters buy, on average under the null, a G of about 2. The second example is the opposite: 2.90 points for 3 restrictions, G = 5.80, p = 0.1218, entirely consistent with the restrictions being true.
The third example shows why degrees of freedom matter as much as the raw gain: a similar improvement of 7.58 points, but bought with a single restriction, gives G = 15.16 and p below 0.0001. One parameter that buys 7.58 log-likelihood points is a discovery; three parameters that buy 2.90 are a rounding error. The statistic prices parameters, and the p-value is the exchange rate.
| Example | LL full | LL reduced | Restrictions | G | p |
|---|---|---|---|---|---|
| 1 | -214.35 | -221.80 | 2 | 14.90 | 0.0006 |
| 2 | -1050.20 | -1053.10 | 3 | 5.80 | 0.1218 |
| 3 | -89.44 | -97.02 | 1 | 15.16 | <0.0001 |
Worked examples
Example 1: Log-likelihood, full model -214.35; Log-likelihood, reduced model -221.8; Restrictions (difference in parameters) 2. Likelihood ratio statistic G = 14.90. Supporting values: p-value 0.0006; Degrees of freedom 2; Log-likelihood improvement 7.45. Inputs: full-model log-likelihood -214.35, reduced-model log-likelihood -221.80, 2 restrictions. G = 2 x (-214.35 - (-221.80)) = 14.90. Under the null that the restrictions hold, G follows a chi-square distribution with 2 degrees of freedom, giving p = 0.0006. The fuller model fits significantly better - the restrictions are rejected at the 5% level.
Example 2: Log-likelihood, full model -1050.2; Log-likelihood, reduced model -1053.1; Restrictions (difference in parameters) 3. Likelihood ratio statistic G = 5.80. Supporting values: p-value 0.1218; Degrees of freedom 3; Log-likelihood improvement 2.90. Inputs: full-model log-likelihood -1,050.20, reduced-model log-likelihood -1,053.10, 3 restrictions. G = 2 x (-1,050.20 - (-1,053.10)) = 5.80. Under the null that the restrictions hold, G follows a chi-square distribution with 3 degrees of freedom, giving p = 0.1218. The improvement is within sampling noise - the reduced model is not rejected at the 5% level.
Example 3: Log-likelihood, full model -89.44; Log-likelihood, reduced model -97.02; Restrictions (difference in parameters) 1. Likelihood ratio statistic G = 15.16. Supporting values: p-value <0.0001; Degrees of freedom 1; Log-likelihood improvement 7.58. Inputs: full-model log-likelihood -89.44, reduced-model log-likelihood -97.02, 1 restrictions. G = 2 x (-89.44 - (-97.02)) = 15.16. Under the null that the restrictions hold, G follows a chi-square distribution with 1 degrees of freedom, giving p = <0.0001. The fuller model fits significantly better - the restrictions are rejected at the 5% level.
Reading a deviance difference
In generalised linear models the same computation wears the name deviance: each model's deviance is its likelihood ratio against the saturated model, so the difference of deviances is exactly G for the pair. Analysis-of-deviance tables in R and similar software are sequences of these tests, each row asking whether the last block of terms added anything. Reading such a table with the calculator's logic - gain per parameter, priced by the chi-square - turns a wall of output into a series of small, answerable questions.
A caution about scale: with very large samples, trivially small effects produce enormous G values, because the test measures evidence, not importance. A restriction can be false, decisively rejected, and still practically irrelevant if the parameters it frees move predictions by less than the noise in using them. Report the parameter estimates beside the p-value; the test alone cannot say whether the fuller model is worth its complexity in any currency except likelihood.
Boundary problems and mixtures
Wilks' theorem needs the null value to lie inside the parameter space, not on its edge. The standard counterexample is testing whether a variance component is zero: zero is the boundary of a variance's possible values, and the null distribution becomes a mixture of chi-squares - half a point mass at zero, half a chi-square on 1 degree of freedom - rather than the plain chi-square this calculator uses. Random-effects selection in mixed models lives in that territory, and naive likelihood ratio p-values there are conservative by roughly a factor of two.
A second failure mode is non-nested comparison: models that are not restrictions of one another have no G distribution at all, and the right tools are information criteria or Vuong-style tests. The calculator's inputs will happily accept any two log-likelihoods, so the nesting judgement is the user's - the arithmetic cannot check it.
Practical notes
Both log-likelihoods must come from the same observations. If the fuller model drops rows because a new variable has missing values, the two fits describe different datasets and the difference is meaningless - refit the reduced model on the fuller model's sample before comparing. Likewise the likelihoods must be true maximised log-likelihoods from the same likelihood: comparing a penalised fit's objective against an unpenalised one is a category error the subtraction will not reveal.
Sign conventions trip people up: log-likelihoods of discrete models are negative, improvements are positive differences, and G is twice the improvement - enter the values as your software prints them, with their signs, as in the worked examples, and the calculator handles the rest.
Profile likelihood intervals are the test's most useful by-product. Inverting the test - collecting every parameter value whose restricted model is not rejected - gives a confidence interval that respects the likelihood's actual shape: asymmetric when the likelihood is asymmetric, wide where the data are uninformative, and honest in small samples where the Wald interval's symmetry is a fiction. Modern practice in biostatistics and in particle physics (where the profile likelihood ratio is the discovery statistic) runs on exactly this inversion, and the G values this calculator returns are its raw material.
The connection to information criteria is worth making explicit for model selection. AIC penalises each extra parameter by a fixed amount of log-likelihood; the likelihood ratio test prices parameters by the chi-square distribution instead, so its implicit penalty grows with the confidence demanded. Choosing between nested models by AIC and by a 5% likelihood ratio test are different policies - AIC the more permissive - and reporting which policy selected a model is part of reporting the model. The calculator serves the test-based policy; its G is also, up to the penalty convention, the quantity AIC consumes.
One more practical trap completes the list: likelihoods from models fitted by penalised or approximate methods. A log-likelihood read from a Laplace approximation, a variational bound or a penalised fit is not the maximised likelihood Wilks' theorem prices, and differencing two such quantities can produce a G that is too large, too small or even negative. When software reports a deviance it is usually the genuine article; when it reports an objective function, it usually is not. Knowing which number your package prints is the whole of this caution, and it is unglamorous precisely because the failure it prevents is silent.
A closing observation on scale ties the examples together. The three G values - 14.90, 5.80 and 15.16 - were bought with 2, 3 and 1 restrictions respectively, and their verdicts order themselves not by the size of the log-likelihood gain but by the gain per restriction weighed against the chi-square's spread. That is the test's whole philosophy in miniature: evidence is a rate, not a total. A research programme that reports likelihood gains without the parameter counts that purchased them is withholding the denominator, and this calculator exists to put the denominator back.
FAQs
What G statistic does the first example give?
The improvement is 7.45 log-likelihood points, so G = 2 x 7.45 = 14.90 on 2 degrees of freedom.
What is its p-value?
The p-value is 0.0006 - the restrictions are firmly rejected; the fuller model fits significantly better.
What G does the second example give?
It gives G = 5.80 on 3 degrees of freedom, p = 0.1218: the gain of 2.90 points is within sampling noise.
What G does the single-restriction third example give?
It gives G = 15.16 on 1 degree of freedom, p below 0.0001 - one parameter buying 7.58 points is decisive.
How much log-likelihood does the first example gain?
It gains 7.45 points, from -221.80 for the reduced model to -214.35 for the full model.
How much does the third example gain?
It gains 7.58 points, from -97.02 to -89.44, which the single degree of freedom prices much more dearly.