Bayesian Negative Binomial Model Factory
Bayesian Negative Binomial Model Factory
version
Package version used to fit the model
mcmChecks
MCMC diagnostics
credible_interval
Credible interval for the treatment effect
tau_draws
Posterior 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,
...
)
data
Data frame to be used
y
Name of the outcome variable in the data frame
x
Vector of names of all covariates in the data frame
treatment
Name of the treatment indicator variable in the data frame
tau_mean
Prior mean for the treatment effect estimation
tau_sd
Prior standard deviation for the treatment effect estimation
run_estimation
Integer flag to control whether estimation is run (1) or not (0)
seed
Seed 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)
threshold
A numeric value specifying the threshold.
gt
A 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)
median
Logical 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)
width
Numeric value between 0 and 1 representing the desired width of the credible interval (e.g., 0.95 for a 95% credible interval).
round
Integer 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)
deep
Whether to make a deep clone.