if (FALSE) {
# fit a JointAI object:
mod <- lm_imp(y ~ C1 + C2 + M1, data = wideDF, n.iter = 100)
# Example 1: basic densityplot
densplot(mod)
densplot(mod, exclude_chains = 2)
# Example 2: use vlines to mark zero
densplot(mod, col = c("darkred", "darkblue", "darkgreen"),
vlines = list(list(v = rep(0, nrow(summary(mod)$res$y$regcoef)),
col = grey(0.8))))
# Example 3: use vlines to visualize posterior mean and 2.5%/97.5% quantiles
res <- rbind(summary(mod)$res$y$regcoef[, c('Mean', '2.5%', '97.5%')],
summary(mod)$res$y$sigma[, c('Mean', '2.5%', '97.5%'),
drop = FALSE]
)
densplot(mod, vlines = list(list(v = res[, "Mean"], lty = 1, lwd = 2),
list(v = res[, "2.5%"], lty = 2),
list(v = res[, "97.5%"], lty = 2)))
# Example 4: ggplot version
densplot(mod, use_ggplot = TRUE)
# Example 5: change how the ggplot version looks
library(ggplot2)
densplot(mod, use_ggplot = TRUE) +
xlab("value") +
theme(legend.position = 'bottom') +
scale_color_brewer(palette = 'Dark2', name = 'chain')
}
Run the code above in your browser using DataLab