# NOT RUN {
# Use the colorad data set
data(colorad)
# Add a second mediator to the data set
colorad$blur_squared <- (colorad$blur)^2
# Prepare mediators to be analyzed in the Multivariate Normal model
mediators <- cbind(colorad$blur, colorad$blur_squared)
colnames(mediators) <- c("blur", "blur_squared")
colorad$mediators <- mediators
# }
# NOT RUN {
# Build and analyze the model for the outcome variable
model <- BANOVA.model('Binomial')
banova_binom_model <- BANOVA.build(model)
res_1 <- BANOVA.run(y ~ typic, ~ color + blur + blur_squared, fit = banova_binom_model,
data = colorad, id = 'id', num_trials = as.integer(16),
iter = 2000, thin = 1, chains = 2)
# Build and analyze the model for the mediators
model <- BANOVA.model('multiNormal')
banova_multi_norm_model <- BANOVA.build(model)
res_2 <- BANOVA.run(mediators ~ typic, ~ color, fit = banova_multi_norm_model,
data = colorad, id = 'id', iter = 2000, thin = 1, chains = 2)
# Calculate (moderated) effects of "typic" mediated by "blur" and "blur_squared"
results <- BANOVA.multi.mediation(res_1, res_2, xvar='typic', mediators=c("blur", "blur_squared"))
# }
Run the code above in your browser using DataLab