View source: R/faintr_functions.R
compare_groups | R Documentation |
Convenience function for comparing two subsets of factorial design cells.
It takes a brms
model fit, two group specifications
(two subsets of design cells), and the probability mass within the highest
density interval of the difference in groups. It outputs the posterior mean
of the 'higher' minus the 'lower' group, a credible interval of the mean difference,
as well as the posterior probability and odds that the mean estimate of the 'higher'
group is higher than that of the 'lower' group. A comparison of one group against
the grand mean can be obtained by leaving out one of the two group specifications
in the function call.
compare_groups(
fit,
higher = NULL,
lower = NULL,
hdi = 0.95,
include_bf = FALSE
)
fit |
An object of class |
higher |
An expression specifying the 'higher' group to filter the draws for. |
lower |
An expression specifying the 'lower' group to filter the draws for. |
hdi |
A single value (0, 1) defining the probability mass within the highest density interval; defaults to 0.95. |
include_bf |
A Boolean flag indicating whether Bayes Factors should be approximated (required additional sampling); defaults to FALSE. |
An object of class 'faintCompare' containing summary statistics of the comparison.
The faintr package currently does not support multivariate models and
models that use families categorical
, dirichlet
, multinomial
,
and logistic_normal
. Furthermore, models must not include special effect
terms mo()
, mi()
, me()
, and cs()
for fixed effects.
Also note that faintr currently does not support models where the intercept
is a population-level parameter (class b
), as is the case when using the
0 + Intercept
syntax in the brm
function call.
Bürkner, P.-C. (2017). brms: An R Package for Bayesian Multilevel Models Using Stan. Journal of Statistical Software, 80(1), 1-28. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v080.i01")}
## Not run:
# fit a linear mixed effects model on data from a 2 x 2 factorial design
## regress voice pitch against gender and context
fit <- brms::brm(formula = pitch ~ gender * context + (1 | subject + sentence),
data = politeness)
# compare female speakers in informal contexts against male speakers in polite contexts
compare_groups(
fit = fit,
higher = gender == "F" & context == "inf",
lower = gender == "M" & context == "pol"
)
# compare informal contexts against polite contexts, averaged over gender
compare_groups(
fit = fit,
higher = context == "inf",
lower = context == "pol"
)
# compare female speakers against the grand mean
compare_groups(
fit = fit,
higher = gender == "F",
hdi = 0.8
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.