plotPosteriorProbs {epts} | R Documentation |
Plot Posterior Probabilities Across Thresholds for CRT, MST, or SRT Designs
Description
This function generates a Bayesian posterior probability plot across multiple thresholds for each intervention group in a clustered randomized trial (CRT), multisite trial (MST), or simple randomized trial (SRT).
Usage
plotPosteriorProbs(
method = c("crt", "mst", "srt"),
data,
outcome = "posttest",
interventions = "interventions",
Random = "schools",
Nsim = 10000,
continuous_covariates = NULL,
categorical_covariates = NULL,
VerticalLine = NULL,
VerticalLineColor = "#0000FF",
HorizontalLine = NULL,
HorizontalLineColor = "#FF0000",
threshold_range = c(0, 1),
maintitle = "Posterior Probabilities Across Thresholds",
xlabel = "Threshold",
ylabel = "Posterior Probability",
intcolors = NULL,
intlabels = NULL,
xbreaks = NULL,
ybreaks = seq(0, 1, by = 0.1)
)
Arguments
method |
The trial design type: "crt", "mst", or "srt". |
data |
A data frame containing the variables including outcome, predictors, the clustering variable, and the intervention. |
outcome |
The name of the outcome (post-test) variable. |
interventions |
A string specifying the intervention variable. |
Random |
The name of the clustering variable (e.g., schools or sites) for CRT and MST designs. |
Nsim |
Number of MCMC iterations to be performed. A minimum of 10,000 is recommended to ensure convergence. |
continuous_covariates |
A character vector specifying the names of continuous covariates. |
categorical_covariates |
A character vector specifying the names of categorical covariates (converted to factors). |
VerticalLine |
Optional vertical reference line added at a threshold value. It should be specified as a numeric value. |
VerticalLineColor |
The color of the vertical reference line. It should be specified as a character string (default = "#0000FF"). |
HorizontalLine |
Optional posterior probability cutoff for adding a horizontal reference line. It should be specified as a numeric value. |
HorizontalLineColor |
The color of the horizontal reference line. It should be specified as a character string (default = "#FF0000"). |
threshold_range |
The range of thresholds to evaluate. It should be specified as a numeric vector of length 2 (default = c(0, 1.0)). |
maintitle |
The main title of the plot. |
xlabel |
The label for the x-axis. |
ylabel |
The label for the y-axis. |
intcolors |
Optional intervention colors specified manually. It should be provided as a named character vector. |
intlabels |
Optional intervention labels to use instead of default names. It should be specified as a character vector. |
xbreaks |
Tick marks for the x-axis. Must be a numeric vector with values within the specified threshold_range (default = 0.1). |
ybreaks |
Tick marks for the y-axis. It should be specified as a numeric vector (default = seq(0, 1, by = 0.1)). |
Details
The function uses crtBayes()
, mstBayes()
, or srtBayes()
from eefAnalytics package depending on the method
.
Value
A ggplot
object that displays posterior probabilities across thresholds for each intervention.
See Also
crtBayes
, mstBayes
, srtBayes
functions from the eefAnalytics package
Examples
###Plot Posterior Probabilities of cluster randomized trial###
data(crt4armSimData)
plotPosteriorProbs(method = "crt",data = crt4armSimData, outcome = "posttest",
interventions = "interventions", Random = "schools", Nsim = 10000,
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"),
threshold_range = c(0, 0.1), VerticalLine = 0.05, HorizontalLine = 0.8,
VerticalLineColor= "purple", HorizontalLineColor= "black",
intlabels = c("Intervention A", "Intervention B", "Intervention C"),
intcolors = c("Intervention A" = "blue", "Intervention B" = "red",
"Intervention C" = "green"), maintitle= "Posterior probability plot",
xlabel= "Threshold", ylabel= "Posterior probability",
xbreaks= 0.1, ybreaks= seq(0, 1, by = 0.1))
###Plot Posterior Probabilities of multisite trial###
data(mst4armSimData)
plotPosteriorProbs(method = "ms",data = mst4armSimData, outcome = "posttest",
interventions = "interventions", Random = "schools", Nsim = 10000,
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"),
threshold_range = c(0, 0.1), VerticalLine = 0.05, HorizontalLine = 0.8,
VerticalLineColor= "purple", HorizontalLineColor= "black",
intlabels = c("Intervention A", "Intervention B", "Intervention C"),
intcolors = c("Intervention A" = "blue", "Intervention B" = "red",
"Intervention C" = "green"), maintitle= "Posterior probability plot",
xlabel= "Threshold", ylabel= "Posterior probability",
xbreaks= 0.1, ybreaks= seq(0, 1, by = 0.1))
###Futility analysis of simple randomized trial###
data(srt4armSimData)
plotPosteriorProbs(method = "srt",data = srt4armSimData, outcome = "posttest",
interventions = "interventions", Nsim = 10000, threshold_range = c(0, 0.2),
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"),
VerticalLine = 0.05, HorizontalLine = 0.8, VerticalLineColor= "purple",
HorizontalLineColor= "black", intlabels = c("Intervention A", "Intervention B",
"Intervention C"), intcolors = c("Intervention A" = "#1F77B4",
"Intervention B" = "#D62728", "Intervention C" = "#2CA02C"),
maintitle= "Posterior probability plot", xlabel= "Threshold",
ylabel= "Posterior probability", xbreaks= 0.1, ybreaks= seq(0, 1, by = 0.1))