Perform sample size determination or calculate probabilities of compelling and misleading evidence for a Bayesian comparison of two proportions.
BFpower.props(
threshold,
true_rate,
a0,
b0,
a1,
b1,
a2,
b2,
prior_design_1 = "same",
a1d,
b1d,
dp1,
prior_design_2 = "same",
a2d,
b2d,
dp2,
n1 = NULL,
n2 = NULL,
type_rate = "positive",
plot_power = FALSE,
plot_rel = FALSE
)An object of class BFpower_2p (a list) containing:
typeCharacter, always "Two-proportions".
analysis_h0List of analysis prior parameters under the null, containing a and b.
analysis_h1_theta_1List of analysis prior parameters for group 1 under the alternative, containing a and b.
analysis_h1_theta_2List of analysis prior parameters for group 2 under the alternative, containing a and b.
design_h1_theta_1List of design prior parameters for group 1 under the alternative, containing prior, a, b, and p.
design_h1_theta_2List of design prior parameters for group 2 under the alternative, containing prior, a, b, and p.
resultsData frame of probabilities of compelling and misleading evidence.
gridGrid used for computation.
thresholdThreshold of compelling evidence.
mode_bfCharacter string specifying the mode (sample size determination or power calculation).
plot_powerLogical; whether the power curve is plotted.
plot_relLogical; whether the relationship between the Bayes factor and observed proportion differences is plotted.
Numeric scalar. Threshold of compelling evidence.
Numeric scalar. Targeted true positive rate (if positive = "positive") or true negative rate (if positive = "negative").
Numeric scalar. Alpha parameter of the Beta prior under the null hypothesis.
Numeric scalar. Beta parameter of the Beta prior under the null hypothesis.
Numeric scalar. Alpha parameter of the Beta analysis prior for group 1 under the alternative hypothesis.
Numeric scalar. Beta parameter of the Beta analysis prior for group 1 under the alternative hypothesis.
Numeric scalar. Alpha parameter of the Beta analysis prior for group 2 under the alternative hypothesis.
Numeric scalar. Beta parameter of the Beta analysis prior for group 2 under the alternative hypothesis.
Character. The design prior of group 1: "beta", "Point", or "same" (if "same", the design prior is identical to the analysis prior).
Numeric scalar. Alpha parameter of the design prior for group 1 (used if model1 = "beta").
Numeric scalar. Beta parameter of the design prior for group 1 (used if model1 = "beta").
Numeric scalar. True proportion for group 1 in the design prior (used if model1 = "Point").
Character. The design prior of group 2: "beta", "Point", or "same" (if "same", the design prior is identical to the analysis prior).
Numeric scalar. Alpha parameter of the design prior for group 2 (used if model2 = "beta").
Numeric scalar. Beta parameter of the design prior for group 2 (used if model2 = "beta").
Numeric scalar. True proportion for group 2 in the design prior (used if model2 = "Point").
Numeric integer. Sample size for group 1.
Numeric integer. Sample size for group 2.
Character. Choose "positive" to control true/false positive rates or "negative" to control true/false negative rates.
Logical; if TRUE, plot the power curve.
Logical; if TRUE, plot the grid for the values of BF across all possible combination of x1 and x2.
1. Sample size determination mode (when n1 = NULL and n2 = NULL):
If no sample sizes are provided for the two groups, the function calculates the minimum sample sizes needed to achieve the desired configuration. The user must provide:
type_rate - either "positive" to control true/false positive rates or "negative" to control true/false negative rates.
true_rate - the targeted true positive or true negative rate (between 0.6 and 0.999).
threshold - the Bayes factor threshold for compelling evidence (must be > 1).
The function iteratively finds the smallest sample sizes for which the probability of obtaining compelling evidence meets or exceeds true_rate.
2. Fixed-sample analysis mode (when n1 and n2 are supplied):
If positive numeric sample sizes n1 and n2 are provided, the function computes the probabilities of obtaining compelling or misleading evidence for these fixed sample sizes. In this mode, type_rate and true_rate are ignored; only the Bayes factor threshold threshold is used.
Model specification:
The user must specify the analysis priors under the null and alternative hypotheses using Beta parameters:
a0, b0 - Beta parameters for the null hypothesis prior.
a1, b1 - Beta parameters for the analysis prior of group 1 under the alternative hypothesis.
a2, b2 - Beta parameters for the analysis prior of group 2 under the alternative hypothesis.
Design priors for the alternative hypothesis can optionally be specified:
prior_design_1, a1d, b1d, dp1 - design prior for group 1 ("same" uses the analysis prior, "beta" requires Beta parameters, "Point" uses a fixed proportion).
prior_design_2, a2d, b2d, dp2 - design prior for group 2.
Plotting:
If plot_power = TRUE, a power curve is plotted showing the probability of compelling evidence as a function of sample sizes. If plot_rel = TRUE, a grid of Bayes factors across possible outcomes is plotted.
BFpower.props(
threshold = 3,
true_rate = 0.8,
a0 = 1,
b0 = 1,
a1 = 156,
b1 = 339,
a2 = 151,
b2 = 339,
plot_power = TRUE,
plot_rel = TRUE)
Run the code above in your browser using DataLab