Get startedGet started for free

Chi-Square test of independence

1. Chi-Square test of independence

The Chi-square test of independence assesses categorical data.

2. Frequency tables

The chi-square test of independence assesses whether two nominal variables are related, for example, whether subjects are interested in eating the Cheese or Pepperoni pizza again. The frequency table, the number of times each of the conditions co-occurs, is assessed. For example, subjects contributing to the Cheese or Pepperoni pizza condition of the one-topping pizza variable also reported whether they would eat the pizza again, creating a nominal variable of yes, no, or maybe conditions. Calling the two variable columns in table gives the number of subjects that reported they might, would not, and would eat the assigned pizza again. This is the frequency table that the Chi-Square test of independence will assess.

3. Hypotheses

The null hypothesis for this test is that the topping and interest in eating the pizza again have no relationship and the alternative is that the variables are dependent and do have a relationship. Note that we cannot conclude whether the topping causes the interest in eating the pizza again, the test will only tell if a relationship exists, not whether a variable causes the other.

4. Sample size

Determining the required sample size uses pwr-dot-chisq-dot-test in the pwr package, using w for the effect size. A small effect size of w is point-one, medium is point-three, and point-five is large. Reporting the degrees of freedom with df specifies which chi-square test is of interest as the chi-square test of independence is not the only chi-square test. In the Chi-square test of independence, the degrees of freedom is the product of the number of conditions in variable one minus one and the number of conditions in variable two minus one. In the case of the pizza study, two one-topping conditions and three conditions for eating the pizza again gives two degrees of freedom. 964 total subjects are needed. Note that for a Chi-square test of independence to be valid, regardless of the sample size required by the analysis, at least five values are required at each condition combination.

5. Chi-square test

To run the chi-square test of independence, call or create the frequency table in the chisq-dot-test function. This p-value is an approximation which becomes more exact as the sample reaches infinity, therefore, the test is used for large sample sizes, such as over 1000. Our p-value of less than point-zero-five indicates that there is a relationship between eating the pizza again and the pizza topping groups.

6. Effect size

The effect size in a chi-squared test is w, which is calculated from a table of probabilities and is independent of the sample size. To transform the frequency table into probabilities, divide the frequency table by the number of observations, found with sum of the table. The probability table is called in es-dot-w2. Our w is less than point-one, indicating we have a small effect between the null and alternative AB group hypotheses.

7. Power

With the effect size w computed, the power of the test can be found. Using the same pwr-dot-chisq-dot-test function as in finding the sample size, replace the expected w with the calculated w,and power with the sample size using N. Be sure to capitalize N for this argument. Recall the degrees of freedom are output in the chisq-dot-test analysis. Power is a scale of zero to one, therefore we can be confident in our test indicating eating the pizza again is related to topping is reliable.

8. Let's practice!

Let's try this.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.