brmViolin | R Documentation |
Function to visualize hypotheses tested on brms models similar to those made using growthSS outputs.
brmViolin(fit, ss, hypothesis)
fit |
A brmsfit object or a dataframe of draws. If you need to combine multiple models then use combineDraws to merge their draws into a single dataframe for testing. |
ss |
A |
hypothesis |
A hypothesis expressed as a character string in the style of that used by
|
Returns a ggplot showing a brms model's posterior distributions as violins and filled by posterior probability of some hypothesis.
set.seed(123)
simdf <- growthSim(
"logistic",
n = 20, t = 25,
params = list("A" = c(200, 180, 190, 160), "B" = c(13, 11, 10, 10), "C" = c(3, 3, 3.25, 3.5))
)
ss <- growthSS(
model = "logistic", form = y ~ time | id / group, sigma = "int",
list("A" = 130, "B" = 10, "C" = 3),
df = simdf, type = "brms"
)
fit <- fitGrowth(ss, backend = "cmdstanr", iter = 500, chains = 1, cores = 1)
brmViolin(fit, ss, ".../A_groupd > 1.05") # all groups used
brmViolin(fit, ss, "abs(1 - ((...)/(C_groupd - B_groupd))) > 0.05") # rather arbitrary
brmViolin(fit, ss, "abs(1 - ((...)/(C_groupa - B_groupd))) > 0.05") # totally arbitrary
brmViolin(fit, ss, "A_groupa/A_groupd > 1.05") # only these two groups
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.