Perform sample size determination or calculate the probability of obtaining compelling or misleading evidence for a one-sample Bayesian t-test. Can handle both point-null and interval-null hypothesis, and allows specifying analysis and design priors.
BFpower.ttest.OneSample(
alternative,
ROPE = NULL,
prior_analysis,
location,
scale,
dff,
prior_design = NULL,
location_d,
scale_d,
dff_d,
N = NULL,
type_rate = "positive",
true_rate,
false_rate,
threshold,
plot_power = FALSE,
plot_rel = FALSE
)An object of class BFpower_t (a list) containing:
Character, always "One-sample t-test".
Character, the direction of the alternative hypothesis.
Optional numeric vector for interval null bounds.
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 of probabilities: compelling/misleading evidence, or NaN if calculation fails.
Numeric, threshold of compelling evidence.
Logical, whether to plot the power curve.
Logical, whether the relationship between the BF and t-value is plotted.
Character. The direction of the alternative hypothesis : two-sided ("two.sided" ), right-sided ("greater"), or left-sided ("less").
Optional numeric vector. Bounds for an interval null hypothesis.
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.
Character. The analysis prior under the alternative hypothesis:
"Normal", "Moment" (normal-moment prior), or "t-distribution".
Numeric scaler. Location parameter for the analysis prior under the alternative hypothesis.
Numeric scaler. Scale parameter for the analysis prior under the alternative hypothesis (must be > 0).
Numeric scaler. Degrees of freedom for the analysis prior under the alternative hypothesis (required if prior_analysis = "t-distribution").
Optional character. The design prior under the alternative hypothesis:
"Normal", "Moment", "t-distribution", or "Point".
Numeric scaler. Location parameter for the design prior under the alternative hypothesis.
Numeric scaler. Scale parameter for the design prior under the alternative hypothesis.
Numeric scaler. Degrees of freedom for the design prior under the alternative hypothesis (required if prior_design = "t-distribution").
Numeric integer. Sample size.
Character. Either "positive" (controls true/false positive rates) or "negative" (controls true/false negative rates).
Numeric scaler. Target true positive or negative rate (between 0.6 and 0.999).
Numeric scaler. Target false positive or false negative rate (between 0.001 and 0.1).
Numeric scaler. Threshold of compelling evidence (must be > 1).
Logical. If TRUE, plots power curve.
Logical. If TRUE, plots the relationship between the BF and data.
1. Sample size determination mode (when N = NULL):
If no sample size is provided, the function determines the minimum sample size. In this mode, the user must supply the following arguments:
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).
The function iteratively finds the smallest sample size 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 N is supplied):
If a positive numeric sample size N is provided, the function computes
the probabilities of obtaining compelling or misleading evidence for that
fixed sample size. 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 sample size. If plot_rel = TRUE, the relationship betwwen the BF and data is plotted.
BFpower.ttest.OneSample(
alternative = "two.sided",
threshold = 3,
true_rate = 0.8,
false_rate = 0.05,
prior_analysis = "t-distribution",
location = 0,
scale = 0.707,
dff = 1
)
Run the code above in your browser using DataLab