two_sample_htest {atable} | R Documentation |
Two sample hypothesis tests and effect size
Description
Calculates two sample hypothesis tests and effect size depending on the class of its input.
Usage
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, ...)
Arguments
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 |
Details
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.
Value
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.
Methods (by class)
-
two_sample_htest(character)
: Castsvalue
to factor and then calls methodtwo_sample_htest
again. -
two_sample_htest(factor)
: Callschisq.test
onvalue
. Effect size is the odds ratio calculated byfisher.test
(ifvalue
has two levels), or Cramer's V byCramerV
. -
two_sample_htest(logical)
: Castsvalue
to factor and then callstwo_sample_htest
again. -
two_sample_htest(numeric)
: Callsks.test
onvalue
. Effect size is Cohen's d calculated bycohen.d
. -
two_sample_htest(ordered)
: Callswilcox.test
onvalue
. Effect size is Cliff's delta calculated bycliff.delta
.