## Not run:
# # simulate mediational data
# a <- .5
# b <- .6
# t_prime <- .3
#
# X <- rnorm(50,0,1)
# M <- a*X + rnorm(50,0,1)
# Y <- t_prime*X + b*M + rnorm(50,0,1)
#
# # run jzs_med
#
# result <- jzs_med(independent=X,dependent=Y,mediator=M)
# result
#
# #-------------------------------------
#
# # load Firefighter data
# data(Firefighters)
#
# X <- Firefighters$x
# M <- Firefighters$m
# Y <- Firefighters$y
#
# # run jzs_med
# result <- jzs_med(independent=X,dependent=Y,mediator=M)
#
# # plot the result in a mediation diagram
# plot(result$main_result)
#
# # inspect posterior distribution of the coefficients
# plot(result$alpha_samples)
# plot(result$beta_samples)
# plot(result$tau_prime_samples)
#
# # print a traceplot of the chains
# plot(result$jagssamplesA)
# plot(result$jagssamplesTB)
# # where the first chain (theta[1]) is for tau' and the second chain (theta[2]) for beta
#
# # calculate and plot a 95% credible interval for the
# # posterior mean of the indirect effect
# result$CI_ab
# plot(result$ab_samples)
#
#
# ## End(Not run)
Run the code above in your browser using DataLab