chisq.post.hoc: Tests for significant differences among all pairs of...

Description Usage Arguments Details Value Note See Also Examples

View source: R/chisqPostHoc.R

Description

Tests for significant differences among all pairs of populations in a chi-square test.

Usage

1
2
3
chisq.post.hoc(tbl, test = c("fisher.test"), popsInRows = TRUE,
  control = c("fdr", "BH", "BY", "bonferroni", "holm", "hochberg", "hommel"),
  digits = 4, ...)

Arguments

tbl

A table object.

test

What sort of test will be used? This must have an object called p.value so it can correct the p-values. Defaults to "fisher.test"

popsInRows

A logical indicating whether the populations form the rows (default; =TRUE) of the table or not (=FALSE).

control

A string indicating the method of control to use. See details.

digits

A numeric that controls the number of digits to print.

...

Other arguments sent to whatever test the user specifies.

Details

Post-hoc tests for which pairs of populations differ following a significant chi-square test can be constructed by performing all chi-square tests for all pairs of populations and then adjusting the resulting p-values for inflation due to multiple comparisons. The adjusted p-values can be computed with a wide variety of methods – fdr, BH, BY, bonferroni, holm, hochberg, and hommel. This function basically works as a wrapper function that sends the unadjusted “raw” p-values from each pair-wise chi-square test to the p.adjust function in the base R program. The p.adjust function should be consulted for further description of the methods used.

Value

A data.frame with a description of the pairwise comparisons, the raw p-values, and the adjusted p-values.

Note

This code was adapted and modified from the NCStats package

See Also

chisq.test and p.adjust.

Examples

1
2
3
4
5
6
# Makes a table of observations -- similar to first example in chisq.test
M <- as.table(rbind(c(76, 32, 46), c(48,23,47), c(45,34,78)))
dimnames(M) <- list(sex=c("Male","Female","Juv"),loc=c("Lower","Middle","Upper"))
M
# Shows post-hoc pairwise comparisons using fdr method
chisq.post.hoc(M)

Example output

Loading required package: MASS
        loc
sex      Lower Middle Upper
  Male      76     32    46
  Female    48     23    47
  Juv       45     34    78
Adjusted p-values used the fdr method.

       comparison  raw.p  adj.p
1 Male vs. Female 0.2183 0.2183
2    Male vs. Juv 0.0003 0.0009
3  Female vs. Juv 0.1076 0.1614

fifer documentation built on May 30, 2017, 7:40 a.m.

Related to chisq.post.hoc in fifer...