Goodness of fit test

This page offers all the basic information you need about the goodness of fit test. It is part of Statkat’s wiki module, containing similarly structured info pages for many different statistical methods. The info pages give information about null and alternative hypotheses, assumptions, test statistics and confidence intervals, how to find p values, SPSS how-to’s and more.

To compare the goodness of fit test with other statistical methods, go to Statkat's or practice with the goodness of fit test at Statkat's

Contents

When to use?

Deciding which statistical method to use to analyze your data can be a challenging task. Whether a statistical method is appropriate for your data is partly determined by the measurement level of your variables. The goodness of fit test requires one variable of the following type:

Variable type required for the goodness of fit test :
One categorical with $J$ independent groups ($J \geqslant 2$)

Note that theoretically, it is always possible to 'downgrade' the measurement level of a variable. For instance, a test that can be performed on a variable of ordinal measurement level can also be performed on a variable of interval measurement level, in which case the interval variable is downgraded to an ordinal variable. However, downgrading the measurement level of variables is generally a bad idea since it means you are throwing away important information in your data (an exception is the downgrade from ratio to interval level, which is generally irrelevant in data analysis).

If you are not sure which method you should use, you might like the assistance of our method selection tool or our method selection table.

Null hypothesis

The goodness of fit test tests the following null hypothesis (H0):

or equivalently
Alternative hypothesis

The goodness of fit test tests the above null hypothesis against the following alternative hypothesis (H1 or Ha):

or equivalently
Assumptions

Statistical tests always make assumptions about the sampling procedure that was used to obtain the sample data. So called parametric tests also make assumptions about how data are distributed in the population. Non-parametric tests are more 'robust' and make no or less strict assumptions about population distributions, but are generally less powerful. Violation of assumptions may render the outcome of statistical tests useless, although violation of some assumptions (e.g. independence assumptions) are generally more problematic than violation of other assumptions (e.g. normality assumptions in combination with large samples).

The goodness of fit test makes the following assumptions:

Test statistic

The goodness of fit test is based on the following test statistic:

$X^2 = \sum{\frac{(\mbox{observed cell count} - \mbox{expected cell count})^2}{\mbox{expected cell count}}}$
Here the expected cell count for one cell = $N \times \pi_j$, the observed cell count is the observed sample count in that same cell, and the sum is over all $J$ cells.
Sampling distribution

Sampling distribution of $X^2$ if H0 were true:

Approximately the chi-squared distribution with $J - 1$ degrees of freedom
Significant?

This is how you find out if your test result is significant:

Example context

The goodness of fit test could for instance be used to answer the question:

Is the proportion of people with a low, moderate, and high social economic status in the population different from $\pi_{low} = 0.2,$ $\pi_{moderate} = 0.6,$ and $\pi_{high} = 0.2$?
SPSS

How to perform the goodness of fit test in SPSS:

Analyze > Nonparametric Tests > Legacy Dialogs > Chi-square...
Jamovi

How to perform the goodness of fit test in jamovi:

Frequencies > N Outcomes - $\chi^2$ Goodness of fit