A Post Hoc Analysis for Pearson's Chi-Squared Test for Count Data

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

library(chisq.posthoc.test)

Introduction

When computing Pearson's Chi-squared Test for Count Data the only result you get is that you know that there is a significant difference in the data and not which parts of the data are responsible for this. Here you see the example from the chisq.test documentation.

M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"),
                    party = c("Democrat","Independent", "Republican"))
chisq.test(M)

Standarized residuals

As a form of post hoc analysis the standarized residuals can be analysed. A rule of thumb is that standarized residuals of above two show significance.

chisq.results <- chisq.test(M)
chisq.results$stdres

Post Hoc Analysis

However, the above two rule is a rule of thumb. These standarized residuals can be used to calculate p-values, which is what this package is designed for as shown in the following example.

chisq.posthoc.test(M,
                   method = "bonferroni")


Try the chisq.posthoc.test package in your browser

Any scripts or data that you put into this service are public.

chisq.posthoc.test documentation built on Oct. 30, 2019, 11:41 a.m.