Chi squared tests and expected counts, Cheat Sheet of Statistics

Chi squared tests and expected counts

Typology: Cheat Sheet

2020/2021

Uploaded on 06/13/2021

tea-rasclas
tea-rasclas 🇳🇿

1

(1)

3 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Statistics Notes Continued:
Chi Squared Test:
With two categorical variables:
Create a table of counts.
Create a table of proportions.
Create bar plots from tables.
Categorical bivariate data.
Data where we have two categorical measurements form each individual.
Table of counts:
used to display two categorical variables.
Example for table of counts code:
itch.table= table(duck$Infected, duck$Lake)
itch.table
itch.prop = prop.table(itch.table, 2)
barplot(itch.prop, legend=TRUE)
If the variables were not related, the proportions would be the same.
Chi-squared test continued:
Use RStudio to do a Chi-squared test.
A Chi-squared test:
Is used with bivariate categorical data.
Determines whether the two variables are related.
Expected frequencies are calculated based on the null hypothesis being true.
Write the null and alternative hypotheses. Null is always 'not related' and alternative is always 'is
related'.
Code on RStudio:
chisq.test(itch.table)
Check p-value. If this is lower than 0.05, the alternative is favoured.
Conclude that there is or is not evidence.
Conditions met?
1. Sample is representative (random). Or assume, if it is reasonable to.
2. All expected counts are at least 5.
Expected counts:
Calculate expected counts.
Use RStudio to produce expected counts.
Check sample size condition of chi-squared test.
pf2

Partial preview of the text

Download Chi squared tests and expected counts and more Cheat Sheet Statistics in PDF only on Docsity!

Statistics Notes Continued:

Chi Squared Test: With two categorical variables: Create a table of counts. Create a table of proportions. Create bar plots from tables. Categorical bivariate data. Data where we have two categorical measurements form each individual. Table of counts:

  • used to display two categorical variables. Example for table of counts code: itch.table= table(duck$Infected, duck$Lake) itch.table itch.prop = prop.table(itch.table, 2) barplot(itch.prop, legend=TRUE) If the variables were not related, the proportions would be the same. Chi-squared test continued: Use RStudio to do a Chi-squared test. A Chi-squared test:
  • Is used with bivariate categorical data.
  • Determines whether the two variables are related.
  • Expected frequencies are calculated based on the null hypothesis being true. Write the null and alternative hypotheses. Null is always 'not related' and alternative is always 'is related'. Code on RStudio: chisq.test(itch.table) Check p-value. If this is lower than 0.05, the alternative is favoured. Conclude that there is or is not evidence. Conditions met?
  1. Sample is representative (random). Or assume, if it is reasonable to.
  2. All expected counts are at least 5. Expected counts: Calculate expected counts. Use RStudio to produce expected counts. Check sample size condition of chi-squared test.

Use the residuals to add to the conclusion. Expected count = (row total x column total) / grand total Calculate expected counts on RStudio: Are conditions met?

  1. Sample is representative. Random sampling.
  2. All expected counts are at least 5. Even if condition 1 is met, if the counts are lower, then the conclusion may not be fully trusted.