View source: R/conditional_effects.R
| conditional_effects.bmmfit | R Documentation |
Compute conditional effects for parameters of a bmmfit object.
This method provides a more intuitive interface than directly calling
brms::conditional_effects() on bmmfit objects, by:
Accepting model parameter names directly (e.g., "kappa", "thetat")
Automatically determining whether parameters are distributional or non-linear
Optionally applying inverse link transformations to show parameters on their natural scale
## S3 method for class 'bmmfit'
conditional_effects(x, par = NULL, scale = c("native", "sampling"), ...)
x |
A bmmfit object (created by |
par |
Character string. Name of the model parameter to compute effects for.
This should be one of the parameter names from the original model specification
(see |
scale |
Character. Scale on which to show the parameter:
|
... |
Additional arguments passed to
|
bmm models use two types of parameters internally:
Non-linear parameters (nlpar): Core model parameters like kappa, c, a, thetat
Distributional parameters (dpar): Derived parameters used in brms mixture distributions
Users should not need to know this distinction - conditional_effects.bmmfit()
automatically routes to the correct parameter type.
By default (scale = "native"), parameters are shown on their natural scale by
applying inverse link transformations:
log link → exp transformation
logit link → inverse logit (probability scale)
tan_half link → 2*atan transformation (radians)
identity link → no transformation
Use scale = "sampling" to see parameters on the scale used during MCMC sampling.
A brms_conditional_effects object (from brms), which can be:
Plotted directly using plot()
Converted to a data frame for custom plotting
Combined with other conditional effects plots
brms::conditional_effects() for the underlying brms function
## Not run:
# Fit a mixture model with set size effect on kappa
fit <- bmm(
formula = bmf(kappa ~ 0 + setsize, thetat ~ 1),
data = zhang_luck_2008,
model = mixture3p(
resp_error = "response_error",
nt_features = paste0("col_lure", 1:5),
set_size = "setsize"
)
)
# Get conditional effects for kappa on natural scale (exp of log)
ce_kappa <- conditional_effects(fit, par = "kappa")
plot(ce_kappa)
# Get conditional effects for kappa on log scale (sampling scale)
ce_kappa_log <- conditional_effects(fit, par = "kappa", scale = "sampling")
plot(ce_kappa_log)
# Get effects for thetat (memory probability)
ce_thetat <- conditional_effects(fit, par = "thetat")
plot(ce_thetat)
# Specify which effects to plot
ce_specific <- conditional_effects(fit, par = "kappa", effects = "setsize")
# Combine with other brms options
ce_detailed <- conditional_effects(
fit,
par = "kappa",
effects = "setsize",
spaghetti = TRUE,
ndraws = 100
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.