Bayesian Negative Binomial Model Factory
Bayesian Negative Binomial Model Factory
versionPackage version used to fit the model
mcmChecksMCMC diagnostics
credible_intervalCredible interval for the treatment effect
tau_drawsPosterior draws for the treatment effect
new()Create a new Bayesian Negative Binomial Model object.
negativeBinomial$new(
data,
y,
x,
treatment,
tau_mean,
tau_sd,
run_estimation = 1,
seed = 1982,
...
)dataData frame to be used
yName of the outcome variable in the data frame
xVector of names of all covariates in the data frame
treatmentName of the treatment indicator variable in the data frame
tau_meanPrior mean for the treatment effect estimation
tau_sdPrior standard deviation for the treatment effect estimation
run_estimationInteger flag to control whether estimation is run (1) or not (0)
seedSeed for Stan fitting
...Additional arguments for Stan
invisible
tracePlot()Plot MCMC trace for the eta and sigma parameters.
negativeBinomial$tracePlot(...)...Additional arguments for Stan
A ggplot object.
posteriorProb()Calculate posterior probability of effect exceeding a threshold
This function calculates the posterior probability of the effect being larger or smaller than a specified threshold.
negativeBinomial$posteriorProb(threshold = 0, gt = TRUE)thresholdA numeric value specifying the threshold.
gtA logical value indicating whether to calculate the probability of the effect being greater than (TRUE) or less than (FALSE) the threshold.
This function uses the private$..tau_draws internal variable to obtain draws from the posterior distribution of the effect size. Based on the specified arguments, the function calculates the proportion of draws exceeding/falling below the threshold and returns a formatted statement describing the estimated probability.
Calculate point estimate of the effect
This R6 method calculates the point estimate of the effect size based on the posterior draws of the tau parameter.
A character string summarizing the estimated probability.
pointEstimate()negativeBinomial$pointEstimate(median = TRUE)medianLogical value. If TRUE (default), the median of the tau draws is returned. If FALSE, the mean is returned.
This method uses the private$..tau_draws internal variable which contains MCMC draws of the tau parameter representing the effect size. Based on the specified median argument, the method calculates and returns either the median or the mean of the draws. Calculates credible interval for the effect of the intervention
This R6 method calculates and returns a formatted statement summarizing the credible interval of a specified width for the effect of the intervention.
A numeric value representing the point estimate.
credibleInterval()negativeBinomial$credibleInterval(width = 0.75, round = 0)widthNumeric value between 0 and 1 representing the desired width of the credible interval (e.g., 0.95 for a 95% credible interval).
roundInteger value indicating the number of decimal places to round the lower and upper bounds of the credible interval.
This method uses the private$..tau_draws internal variable containing MCMC draws of the tau parameter representing the effect size. It calculates the credible interval, stores it internally, and returns a formatted statement summarizing the findings.
A character string with the following information:
The probability associated with the specified width
The lower and upper bounds of the credible interval, rounded to the specified number of decimal places
vizdraws()Plots impact's prior and posterior distributions.
For more details see vizdraws::vizdraws().
negativeBinomial$vizdraws(...)...other arguments passed to vizdraws.
An interactive plot of the prior and posterior distributions.
clone()The objects of this class are cloneable with this method.
negativeBinomial$clone(deep = FALSE)deepWhether to make a deep clone.