calcProb {imt} | R Documentation |
Calculate Probability of Posterior Draws Falling Within a Range
Description
This function estimates the probability that a vector of posterior draws,
represented by the parameter eta
, falls within a specified range.
It provides flexibility to use either prior distributions or posterior draws,
and to specify one-sided or two-sided probability calculations.
Usage
calcProb(x, a = NULL, b = NULL, prior = FALSE, group_name = "group average")
Arguments
x |
A numeric vector containing either posterior draws (default)
or prior samples of the treatment effect parameter ( |
a |
(Optional) The lower bound of the range (as a proportion, not percentage). |
b |
(Optional) The upper bound of the range (as a proportion, not percentage). |
prior |
A logical value indicating whether to use prior samples ( |
group_name |
A string describing the group for which the probability is being calculated (default: "group average"). |
Details
This function checks the following cases:
If both
a
andb
areNULL
, it returns an empty string.If
b
is less than or equal toa
, it throws an error.
The calculated probability and range are presented in a human-readable string
using the glue
package for formatting.
Value
A formatted string stating the calculated probability and the specified range. The probability is the proportion of samples (either prior or posterior) that fall within the defined range.