View source: R/two_sample_htest.R
two_sample_htest | R Documentation |
Calculates two sample hypothesis tests and effect size depending on the class of its input.
two_sample_htest(value, group, ...)
## S3 method for class 'character'
two_sample_htest(value, group, ...)
## S3 method for class 'factor'
two_sample_htest(value, group, two_sample_htest.factor = NULL, ...)
## S3 method for class 'logical'
two_sample_htest(value, group, ...)
## S3 method for class 'numeric'
two_sample_htest(value, group, two_sample_htest.numeric = NULL, ...)
## S3 method for class 'ordered'
two_sample_htest(value, group, two_sample_htest.ordered = NULL, ...)
value |
An atomic vector. These values will be tested. |
group |
A factor with two levels and same length as |
... |
Passed to methods. |
two_sample_htest.factor |
Analog to argument two_sample_htest.numeric |
two_sample_htest.numeric |
Either |
two_sample_htest.ordered |
Analog to argument two_sample_htest.numeric |
Results are passed to function format_tests
for the final table.
So the results of two_sample_htest
must have a class for which the generic
format_tests
has a method.
If you are not pleased with the current hypothesis tests you may alter these functions. But you must keep the original output-format, see section Value.
Note that the various statistical test functions in R have heterogeneous arguments:
for example chisq.test
and ks.test
do not have
formula/data as arguments, whereas wilcox.test
and
kruskal.test
do. So the function two_sample_htest
is essentially
a wrapper to standardize the arguments of various hypothesis test functions.
As two_sample_htest
is only intended to be applied to unpaired two sample data,
the two arguments value
and group
are sufficient to describe the data.
Note that e.g. for class numeric the p-value is calculated by ks.test
and the effects
size 95% CI by cohen.d
. As these are two different functions the results may be
contradicting: the p-value of ks.test
can be smaller than 0.05
and the CI of cohen.d
contains 0 at the same time.
A named list with length > 0, where all elements of the list are atomic and have the same length.
Most hypothesis-test-functions in R like t.test
or chisq.test
return an object of class 'htest'
. 'htest'
-objects are a suitable output for function
two_sample_htest
. Function check_tests
checks if the output is suitable for
further processing.
two_sample_htest(character)
: Casts value
to factor and then calls method two_sample_htest
again.
two_sample_htest(factor)
: Calls chisq.test
on value
.
Effect size is the odds ratio calculated by fisher.test
(if value
has two levels),
or Cramer's V by CramerV
.
two_sample_htest(logical)
: Casts value
to factor and then calls two_sample_htest
again.
two_sample_htest(numeric)
: Calls ks.test
on value
.
Effect size is Cohen's d calculated by cohen.d
.
two_sample_htest(ordered)
: Calls wilcox.test
on value
.
Effect size is Cliff's delta calculated by cliff.delta
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.