# Quck example to run using subset of MenSS dataset
MenSS.subset <- MenSS[50:100, ]
# Run the model using the selection function assuming a MAR mechanism
# Use only 100 iterations to run a quick check
model.selection <- selection(data = MenSS.subset, model.eff = e ~ 1,model.cost = c ~ 1,
model.me = me ~ 1, model.mc = mc ~ 1, dist_e = "norm", dist_c = "norm",
type = "MAR", n.chains = 2, n.iter = 100, ppc = TRUE)
# Print the results of the JAGS model
print(model.selection)
#
# Use dic information criterion to assess model fit
pic.dic <- pic(model.selection, criterion = "dic", module = "total")
pic.dic
#
# Extract regression coefficient estimates
coef(model.selection)
#
# \dontshow{
# Use waic information criterion to assess model fit
pic.waic <- pic(model.selection, criterion = "waic", module = "total")
pic.waic
# }
# Assess model convergence using graphical tools
# Produce histograms of the posterior samples for the mean effects
diag.hist <- diagnostic(model.selection, type = "histogram", param = "mu.e")
#
# Compare observed effect data with imputations from the model
# using plots (posteiror means and credible intervals)
p1 <- plot(model.selection, class = "scatter", outcome = "effects")
#
# Summarise the CEA information from the model
summary(model.selection)
# \donttest{
# Further examples which take longer to run
model.selection <- selection(data = MenSS, model.eff = e ~ u.0,model.cost = c ~ e,
model.se = me ~ u.0, model.mc = mc ~ 1, dist_e = "norm", dist_c = "norm",
type = "MAR", n.chains = 2, n.iter = 500, ppc = FALSE)
#
# Print results for all imputed values
print(model.selection, value.mis = TRUE)
# Use looic to assess model fit
pic.looic<-pic(model.selection, criterion = "looic", module = "total")
pic.looic
# Show density plots for all parameters
diag.hist <- diagnostic(model.selection, type = "denplot", param = "all")
# Plots of imputations for all data
p1 <- plot(model.selection, class = "scatter", outcome = "all")
# Summarise the CEA results
summary(model.selection)
# }
#
#
Run the code above in your browser using DataLab