# NOT RUN {
if (interactive()) {
# load simulated data and fitted model (see ?sim_data and ?jags_logit)
data("jags_logit")
# using mcmcRocPrc
fit_sum <- mcmcRocPrc(jags_logit,
yname = "Y",
xnames = c("X1", "X2"),
curves = TRUE,
fullsims = FALSE)
fit_sum
plot(fit_sum)
# Equivalently, we can calculate the matrix of predicted probabilities
# ourselves; using the example from ?jags_logit:
library(R2jags)
data("sim_data")
yvec <- sim_data$Y
xmat <- sim_data[, c("X1", "X2")]
# add intercept to the X data
xmat <- as.matrix(cbind(Intercept = 1L, xmat))
beta <- as.matrix(as.mcmc(jags_logit))[, c("b[1]", "b[2]", "b[3]")]
pred_mat <- plogis(xmat %*% t(beta))
# the matrix of predictions has rows matching the number of rows in the data;
# the column are the predictions for each of the 2,000 posterior samples
nrow(sim_data)
dim(pred_mat)
# now we can call mcmcRocPrc; the default method works with the matrix
# of predictions and vector of outcomes as input
mcmcRocPrc(object = pred_mat, curves = TRUE, fullsims = FALSE, yvec = yvec)
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab