Learn R Programming

utile.tools (version 0.3.0)

test_hypothesis: Test the null hypothesis

Description

Tests the null hypothesis that there is no difference between grouped data.

Usage

test_hypothesis(
  x,
  y,
  test,
  digits,
  p.digits,
  simulate.p.value,
  B,
  workspace,
  ...
)

# S3 method for numeric test_hypothesis( x, y, test = c("anova", "kruskal", "wilcoxon"), digits = 1, p.digits, ... )

# S3 method for factor test_hypothesis( x, y, test = c("chisq", "fisher"), digits = 1, p.digits, simulate.p.value = FALSE, B = 2000, workspace = 2e+07, ... )

# S3 method for logical test_hypothesis( x, y, test = c("chisq", "fisher"), digits = 1, p.digits, simulate.p.value = FALSE, B = 2000, workspace = 2e+07, ... )

Value

A list containing the statistical test performed, test statistic, and p-value.

Arguments

x

A numeric, factor, or logical. Observations.

y

A factor or logical. Categorical "by" grouping variable.

test

A character. Name of the statistical test to use. See note.

digits

An integer. Number of digits to round to.

p.digits

An integer. The number of p-value digits to the right of the decimal point. Note that p-values are still rounded using 'digits'.

simulate.p.value

A logical. Whether p-values in nominal variable testing should be computed with Monte Carlo simulation.

B

An integer. Number of replicates to use in Monte Carlo simulation for nominal testing.

workspace

An integer. Size of the workspace used for the Fisher's Exact Test network algorithm.

...

Additional arguments passed to the appropriate S3 method.

Examples

Run this code
strata <- as.factor(mtcars$cyl)

# Numeric data
test_hypothesis(mtcars$mpg, strata)

# Logical data
test_hypothesis(as.logical(mtcars$vs), strata)

# Factor data
test_hypothesis(as.factor(mtcars$carb), strata)

Run the code above in your browser using DataLab