two_samp_cont_test: Continuous Variable Compared to Binary Variable Test (VISC)

View source: R/statistical_tests_and_estimates.R

two_samp_cont_testR Documentation

Continuous Variable Compared to Binary Variable Test (VISC)

Description

Either Wilcox or T-Test Performed, for unpaired or paired data

Usage

two_samp_cont_test(
  x,
  y,
  method = c("wilcox", "t.test"),
  paired = FALSE,
  verbose = FALSE,
  ...
)

Arguments

x

numeric vector (can include NA values).

y

vector with only 2 levels (can include NA values unless paired = TRUE).

method

what test to run (wilcox or t-test).

paired

a logical indicating whether you want a paired test.

verbose

a logical variable indicating if warnings and messages should be displayed.

...

parameters to pass to wilcox_test or t.test functions. For example the testing direction (alternative) in either call or the var.equal in the t.test function.

Details

Runs wilcox_test() in the coin package, with "exact" distribution and mid-ranks ties method.

For one sided tests if y is a factor variable the level order is respected, otherwise the levels will set to alphabetical order (i.e. if alternative = less then testing a < b ).

If paired = TRUE assumes the first observations of the first group matches the first observation of the second group, and so on. Also if paired = TRUE then y must have the same number of samples for each level.

Value

p-value for comparing x at the different levels of y.

Examples


set.seed(5432322)
outcome <- c(rnorm(10,0,3), rnorm(10,3,3))
grp <- c(rep('a', 10), rep('b', 10))
two_samp_cont_test(x = outcome, y = grp, method = 'wilcox', paired = FALSE)
two_samp_cont_test(x = outcome, y = grp, method = 'wilcox', paired = TRUE)
two_samp_cont_test(x = outcome, y = grp, method = 't', paired = FALSE)
two_samp_cont_test(x = outcome, y = grp, method = 't', paired = TRUE)


FredHutch/VISCfunctions documentation built on Oct. 14, 2024, 11:33 p.m.