Skip to contents

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 the Robust Cohen's d.

Usage

nice_contrasts(response, group, covariates = NULL, data, bootstraps = 2000)

Arguments

response

The dependent variable.

group

The group for the comparison.

covariates

The desired covariates in the model.

data

The data frame.

bootstraps

The number of bootstraps to use for the confidence interval

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).

Examples


# Basic example
nice_contrasts(
  data = mtcars,
  response = "mpg",
  group = "cyl",
  bootstraps = 200
)
#>   Dependent Variable Comparison df        t            p       dR  CI_lower
#> 1                mpg      4 - 8 29 8.904534 8.568209e-10 3.031774 2.0731878
#> 2                mpg      6 - 8 29 3.111825 4.152209e-03 1.245144 0.6934405
#> 3                mpg      4 - 6 29 4.441099 1.194696e-04 1.786630 0.9840528
#>   CI_upper
#> 1 5.229091
#> 2 2.728547
#> 3 3.415750

if (FALSE) {
nice_contrasts(
  data = mtcars,
  response = "disp",
  group = "gear"
)

# Multiple dependent variables
nice_contrasts(
  data = mtcars,
  response = c("mpg", "disp", "hp"),
  group = "cyl"
)

# Adding covariates
nice_contrasts(
  data = mtcars,
  response = "mpg",
  group = "cyl",
  covariates = c("disp", "hp")
)
}