Easily compute planned contrast analyses (pairwise comparisons similar to t-tests but more powerful when more than 2 groups), and format in publication-ready format. Supports only three groups for the moment. In this particular case, the confidence intervals are bootstraped on chosen effect size (default to Cohen's d).
Arguments
- model
The model to be formatted.
- group
The group for the comparison.
- data
The data frame.
- effect.type
What effect size type to use. One of "cohens.d" (default), "akp.robust.d", "unstandardized", "hedges.g", "cohens.d.sigma", or "r".
- bootstraps
The number of bootstraps to use for the confidence interval
- ...
Arguments passed to bootES::bootES.
Value
A dataframe, with the selected dependent variable(s), comparisons of interest, degrees of freedom, t-values, p-values, Cohen's d, and the lower and upper 95% confidence intervals of the effect size (i.e., dR).
Details
Statistical power is lower with the standard t test compared than it is with the planned contrast version for two reasons: a) the sample size is smaller with the t test, because only the cases in the two groups are selected; and b) in the planned contrast the error term is smaller than it is with the standard t test because it is based on all the cases (source).
The effect size and confidence interval are calculated via bootES::bootES.
For the easystats equivalent, see:
modelbased::estimate_contrasts()
.
Examples
# Make and format model (group need to be a factor)
model <- lm(mpg ~ as.factor(cyl) + wt * hp, mtcars)
nice_lm_contrasts(model, group = "cyl", data = mtcars, bootstraps = 500)
#> Dependent Variable Comparison df t p d CI_lower
#> 1 mpg 4 - 8 26 0.7047256 0.4872464 3.587739 2.7741065
#> 2 mpg 6 - 8 26 0.1302365 0.8973817 1.440495 0.7694249
#> 3 mpg 4 - 6 26 0.8452452 0.4056854 2.147244 1.3007783
#> CI_upper
#> 1 4.717740
#> 2 1.954054
#> 3 3.054546
model2 <- lm(qsec ~ as.factor(cyl), data = mtcars)
my.models <- list(model, model2)
nice_lm_contrasts(my.models, group = "cyl", data = mtcars, bootstraps = 500)
#> Dependent Variable Comparison df t p d CI_lower
#> 1 mpg 4 - 8 26 0.7047256 0.4872463657 3.5877388 2.7069062
#> 2 mpg 6 - 8 26 0.1302365 0.8973817161 1.4404949 0.7946580
#> 3 mpg 4 - 6 26 0.8452452 0.4056854062 2.1472439 1.3871209
#> 4 qsec 4 - 8 29 3.9396785 0.0004711519 1.5873417 0.7367389
#> 5 qsec 6 - 8 29 1.7470521 0.0912125385 0.8087280 -0.1059372
#> 6 qsec 4 - 6 29 1.6103903 0.1181454384 0.7786137 -0.3497233
#> CI_upper
#> 1 4.476387
#> 2 1.934945
#> 3 3.011751
#> 4 2.162538
#> 5 1.845130
#> 6 1.963458