groupdiff: Test of group differences

Description Usage Arguments Details Value See Also Examples

View source: R/groupdiff.R

Description

One-way analysis (ANOVA or Kruskal-Wallis Test) with post-hoc comparisons and plots

Usage

1
2
3
4
5
6
7
8
groupdiff(
  formula,
  data,
  method = c("anova", "kw"),
  digits = 2,
  horizontal = FALSE,
  posthoc = TRUE
)

Arguments

formula

use the form Y ~ X where Y is the response variable, and X is the categorical explanatory variable. X will be coerced to be a factor.

data

a data frame.

method

character. Either "anova", or "kw" (see details).

digits

Number of significant digits to print.

horizontal

logical. If TRUE, boxplots are plotted horizontally.

posthoc

logical. If TRUE, the default, perform pairwise post-hoc comparisons (TukeyHSD for ANOVA and Conover Test for Kuskal Wallis). This test will only be performed if there are 3 or more levels for X.

Details

The groupdiff function performs one of two analyses:

anova

A one-way analysis of variance, with TukeyHSD post-hoc comparisons.

kw

A Kruskal Wallis Rank Sum Test, with Conover Test post-hoc comparisons.

In each case, summary statistics and a grouped boxplots are provided. In the parametric case, the statistics are n, mean, and standard deviation. In the nonparametric case the statistics are n, median, and median absolute deviation. If posthoc = TRUE, pairwise comparisons of superimposed on the boxplots. Groups that share a letter are not significantly different (p < .05), controlling for multiple comparisons.

Value

a list with 3 components:

result

omnibus test

summarystats

summary statistics

plot

ggplot2 graph

See Also

kwAllPairsConoverTest, multcompLetters.

Examples

1
2
3
4
5
6
# parametric analysis
groupdiff(hp ~ gear, mtcars)

# nonparametric analysis
groupdiff(popularity ~ vehicle_style, cardata,
          method="kw", horizontal=TRUE)

Rkabacoff/qacr documentation built on March 20, 2021, 3:03 p.m.