t_test {miceafter} | R Documentation |
Calculates the one, two and paired sample t-test
Description
t_test
Calculates the one, two and paired sample t-test.
Usage
t_test(y, x, formula, data, paired = FALSE, var_equal = TRUE)
Arguments
y |
numeric response variable. |
x |
categorical variable with 2 groups. |
formula |
A formula object to specify the model as normally used by glm. |
data |
An objects of class |
paired |
a logical indicating whether you want a paired t-test (TRUE) or not (FALSE, default). |
var_equal |
a logical, if TRUE equal variances are assumed, if FALSE (default) equal variances are not assumed and Welch correction is applied for the number of degrees of freedom. See detail. |
Details
For all t-tests the dataset must be in long format
(i.e. group data under each other). For the paired t-test x and y
must have the same length. When variances between groups are
unequal, the Welch df correction formula is used and eventually
averaged across multiply imputed datasets in the pool_t_test
function.
Value
An object containing the following objects are extracted:
-
mdiff
the mean difference. -
se
the standard error. -
dfcom
the complete data degrees of freedom.
Author(s)
Martijn Heymans, 2022
See Also
Examples
imp_dat <- df2milist(lbpmilr, impvar="Impnr")
ra <- with(imp_dat, expr=t_test(Pain ~ Gender))