Perform sample size determination or calculate the probabilities of obtaining compelling or misleading evidence for a two-sample Bayesian t-test. Supports point-null and interval-null hypotheses, and allows specifying analysis and design priors.
BFpower.ttest.TwoSample(
alternative,
ROPE = NULL,
threshold,
true_rate,
false_rate,
prior_analysis,
location,
scale,
dff,
prior_design = NULL,
location_d,
scale_d,
dff_d,
N1 = NULL,
N2 = NULL,
r = NULL,
type_rate = "positive",
plot_power = FALSE,
plot_rel = FALSE
)An object of class BFpower_t containing:
Character string describing the test type.
alternative hypothesis ("two.sided", "greater", or "less").
Interval bounds under the null used, if any.
List with the analysis prior parameters: prior_analysis, location, scale, and optionally dff.
List with the design prior parameters: prior_design, location, scale, and optionally dff (or NULL if not provided).
Data frame with probabilities of compelling/misleading evidence.
Threshold of compelling evidence.
Logical flag for plotting power.
Logical flag for plotting the relationship between BF and t-value.
Character. The direction of the alternative hypothesis: two-sided ("two.sided"),
right-sided ("greater"), or left-sided ("less").
Optional numeric. Bounds for an interval null:
For hypothesis = "two.sided", must be a numeric vector of length 2 with distinct finite values.
For "greater", must be a single numeric scalar > 0.
For "less", must be a single numeric scalar < 0.
Numeric scalar. Threshold for compelling evidence (must be > 1).
Numeric scalar. Target true positive or negative rate .
Numeric scalar. Target false positive or negative rate .
Character. Analysis prior under the alternative hypothesis:
"Normal", "Moment", or "t-distribution".
Numeric scalar. Location parameter for the analysis prior.
Numeric scalar > 0. Scale parameter for the analysis prior.
Numeric scalar. Degrees of freedom for the analysis prior (required if prior_analysis = "t-distribution"; ignored otherwise).
Optional character. Design prior under the alternative:
"Normal", "Moment", "t-distribution", or "Point".
Numeric scalar. Location parameter for the design prior.
Numeric scalar > 0. Scale parameter for the design prior.
Numeric scalar. Degrees of freedom for the design prior (required if prior_design = "t-distribution"; ignored otherwise).
Numeric integer. Sample size for group 1 (used if r = NULL).
Numeric integer. Sample size for group 2 (used if r = NULL).
Optional numeric scalar. Ratio of sample size N2 / N1 (used if N1 and N2 are NULL).
Character, either "positive" or "negative"; determines whether to control
true/false positive or true/false negative rates .
Logical. If TRUE, a plot of the power or probability of compelling evidence is generated.
Logical. Whether the relationship between the BF and data is plotted..
1. Sample size determination mode (when N1 = NULL and N2 = NULL, but r is provided):
If no sample sizes are provided, the function calculates the minimum required sample sizes for both groups. In this mode, the user must supply:
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).
false_rate - the acceptable false positive or false negative rate (between 0.001 and 0.1).
threshold - the Bayes factor threshold for compelling evidence (must be > 1).
r - the allocation ratio of group 2 to group 1 sample sizes (N2/N1).
The function iteratively finds the smallest sample sizes N1 and N2 = r * N1 for which the probability
of obtaining compelling evidence meets or exceeds true_rate, while the probability of misleading evidence
does not exceed false_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 those fixed sample sizes. In this mode,
the arguments type_rate, true_rate, and false_rate are ignored; only the Bayes factor threshold threshold is used.
Analysis Priors:
The analysis prior specifies the prior distribution of the effect under the alternative hypothesis. The user must provide:
prior_analysis - the type of prior: "Normal", "Moment" (normal-moment prior), or "t-distribution".
location - the mean or location of the prior.
scale - the standard deviation or scale (must be positive).
dff - degrees of freedom (required if prior_analysis = "t-distribution").
Design Priors (optional):
A design prior can be supplied to reflect uncertainty about the effect size during study planning. If provided, the following must be supplied:
prior_design - the type of design prior: "Normal", "Moment", "t-distribution", or "Point".
location_d - the location of the design prior.
scale_d - the scale parameter (positive for all models except "Point").
dff_d - degrees of freedom for "t-distribution" design priors.
interval null Hypothesis:
The argument ROPE specifies the bounds of an interval null hypothesis.
If ROPE is provided, the function evaluates the Bayes factor for an interval
null hypothesis. For a point-null hypothesis, ROPE should be left as NULL.
Plotting:
If plot_power = TRUE, the function plots the probability of compelling
evidence as a function of the sample sizes. If plot_rel = TRUE, the relationship between BF and data is plotted.
BFpower.ttest.TwoSample(
alternative = "two.sided",
ROPE = c(-0.36, 0.36),
threshold = 3,
true_rate = 0.8,
false_rate = 0.05,
prior_analysis = "Normal",
location = -0.23,
scale = 0.2,
dff = 1,
type_rate = "negative",
r = 1)
Run the code above in your browser using DataLab