This function visualizes the predicted probabilities from a Bayesian logistic regression model
fitted using rstan. It computes the posterior predicted probabilities over a grid defined by
two continuous predictor variables, and creates a plot showing how these probabilities vary
across their values. Color is used to represent the estimated probability, and the original
data points are overlaid for reference.
logit_prob_plot(
data,
ypredict = NULL,
model = NULL,
parameters = NULL,
intercept = NULL,
outcome,
predictors.plot
)A ggplot2 object showing the mean predicted probabilities across the grid of the
two specified predictors, with the observed outcome overlaid as colored points.
A data frame containing the original data used to fit the model.
Optional. A matrix of posterior predictive simulations of the outcome variable
(e.g., generated externally). If NULL, predictions will be simulated internally assuming a single-level logistic regression.
The matrix should have dimensions S x N, where S is the number of posterior draws (rows) and N is the number of observations (columns).
A fitted Stan model object of class 'stanfit' (from rstan). Required if ypredict is not provided.
A named vector where the names are the predictor variable names (as in the data), and the values are the corresponding parameter names in the Stan model. Required if ypredict is not provided.
Optional. A character string indicating the name of the intercept parameter in the Stan model (if present).
A character string with the name of the binary outcome variable in the data.
A character vector of length 2 specifying which two predictor variables to use for the x and y axes of the plot.