| simple_effects | R Documentation |
Calculate the effect of a focal variable at different levels of a moderator. For categorical focal variables, it calculates pairwise differences (contrasts). For continuous focal variables, it calculates the slope (simple slopes).
simple_effects(
fit,
effect,
prob = 0.95,
sd_multiplier = 1,
sd_slice = NULL,
...
)
fit |
Model fit object (e.g., 'map_fit', 'mcmc_fit'). |
effect |
Character string of the interaction (e.g., "A:B"). The first variable is the focal variable. |
prob |
Probability for the credible/confidence interval (default is 0.95). |
sd_multiplier |
Multiplier for SD for continuous moderators (default is 1). |
sd_slice |
Logical or NULL. If TRUE, continuous moderators are evaluated at mean - SD, mean, and mean + SD. If FALSE, all observed moderator values are used. If NULL (default), sd slicing is used automatically when the moderator has 6 or more unique values. |
... |
Additional arguments. |
A 'ce_simple' object (data frame) containing the estimated effects and their credible intervals. For 'Classic_Fit' objects, test columns ('df', 't value', and 'Pr') are also returned when standard errors are available.
data(debate, package = "BayesRTMB")
fit <- rtmb_lm(sat ~ talk * perf, data = debate)
map_fit <- fit$optimize()
# Effect of talk at different levels of performance
se <- simple_effects(map_fit, effect = "talk:perf")
print(se)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.