test_hypothesis {utile.tools} | R Documentation |
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 class 'numeric'
test_hypothesis(
x,
y,
test = c("anova", "kruskal", "wilcoxon"),
digits = 1,
p.digits,
...
)
## S3 method for class '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 class 'logical'
test_hypothesis(
x,
y,
test = c("chisq", "fisher"),
digits = 1,
p.digits,
simulate.p.value = FALSE,
B = 2000,
workspace = 2e+07,
...
)
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. |
Value
A list containing the statistical test performed, test statistic, and p-value.
Note
Statistical testing used is dependent on type of 'x' data. Supported testing for numeric data includes ANOVA ('anova'), Kruskal-Wallis ('kruskal'), and Wilcoxon Rank Sum ('wilcoxon') tests. For categorical data, supported testings includes Pearson's Chi-squared ('chisq') and Fisher's Exact Test ('fisher').
Examples
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)