chisqPostHoc: Tests for significant differences among all pairs of...

Description Usage Arguments Details Value See Also Examples

View source: R/testsPostHoc-utils.R

Description

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

Usage

1
2
3
4
5
6
7
chisqPostHoc(
  chi,
  popsInRows = TRUE,
  control = stats::p.adjust.methods,
  digits = 4,
  verbose = TRUE
)

Arguments

chi

A chisq.test object

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

verbose

A logical that conrols whether the warning message from the individual chisq.test calls are printed

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 (see p.adjust). 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.

See Also

chisq.test and p.adjust.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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
# Fits chi-square test and shows summary
( chi1 <- chisq.test(M) )
# Shows post-hoc pairwise comparisons using fdr method
chisqPostHoc(chi1)

# Transpose the observed table to demonstrate use of popsInRows=FALSE
( chi2 <- chisq.test(t(M)) )
chisqPostHoc(chi2,popsInRows=FALSE)

# How does it handle spares columns
( obs <- matrix(c(20,0,20,30,20,20,10,0,0),nrow=3,byrow=TRUE) )
chi1 <- chisq.test(obs)
chisqPostHoc(chi1)
( obs <- matrix(c(20,0,0,30,20,20,10,0,0),nrow=3,byrow=TRUE) )
chi1 <- chisq.test(obs)
chisqPostHoc(chi1)

droglenc/NCStats documentation built on June 5, 2021, 2:06 p.m.