Chapter 11 Chi squared test

The chi-square test provides a test for the goodness of fit, where fit means how closely the observed results agree with the expected results.

The formula for the chi-square test statistic is:

11.1 Chi-squared probability densities

We can determine the probability density for the chi square distribution for 1-4 degrees of freedom using the dchisq() function

11.2 Chi-square cumulative probability distributions

We can determine the cumulative probability distributions for the chi square distribution for for 1-4 degrees of freedom using the pchisq() function

11.5 Analysis of Bateson and Punnett’s data using internal R functions

Bateson and Punnett’s data. Note that data are entered COLUMN-WISE for a matrix.

Perform chi-square test using the R function chisq.test()

## 
##  Pearson's Chi-squared test
## 
## data:  bp
## X-squared = 3393.6, df = 1, p-value < 2.2e-16

and, visualize the contingency table