Inference for Means
means.Rmd
One Sample t-test
one_t_inference(wt ~ 1, data = mtcars2)
response | n | mean | SE | df | conf.low | conf.high |
---|---|---|---|---|---|---|
wt | 32 | 3.22 | 0.17 | 31 | 2.86 | 3.57 |
One Sample t-test (two.sided), with 95% confidence intervals. |
Separately by another categorical variable
one_t_inference(wt ~ am, data = mtcars2)
response | variable | n | mean | SE | df | conf.low | conf.high |
---|---|---|---|---|---|---|---|
wt | am = automatic | 19 | 3.77 | 0.18 | 18 | 3.39 | 4.14 |
wt | am = manual | 13 | 2.41 | 0.17 | 12 | 2.04 | 2.78 |
One Sample t-test (two.sided), with 95% confidence intervals. |
Two Sample t-test
two_t_inference(wt ~ am, data = mtcars2)
response | variable | difference | SE | df | conf.low | conf.high | null | t.value | p.value |
---|---|---|---|---|---|---|---|---|---|
wt | am: automatic - manual | 1.36 | 0.25 | 29.2 | 0.85 | 1.86 | 0.000 | 5.49 | < 0.0001 |
Welch Two Sample t-test (two.sided), with 95% confidence intervals. |
together in one table
combine_tests(
one_t_inference(wt ~ am, data = mtcars2),
two_t_inference(wt ~ am, data = mtcars2))
response | variable | n | mean | difference | SE | df | conf.low | conf.high | null | t.value | p.value | footnote |
---|---|---|---|---|---|---|---|---|---|---|---|---|
wt | am = automatic | 19 | 3.77 | 0.18 | 18.0 | 3.39 | 4.14 | 1 | ||||
wt | am = manual | 13 | 2.41 | 0.17 | 12.0 | 2.04 | 2.78 | 1 | ||||
wt | am: automatic - manual | 1.36 | 0.25 | 29.2 | 0.85 | 1.86 | 0.000 | 5.49 | < 0.0001 | 2 | ||
1 One Sample t-test (two.sided), with 95% confidence intervals. | ||||||||||||
2 Welch Two Sample t-test (two.sided), with 95% confidence intervals. |
Pairwise t-tests
combine_tests(
one_t_inference(wt ~ cyl, data = mtcars2),
pairwise_t_inference(wt ~ cyl, data = mtcars2))
response | variable | n | mean | difference | SE | df | conf.low | conf.high | null | t.value | p.value | p.adjust | footnote |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
wt | cyl = 4 | 11 | 2.29 | 0.17 | 10.0 | 1.90 | 2.67 | 1 | |||||
wt | cyl = 6 | 7 | 3.12 | 0.13 | 6.00 | 2.79 | 3.45 | 1 | |||||
wt | cyl = 8 | 14 | 4.00 | 0.20 | 13.0 | 3.56 | 4.44 | 1 | |||||
wt | cyl: 4 - 6 | −0.83 | 0.22 | 16.0 | −1.41 | −0.25 | 0.000 | -3.81 | 0.0015 | 0.0046 | 2,3 | ||
wt | cyl: 4 - 8 | −1.71 | 0.27 | 23.0 | −2.40 | −1.03 | 0.000 | -6.44 | < 0.0001 | < 0.0001 | 2,3 | ||
wt | cyl: 6 - 8 | −0.88 | 0.24 | 19.0 | −1.52 | −0.24 | 0.000 | -3.62 | 0.0018 | 0.0055 | 2,3 | ||
1 One Sample t-test (two.sided), with 95% confidence intervals. | |||||||||||||
2 Welch Two Sample t-test (two.sided), with 95% confidence intervals, adjusted for 3 comparisons using the Bonferroni method. | |||||||||||||
3 p-values adjusted for 3 multiple comparisons using the Bonferroni method. |
Paired t-test
combine_tests(
one_t_inference(score1 + score2 ~ 1, data = passfail),
paired_t_inference(score2 - score1 ~ 1, data = passfail))
response | n | mean | difference | SE | df | conf.low | conf.high | null | t.value | p.value | footnote |
---|---|---|---|---|---|---|---|---|---|---|---|
score1 | 50 | 81.85 | 0.90 | 49 | 80.05 | 83.66 | 1 | ||||
score2 | 50 | 84.6 | 1.0 | 49 | 82.5 | 86.7 | 1 | ||||
score2 - score1 | 2.7 | 1.3 | 49 | 0.2 | 5.3 | 0.000 | 2.17 | 0.035 | 2 | ||
1 One Sample t-test (two.sided), with 95% confidence intervals. | |||||||||||
2 Paired t-test (two.sided), with 95% confidence intervals. |
Log transformations
By default, responses using log(...)
are
back-transformed. To keep the result on the log scale, use
backtransform = FALSE
.
combine_tests(
one_t_inference(log(wt) ~ am, data = mtcars2, backtransform = FALSE),
two_t_inference(log(wt) ~ am, data = mtcars2, backtransform = FALSE),
one_t_inference(log(wt) ~ am, data = mtcars2),
two_t_inference(log(wt) ~ am, data = mtcars2))
response | variable | n | mean | difference | ratio | SE | df | conf.low | conf.high | null | t.value | p.value | footnote |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
log(wt) | am = automatic | 19 | 1.308 | 0.045 | 18.0 | 1.215 | 1.402 | 1 | |||||
log(wt) | am = manual | 13 | 0.849 | 0.072 | 12.0 | 0.691 | 1.007 | 1 | |||||
log(wt) | am: automatic - manual | 0.459 | 0.085 | 20.8 | 0.282 | 0.636 | 0.000 | 5.40 | < 0.0001 | 2 | |||
wt | am = automatic | 19 | 3.70 | 0.16 | 18.0 | 3.37 | 4.06 | 1,3 | |||||
wt | am = manual | 13 | 2.34 | 0.17 | 12.0 | 2.00 | 2.74 | 1,3 | |||||
wt | am: automatic / manual | 1.58 | 0.13 | 20.8 | 1.33 | 1.89 | 1.00 | 5.40 | < 0.0001 | 2,4 | |||
1 One Sample t-test (two.sided), with 95% confidence intervals. | |||||||||||||
2 Welch Two Sample t-test (two.sided), with 95% confidence intervals. | |||||||||||||
3 Results are backtransformed from the log scale (that is, the geometric mean is reported), and the standard error is estimated using the delta method. | |||||||||||||
4 Results are backtransformed from the log scale (that is, the ratio is reported), and the standard error is estimated using the delta method. |
combine_tests(
one_t_inference(log(score1) + log(score2) ~ 1, data = passfail),
paired_t_inference(log(score2) - log(score1) ~ 1, data = passfail))
response | n | mean | ratio | SE | df | conf.low | conf.high | null | t.value | p.value | footnote |
---|---|---|---|---|---|---|---|---|---|---|---|
score1 | 50 | 81.61 | 0.90 | 49 | 79.82 | 83.44 | 1,2 | ||||
score2 | 50 | 84.3 | 1.0 | 49 | 82.2 | 86.4 | 1,2 | ||||
score2 / score1 | 1.033 | 0.016 | 49 | 1.001 | 1.065 | 1.00 | 2.09 | 0.042 | 3,4 | ||
1 One Sample t-test (two.sided), with 95% confidence intervals. | |||||||||||
2 Results are backtransformed from the log scale (that is, the geometric mean is reported), and the standard error is estimated using the delta method. | |||||||||||
3 Paired t-test (two.sided), with 95% confidence intervals. | |||||||||||
4 Results are backtransformed from the log scale (that is, the ratio is reported), and the standard error is estimated using the delta method. |