i

R Programming Complete Tutorial

Chi-Square Test

A chi-square statistic is a test that measures how expectations compare to actual observed data (or model results). There are two main kinds of chi-square tests: the test of independence for data and tests of goodness of fit for a model. These tests can be used to determine if a certain null hypothesis can be rejected in hypothesis testing.

A chi-square test will give a p-value. It will tell whether test results are significant or not. In order to perform a chi-square test and get the p-value, we need two pieces of information:

  • Degrees of freedom. It is the number of categories minus 1.

  • The alpha level(α). This is chosen by the researcher or us. The usual alpha level (significance level) is 0.05 (5%), but we could also have other levels, like 0.01 or 0.10.

Example: