# How to test data for normality with Pearson’s chi-squared test

## Description

We often want to know whether a set of data is normally distributed, so that we can deduce what inference tests are appropriate to conduct. If we have a set of data and want to figure out if it comes from a population that follows a normal distribution, one tool that can help is Pearson’s $\chi^2$ test. How do we perform it?

## Solution, in R

View this solution alone.

We’re going to use some fake restaurant data, but you can replace our fake data with your real data in the code below. The values in our fake data represent the amount of money that customers spent on a Sunday morning at the restaurant.

1
2
3
4
5
6
spending <- c(34, 12, 19, 56, 54, 34, 45, 37, 13, 22, 65, 19,
16, 45, 19, 50, 36, 23, 28, 56, 40, 61, 45, 47, 37)

mean(spending)
sd(spending)

1
2
3
4
5
 36.52

 15.77213


We will now conduct a test of the following null hypothesis: The data comes from a population that is normally distributed with mean 36.52 and standard deviation 15.77.

We will use a value $\alpha=0.05$ as our Type I error rate. The pearson.test() function in the nortest package can perform Pearson’s $\chi^2$ test for normality.

1
2
3
# install.packages("nortest") # if you have not already done so
library(nortest)
pearson.test(spending)

1
2
3
4
Pearson chi-square normality test

data:  spending
P = 3.48, p-value = 0.6264


The p-value is 0.6264, which is greater than $\alpha=0.05$, so we fail to reject our null hypothesis. We would continue to operate under our original assumption that the data come from a normally distributed population.

See a problem? Tell us or edit the source.

## Opportunities

This website does not yet contain a solution for this task in any of the following software packages.

• Python
• Excel
• Julia

If you can contribute a solution using any of these pieces of software, see our Contributing page for how to help extend this website.