htest: Basic Bivariate Hypothesis Testing and Plotting

View source: R/htest.R

htestR Documentation

Basic Bivariate Hypothesis Testing and Plotting

Description

Basic Bivariate Hypothesis Testing and Plotting

Usage

htest(
  y,
  group = NULL,
  x = NULL,
  yname = NULL,
  groupname = NULL,
  xname = NULL,
  test = c("t.test", "wilcox.test", "aov", "kruskal.test", "chisq.test", "fisher.test",
    "cor.test", "pearson", "kendall", "spearman", "ks"),
  print.plot = TRUE,
  plot.args = list(),
  theme = rtTheme,
  verbose = TRUE,
  ...
)

Arguments

y

Float, vector: Outcome of interest

group

Factor: Groups to compare

x

Float, vector: Second outcome for correlation tests

yname

Character: y variable name

groupname

Character: group variable name

xname

Character: x variable name

test

Character: Test to use; one of:

  • Continuous outcome by group: "t.test", "wilcox.test", "aov", "kruskal.test"

  • Categorical outcome by group: "chisq.test", "fisher.test", "cor.test"

  • Two continuous variables: "pearson", "kendall", "spearman"

print.plot

Logical: If TRUE, print plot. Default = TRUE

plot.args

List of arguments to pass to plotting function

theme

Character: Run themes() for available themes

verbose

Logical: If TRUE, print messages to console. Default = TRUE

...

Additional arguments to pass to test call

Author(s)

E.D. Gennatas

Examples

## Not run: 
# t.test, wilcoxon
y <- c(rnorm(200, 2, 1.2), rnorm(300, 2.5, 1.4))
group <- c(rep(1, 200), rep(2, 300))

ht_ttest <- htest(y, group, test = "t.test")
ht_wilcoxon <- htest(y, group, test = "wilcox.test")

# aov, kruskal
y <- c(rnorm(200, 2, 1.2), rnorm(300, 2.5, 1.4), rnorm(100, 2.3, 1.1))
group <- c(rep(1, 200), rep(2, 300), rep(3, 100))

ht_aov <- htest(y, group, test = "aov")
ht_kruskal <- htest(y, group, test = "kruskal.test")

# chisq, fisher
y <- c(sample(c(1, 2), 100, T, c(.7, .3)), sample(c(1, 2), 100, T, c(.35, .65)))
group <- c(rep(1, 100), rep(2, 100))
ht_chisq <- htest(y, group, test = "chisq")
ht_fisher <- htest(y, group, test = "fisher")

# cor.test
x <- rnorm(300)
y <- x * .3 + rnorm(300)
ht_pearson <- htest(x = x, y = y, test = "pearson")
ht_kendall <- htest(x = x, y = y, test = "kendall")
ht_kendall <- htest(x = x, y = y, test = "spearman")

## End(Not run)


egenn/rtemis documentation built on Nov. 22, 2024, 4:12 a.m.