Statistical significance testing

Undertake a chi-squared test for homogeneity on sample counts. The test calculates the expected counts assuming homogeneity (all classes have an equal probability) and undertakes a chi-squared test to test whether the observed values deviate significantly from the expected values.

# Chi-squared test for homogeneity of a sample

Undertake a chi-squared test for homogeneity on sample counts. The test calculates the expected counts assuming homogeneity (all classes have an equal probability) and undertakes a chi-squared test to test whether the observed values deviate significantly from the expected values.

Inputs are:

- - the desired level of confidence in the estimate;
- - the desired precision of the results; and
- - two columns of data. The first column is a list of group identifiers and the second column is sample counts for each group. A header row should be included in the data and will be used to label the output.

Outputs include:

- - a table of observed and expected counts, proportions and confidence limits;
- - chi-squared statistic, degrees of freedom and corresponding P-value; and
- - a plot of confidence limits for the proportions in each group.