View source: R/faintr_functions.R
filter_cell_draws | R Documentation |
This function takes as input a brms
model fit for a
factorial design and a group specification (one subset of the design cells)
and returns the posterior draws for that group. If no group is specified,
the returned draws are grand means.
filter_cell_draws(fit, group = NULL, colname = "draws")
fit |
An object of class |
group |
An expression specifying the group to filter the draws for. |
colname |
A string specifying the column name of the returned data frame; defaults to 'draws'. |
A draws_df
object containing posterior draws
for the specified group and additional metadata.
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)
# get the draws for female speakers in informal contexts
filter_cell_draws(fit, gender == "F" & context == "inf")
# get the draws for male speakers or informal contexts
filter_cell_draws(fit, gender == "M" | context == "inf")
# averaged over gender, get the draws for all but polite contexts
filter_cell_draws(fit, context != "pol")
# get the posterior draws averaged over all factors (grand mean)
filter_cell_draws(fit)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.