MerQuR+Statistics Glossary

Statistics Glossary → Goodness-of-fit tests (Pearson X² and deviance)

Goodness-of-fit tests (Pearson X² and deviance)concept

Tests of how well the frequencies or probabilities predicted by a model match the observed data; the most common are the Pearson X² and deviance (G²) statistics.

Pearson X² = Σ (O - E)²/E is the sum of squared standardized differences between observed (O) and model-expected (E) frequencies. The deviance (G²) = 2 Σ O·ln(O/E) compares the model's likelihood with that of the saturated model, which fits every observation exactly. In large samples both approach a chi-square distribution whose degrees of freedom are the number of cells (or covariate patterns) minus the number of estimated parameters. The null hypothesis is 'the model fits the data'.

These tests are meaningful only when the data are grouped, i.e. each covariate pattern has enough observations; with continuous predictors each observation forms its own pattern and the chi-square approximation breaks down. For binary outcomes, grouping tests such as Hosmer-Lemeshow are then used. The deviance is also used to compare nested models: the difference in deviance between two models is the likelihood ratio test. In Poisson and binomial models, a ratio of deviance or X² to its degrees of freedom clearly above 1 signals overdispersion.

An everyday example

A bakery models how the number of bagels sold per day differs between weekdays and weekends. The model gives the expected sales for each day; compared with observed sales, the deviance is 52 on 26 degrees of freedom. Since the ratio is close to 2, the Poisson assumption understates the real day-to-day fluctuation: there is overdispersion.

In MerQur

Available as 'Extra output: Pearson / Deviance goodness of fit' in multinomial and ordinal logistic regression, where it is meaningful when there are few covariate patterns (categorical predictors) and invalid with continuous predictors. It also appears as 'Extra output: Hosmer-Lemeshow' in logistic regression, 'Hosmer-Lemeshow' in probit regression, the 'Archer-Lemeshow goodness-of-fit test' in weighted logistic regression, 'Additional output: Goodness-of-fit test and indices' in exploratory factor analysis, and in point pattern analysis as the chi-square goodness-of-fit test of the cell counts under 'Quadrat counts'; the log-linear model tests effects with goodness-of-fit (G², χ²) tests.

Analyses where this concept appears

Log-Linear ModelLogistic RegressionMultinomial Logistic RegressionOrdinal Logistic RegressionExploratory Factor Analysis (EFA)Weighted Logistic Regression (Survey Logistic Regression)Probit RegressionPoint Pattern Analysis (Ripley K/L, G/F/J, CSR)

Related concepts

Hosmer-Lemeshow goodness-of-fit testLikelihood ratio test (LRT)