# 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

- 1. When to use
- 2. Null hypothesis
- 3. Alternative hypothesis
- 4. Assumptions
- 5. Test statistic
- 6. Sampling distribution
- 7. Significant?
- 8. Example context
- 9. SPSS
- 10. Jamovi

##### 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:

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 (H_{0}):

- H
_{0}: the population proportions in each of the $J$ conditions are $\pi_1$, $\pi_2$, $\ldots$, $\pi_J$

- H
_{0}: the probability of drawing an observation from condition 1 is $\pi_1$, the probability of drawing an observation from condition 2 is $\pi_2$, $\ldots$, the probability of drawing an observation from condition $J$ is $\pi_J$

##### Alternative hypothesis

The goodness of fit test tests the above null hypothesis against the following alternative hypothesis (H_{1} or H_{a}):

- H
_{1}: the population proportions are not all as specified under the null hypothesis

- H
_{1}: the probabilities of drawing an observation from each of the conditions are not all as specified under the null hypothesis

##### 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:

- Sample size is large enough for $X^2$ to be approximately chi-squared distributed. Rule of thumb: all $J$ expected cell counts are 5 or more
- Sample is a simple random sample from the population. That is, observations are independent of one another

##### 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 H_{0}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:

- Check if $X^2$ observed in sample is equal to or larger than critical value $X^{2*}$ or
- Find $p$ value corresponding to observed $X^2$ and check if it is equal to or smaller than $\alpha$

##### 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...- Put your categorical variable in the box below Test Variable List
- Fill in the population proportions / probabilities according to $H_0$ in the box below Expected Values. If $H_0$ states that they are all equal, just pick 'All categories equal' (default)

##### Jamovi

How to perform the goodness of fit test in jamovi:

Frequencies > N Outcomes - $\chi^2$ Goodness of fit- Put your categorical variable in the box below Variable
- Click on Expected Proportions and fill in the population proportions / probabilities according to $H_0$ in the boxes below Ratio. If $H_0$ states that they are all equal, you can leave the ratios equal to the default values (1)