Calculates two sample hypothesis tests and effect size depending on the class of its input.
two_sample_htest(value, group, ...)# S3 method for character
two_sample_htest(value, group, ...)
# S3 method for factor
two_sample_htest(value, group, two_sample_htest.factor = NULL, ...)
# S3 method for logical
two_sample_htest(value, group, ...)
# S3 method for numeric
two_sample_htest(value, group, two_sample_htest.numeric = NULL, ...)
# S3 method for ordered
two_sample_htest(value, group, two_sample_htest.ordered = NULL, ...)
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.
An atomic vector. These values will be tested.
A factor with two levels and same length as value
.
Defines the two groups of value
, that are compared by a two sample hypothesis tests.
Passed to methods.
Analog to argument two_sample_htest.numeric
Either NULL
or a function. Default is NULL
.
If a function, then it will replace atable:::two_sample_htest.numeric
.
The function must mimic two_sample_htest.numeric
: arguments are
value
, group
and the ellipsis ... .
Result is a named list with length
> 0 with unique names.
Analog to argument two_sample_htest.numeric
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
.
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.