Easy API Reference for BioequivalencePower
The key functions of the package are power, samplesize, power_analysis, adjusted_α, adjusted_α_with_samplesize, confint, and pvalue. Here are the doc strings for the easy-API methods of these functions.
Power
BioequivalencePower.power — Methodpower(::Type{BS}, ::Type{D} = EDDefaultDesign,
::Type{BW} = EmptyBayesianWrapper, ::Type{PP} = EmptyPriorParameters;
kwargs...
) where {BS <: BioequivalencePowerStudy, D <: ExperimentalDesign, BW <: BayesianWrapper, PP <:PriorParameters}This is the easy-API power method. Its interface is designed to be as easy and simple to use as possible. However, since it encompasses all of the power functionality of the package, the docstring is long.
There are two positional arguments, first the study type BS and then the design type D. Type names are used for these arguments. For example:
power(RatioTOST, ED2x2x3ReplicateCrossover, ...)Another two optional positional arguments are the prior type BW and its parameters PP. Use these only if a you wish to compute expected power in the Bayesian context. For example:
power(RatioTOST, ED2x2x3ReplicateCrossover, CVSEPrior, DegreesOfFreedomPriorParameters, ...)After these positional arguments, the remaining arguments are indicated in the method signature via kwargs (key word arguments). With these keywords we always need to set the number of subjects, n, and the variability parameter, CV (can also be SE in certain cases). The order of the keywords does not matter. Many other keywords are also possible (see below). Here is a minimal working example:
power(RatioTOST, ED2x2x3ReplicateCrossover, n = 20, CV = 0.32)The essence of the easy-API is that the it uses the complete-API under the hood, yet presents a simple interface. For example here, the number of subjects, n = 20 is automatically set in an HypothesisTestMetaParams object, and the coefficient of variation CV = 0.32 is set in a RatioTOST{ED2x2x3ReplicateCrossover} object. These objects are hidden from the user. The easy-API sees which arguments are supplied and constructs the objects based on these arguments before invoking the complete-API internally.
Here is a full list of arguments:
1st argument: bioequivalence power study type. One of:
- Standard (average) bioequivalence:
RatioTOSTorDifferenceTOST - Reference scaling and/or expanding limits:
ReferenceScaledRatioTOSTorExpandingLimitsRatioTOST - Tests for NTID (Narrow Therapeutic Index Drug):
NarrowTherapeuticIndexDrugRatioTOST - Tests in the context of fiducial inference:
FiducialRatioTOST - Tests with two end points:
TwoDifferenceTOSTsorTwoRatioTOSTs - Dose proportionality:
DoseProportionalityStudy - Non-inferiority tests:
NonInferiorityRatioOSTorNonInferiorityDifferenceOST
- Standard (average) bioequivalence:
2nd argument: design.
- For the study types
RatioTOST,DifferenceTOST,TwoDifferenceTOSTs,TwoRatioTOSTs,NonInferiorityRatioOSTorNonInferiorityDifferenceOST, use one of:ED2Parallel,ED2x2Crossover,ED3x3Crossover,ED3x6x3Crossover,ED4x4Crossover,ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover,ED2x4x4ReplicateCrossover,ED2x3x3PartialReplicate,ED2x4x2Balaam,ED2x2x2RepeatedCrossover, orEDPaired. - For the study types
ExpandingLimitsRatioTOSTorReferenceScaledRatioTOSTuse one of:ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover, orED2x3x3PartialReplicate. - For the study type
NarrowTherapeuticIndexDrugRatioTOSTuse one ofED2x2x3ReplicateCrossoverorED2x2x4ReplicateCrossover. - For the study type
FiducialRatioTOSTuse one ofED2ParallelorED2x2Crossover. - For the study type
DoseProportionalityStudyuse one ofEDGeneralCrossover,EDGeneralParallel, orEDGeneral.
- For the study types
3rd argument (optional) prior type:
- This argument can only be used with study types
RatioTOST,DifferenceTOST,NonInferiorityRatioOST, orNonInferiorityDifferenceOSTand should be one ofCVSEPrior,θ0Prior, orBothCVSEandθ0Prior, to indicate a prior on the variability parameter (CV or SE), on θ₀, or on both, respectively. - If this argument is set, you must set the 4th argument.
- This argument can only be used with study types
4th argument (optional) prior distribution type:
- This argument is relevant if and only if the 3rd argument (prior type) is set.
- If the prior type is
CVSEPrioruseDegreesOfFreedomPriorParametersorCategoricalPriorParameters. - If the prior type is
θ0PrioruseStandardErrorPriorParametersorCategoricalPriorParameters. - If the prior type is
BothCVSEandθ0PrioruseDegreesOfFreedomAndStandardErrorPriorParametersorTwoWayCategoricalPriorParameters.
The keyword arguments following the initial arguments are always set in the form KEY = VALUE, where for example KEY can be n and value can be 20 for indicating the number of subjects. Here is a full list, starting with mandatory arguments and following with optional arguments.
Mandatory Arguments
n: Can be an integer denoting the total number of subjects or an array of the number of subjects per sequence group, e.g.n = [12, 8]. In the typical case where the total number of subjects is given, the subjects are distributed as uniformly as possible among sequences of the design using thedistribute_groupsfunction.- Variability arguments: The typical variability argument is
CV, but in certain casesSEis used instead. In other cases secondary variability arguments are required or optional. Here is a complete list of variability arguments. Note that variability arguments are always positive and in certain cases they are given as a vector.RatioTOST,DoseProportionalityStudy, andNonInferiorityRatioOST: SpecifyCVas a single value.ReferenceScaledRatioTOST,ExpandingLimitsRatioTOST, andNarrowTherapeuticIndexDrugRatioTOST: SpecifyCVas a single value, or if wishing to consider heteroscedasticity, specify as a vector of length 2, with the first entry for the test formulation and the second entry for the reference formulation.DifferenceTOST, andNonInferiorityDifferenceOST: SpecifySEas a single value.FiducialRatioTOST: Specify bothSEandSEb, each as a single value.TwoRatioTOSTs: SpecifyCVas a vector of length 2 matching the two end points of the study.TwoDifferenceTOSTs: SpecifySEas a vector of length 2 matching the two end points of the study.DoseProportionalityStudy: SpecifyCVas a single value. Optionally, specifyCVbas a single value (default value ofCVbif not specified is twiceCV.)
- For
DoseProportionalityStudyyou must also specify the vector of doses viadoses. This is a vector of integer values, e.g.doses = [1, 2, 8]. - In case of a prior distribution (3rd and 4th arguments used) there are other mandatory arguments. See specific description below.
Argument for "test/reference" ratio or difference
A key input to the power computation is the ratio or difference between the test and reference formulation. That is, power is computed based on such a postulated point. It is typically denoted θ₀ with variable name peθ₀, except for the context of dose proportionality studies where it is denoted β₀ with variable name peβ₀. All of the study types set default for this argument, and you can naturally override that default.
Ratio formulation defaults:
peθ₀forRatioTOST,FiducialRatioTOST,NonInferiorityRatioOST: Default is at0.95.peθ₀forReferenceScaledRatioTOST,ExpandingLimitsRatioTOST: Default is at0.9.peθ₀forNarrowTherapeuticIndexDrugRatioTOST: Default is at0.975ifhighly_variable = false(default), and at0.95otherwise (the HVNTID case).peθ₀forTwoRatioTOSTs: Default is at the vector[0.95, 0.95].
Difference formulation defaults:
peθ₀forDifferenceTOST: Default is at0.05.peθ₀forNonInferiorityDifferenceOST: Default is at-0.05.peθ₀forTwoDifferenceTOSTs: Default is at the vector[0.05, 0.05].
Dose proportionality default:
peβ₀forDoseProportionalityStudyis set at1 + log(0.95)/log(maximum(doses) / minimum(doses)).
Argument for limits
Most of the study types have set limits values θ₁ and θ₂ with θ₁ < θ₂. The non-inferiority types has the single limit θmargin, and the two simultaneous end points studies have θ₁ and θ₂, each as a vector of length 2. Default values are set for all of these, and you can set your own values to override the defaults. Note that in most cases θ₂ is defined in terms of θ₁. Hence you may set θ₁ and as a result, θ₂ will be adjusted accordingly, or you may set only θ₂, or set both.
- For
RatioTOST,ReferenceScaledRatioTOST,ExpandingLimitsRatioTOST,NarrowTherapeuticIndexDrugRatioTOST,FiducialRatioTOST,andDoseProportionalityStudywe have thatθ₁andθ₂are each scalar values with defaultsθ₁ = 0.8andθ₂ = 1/θ₁(this is1.25). - For
DifferenceTOSTwe have thatθ₁andθ₂are each scalar values with defaultsθ₁ = -0.2andθ₂ = -θ₁(this is0.2). - For
TwoRatioTOSTsandTwoDifferenceTOSTswe have thatθ₁andθ₂are each vectors of length 2 with default individual entries corresponding toRatioTOSTandDifferenceTOST. For example forTwoRatioTOSTswe haveθ₁ = [0.8, 0.8]andθ₂ = 1 ./ θ₁. - For
NonInferiorityRatioOSTthe default value isθmargin = 0.8. - For
NonInferiorityDifferenceOSTthe default value isθmargin = -0.2.
Optional Arguments for hypothesis test meta parameters (including assumptions)
α: By default,α = 0.05for most studies with the exception ofFiducialRatioTOST,NonInferiorityRatioOST, andNonInferiorityDifferenceOSTwhere it is set at0.025(note that this adjusted default is only applicable via the easy-API and not via the complete-API).n_g: This is the number of groups in the study (it is the number of location sites and should not to be confused with the number of sequences in a design). By defaultn_g = 1. For standard (average) bioequivalence formulated as a ratio, namelyRatioTOST, we may use other values ofn_gif carrying out subject level simulations (subject_level = true). See more details withsubject_levelbelow.robust: Set this to true for a determination of degrees of freedom using a robust formulation. Default isfalse.test_group_effect: Set this to true for the specific caseRatioTOSTwithn_gset to greater than one andsubeject_level = true. In this case a model for testing group effect is first executed. Default isfalse.
Special arguments for reference scaling and/or expanding limits
reg_symbol: This is the symbol for theRegulatoryConstantsobject set in eitherReferenceScaledRatioTOSTorExpandingLimitsRatioTOSTstudies. For the former the default is:fdaand for the latter it is:ema. You may set other regulatory constants objects if you wish.
Special arguments for narrow therapeutic drug index products
highly_variable: This boolean value with defaultfalsedetermines if the study is an NTDI or HVNTDI study. The casehighly_variable= true yields different behavior for the hypothesis test.regulatory_constant: Default is-log(0.9)/0.10(which is about1.053605), used only inhighly_variable = false.ratio_threshold: Default is2.5.
Special arguments for two simultaneous end points
ρ: When usingTwoRatioTOSTsorTwoDifferenceTOSTs, this is the assumed correlation coefficient between the two endpoints. Default is0.0and it can be set to any value such that-1 ≤ ρ ≤ 1.
Special arguments for dose proportionality study
design_matrix: Use this only withDoseProportionalityStudyandEDGeneralspecified in the 1st and 2nd arguments respectively. In this casedesign_matrixshould be set to anEDGeneraldesign object which encapsulates adesign_matrixthat can be specified.
Arguments for simulation and computation
Note that the arguments num_sims, seed, and subject_level are specific to a case where Monte Carlo power calculation is used. In study types where exact power calculation is used by default and Monte Carlo is also supported, the default is overridden and the calculation is changed to Monte Carlo if one of these arguments is set. In other cases, where Monte Carlo is already the default, setting these parameters just updates the nature of the Monte Carlo.
The study types with default as exact calculation and an option for Monte Carlo are: RatioTOST, DifferenceTOST.
The study types with only numerical calculation are: DoseProportionalityStudy (note that this is an approximate calculation), NonInferiorityRatioOST, and NonInferiorityDifferenceOST.
The study types with only Monte Carlo are: ReferenceScaledRatioTOST, ExpandingLimitsRatioTOST, NarrowTherapeuticIndexDrugRatioTOST, FiducialRatioTOST, TwoRatioTOSTs, and TwoDifferenceTOSTs.
When using Monte Carlo, these are the possible arguments.
num_sims: This is the number of simulation runs to execute. The default is1e5.seed: This is the simulation seed to use for reproducibility. The default value is an arbitrary1984value, yet can be set to any integer value. Settingseed = nothing, implies no random seed is set.details: Set this to true to output additional simulation and/or computation output. Default isfalse.subject_level: This argument is by defaultfalseand this implies simulations are based on randomly generating statistics. If set totruethen it means that each simulation run randomly generates sample data and uses this random data to estimate the power. In general,subject_level = trueis slower, yet in certain cases it yields better accuracy. You may setsubject_level = trueonly for the following cases:RatioTOST, yet only with one of the designsED2x2Crossover,ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover, orED2x3x3PartialReplicate.ReferenceScaledRatioTOSTwith any of the supported designs of the study.ExpandingLimitsRatioTOSTwith any of the supported designs of the study.
Arguments for Bayesian computation
When setting the 3rd and 4th parameters for Bayesian computation, you must also supply prior parameters. See the Priors on parameters in power studies section of the docs for more details.
Return value
The return value is always an HypothesisTestMetaParams object. The achieved_power field specifies the power.
Sample size
BioequivalencePower.samplesize — Methodsamplesize(::Type{BS}, ::Type{D} = EDDefaultDesign,
::Type{BW} = EmptyBayesianWrapper, ::Type{PP} = EmptyPriorParameters;
kwargs...
) where {BS <: BioequivalencePowerStudy, D <: ExperimentalDesign, BW <: BayesianWrapper, PP <:PriorParameters}This is the easy-API samplesize method. Its interface is designed to be as easy and simple to use as possible. However, since it encompasses all of the sample size functionality of the package, the docstring is long.
There are two mandatory positional arguments, first the study type BS and then the design type D. Type names are used for these arguments. For example:
samplesize(RatioTOST, ED2x2x3ReplicateCrossover, ...)Another two optional positional arguments are the prior type BW and its parameters PP. Use these only if a you wish to compute sample size using expected power in the Bayesian context. For example:
samplesize(RatioTOST, ED2x2x3ReplicateCrossover, CVSEPrior, DegreesOfFreedomPriorParameters, ...)After these positional arguments, the remaining arguments are indicated in the method signature via kwargs (key word arguments). With these keywords we always need to set the variability parameter, CV (can also be SE in certain cases). The order of the keywords does not matter. Many other keywords are also possible (see below). Here is a minimal working example:
samplesize(RatioTOST, ED2x2x3ReplicateCrossover, CV = 0.32)The essence of the easy-API is that the it uses the complete-API under the hood, yet presents a simple interface. For example here, behind the scenes, CV = 0.32 is set in a RatioTOST{ED2x2x3ReplicateCrossover} object which is passed to a samplesize method for such objects. These details are hidden from the user. The easy-API sees which arguments are supplied and constructs the objects based on these arguments before invoking the complete-API internally.
Here is a full list of arguments:
1st argument: bioequivalence power study type. One of:
- Standard (average) bioequivalence:
RatioTOSTorDifferenceTOST - Reference scaling and/or expanding limits:
ReferenceScaledRatioTOSTorExpandingLimitsRatioTOST - Tests for NTID (Narrow Therapeutic Index Drug):
NarrowTherapeuticIndexDrugRatioTOST - Tests in the context of fiducial inference:
FiducialRatioTOST - Tests with two end points:
TwoDifferenceTOSTsorTwoRatioTOSTs - Dose proportionality:
DoseProportionalityStudy - Non-inferiority tests:
NonInferiorityRatioOSTorNonInferiorityDifferenceOST
- Standard (average) bioequivalence:
2nd argument: design.
- For the study types
RatioTOST,DifferenceTOST,TwoDifferenceTOSTs,TwoRatioTOSTs,NonInferiorityRatioOSTorNonInferiorityDifferenceOST, use one of:ED2Parallel,ED2x2Crossover,ED3x3Crossover,ED3x6x3Crossover,ED4x4Crossover,ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover,ED2x4x4ReplicateCrossover,ED2x3x3PartialReplicate,ED2x4x2Balaam,ED2x2x2RepeatedCrossover, orEDPaired. - For the study types
ExpandingLimitsRatioTOSTorReferenceScaledRatioTOSTuse one of:ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover, orED2x3x3PartialReplicate. - For the study type
NarrowTherapeuticIndexDrugRatioTOSTuse one ofED2x2x3ReplicateCrossoverorED2x2x4ReplicateCrossover. - For the study type
FiducialRatioTOSTuse one ofED2ParallelorED2x2Crossover. - For the study type
DoseProportionalityStudyuse one ofEDGeneralCrossover,EDGeneralParallel, orEDGeneral.
- For the study types
3rd argument (optional) prior type:
- This argument can only be used with study types
RatioTOST,DifferenceTOST,NonInferiorityRatioOST, orNonInferiorityDifferenceOSTand should be one ofCVSEPrior,θ0Prior, orBothCVSEandθ0Prior, to indicate a prior on the variability parameter (CV or SE), on θ₀, or on both, respectively. - If this argument is set, you must set the 4th argument.
- This argument can only be used with study types
4th argument (optional) prior distribution type:
- This argument is relevant if and only if the 3rd argument (prior type) is set.
- If the prior type is
CVSEPrioruseDegreesOfFreedomPriorParametersorCategoricalPriorParameters. - If the prior type is
θ0PrioruseStandardErrorPriorParametersorCategoricalPriorParameters. - If the prior type is
BothCVSEandθ0PrioruseDegreesOfFreedomAndStandardErrorPriorParametersorTwoWayCategoricalPriorParameters.
The keyword arguments following the initial arguments are always set in the form KEY = VALUE, where for example KEY can be CV and value can be 0.32. Here is a full list, starting with mandatory arguments and following with optional arguments.
Mandatory Arguments
- Variability arguments: The typical variability argument is
CV, but in certain casesSEis used instead. In other cases secondary variability arguments are required or optional. Here is a complete list of variability arguments. Note that variability arguments are always positive and in certain cases they are given as a vector.RatioTOST,DoseProportionalityStudy, andNonInferiorityRatioOST: SpecifyCVas a single value.ReferenceScaledRatioTOST,ExpandingLimitsRatioTOST, andNarrowTherapeuticIndexDrugRatioTOST: SpecifyCVas a single value, or if wishing to consider heteroscedasticity, specify as a vector of length 2, with the first entry for the test formulation and the second entry for the reference formulation.DifferenceTOST, andNonInferiorityDifferenceOST: SpecifySEas a single value.FiducialRatioTOST: Specify bothSEandSEb, each as a single value.TwoRatioTOSTs: SpecifyCVas a vector of length 2 matching the two end points of the study.TwoDifferenceTOSTs: SpecifySEas a vector of length 2 matching the two end points of the study.DoseProportionalityStudy: SpecifyCVas a single value. Optionally, specifyCVbas a single value (default value ofCVbif not specified is twiceCV.)
- For
DoseProportionalityStudyyou must also specify the vector of doses viadoses. This is a vector of integer values, e.g.doses = [1, 2, 8]. - In case of a prior distribution (3rd and 4th arguments used) there are other mandatory arguments. See specific description below.
Argument for "test/reference" ratio or difference
A key input to the sample size computation is the ratio or difference between the test and reference formulation. That is, sample size is computed based on such a postulated point. It is typically denoted θ₀ with variable name peθ₀, except for the context of dose proportionality studies where it is denoted β₀ with variable name peβ₀. All of the study types set default for this argument, and you can naturally override that default.
Ratio formulation defaults:
peθ₀forRatioTOST,FiducialRatioTOST,NonInferiorityRatioOST: Default is at0.95.peθ₀forReferenceScaledRatioTOST,ExpandingLimitsRatioTOST: Default is at0.9.peθ₀forNarrowTherapeuticIndexDrugRatioTOST: Default is at0.975ifhighly_variable = false(default), and at0.95otherwise (the HVNTID case).peθ₀forTwoRatioTOSTs: Default is at the vector[0.95, 0.95].
Difference formulation defaults:
peθ₀forDifferenceTOST: Default is at0.05.peθ₀forNonInferiorityDifferenceOST: Default is at-0.05.peθ₀forTwoDifferenceTOSTs: Default is at the vector[0.05, 0.05].
Dose proportionality default:
peβ₀forDoseProportionalityStudyis set at1 + log(0.95)/log(maximum(doses) / minimum(doses)).
Argument for limits
Most of the study types have set limits values θ₁ and θ₂ with θ₁ < θ₂. The non-inferiority types has the single limit θmargin, and the two simultaneous end points studies have θ₁ and θ₂, each as a vector of length 2. Default values are set for all of these, and you can set your own values to override the defaults. Note that in most cases θ₂ is defined in terms of θ₁. Hence you may set θ₁ and as a result, θ₂ will be adjusted accordingly, or you may set only θ₂, or set both.
- For
RatioTOST,ReferenceScaledRatioTOST,ExpandingLimitsRatioTOST,NarrowTherapeuticIndexDrugRatioTOST,FiducialRatioTOST,andDoseProportionalityStudywe have thatθ₁andθ₂are each scalar values with defaultsθ₁ = 0.8andθ₂ = 1/θ₁(this is1.25). - For
DifferenceTOSTwe have thatθ₁andθ₂are each scalar values with defaultsθ₁ = -0.2andθ₂ = -θ₁(this is0.2). - For
TwoRatioTOSTsandTwoDifferenceTOSTswe have thatθ₁andθ₂are each vectors of length 2 with default individual entries corresponding toRatioTOSTandDifferenceTOST. For example forTwoRatioTOSTswe haveθ₁ = [0.8, 0.8]andθ₂ = 1 ./ θ₁. - For
NonInferiorityRatioOSTthe default value isθmargin = 0.8. - For
NonInferiorityDifferenceOSTthe default value isθmargin = -0.2.
Optional Arguments for hypothesis test meta parameters (including assumptions)
target_power: This is the target power for which sample size should be determined. Default value is0.8. The function will search fornthat hastarget_power ≤ achieved_power.α: By default,α = 0.05for most studies with the exception ofFiducialRatioTOST,NonInferiorityRatioOST, andNonInferiorityDifferenceOSTwhere it is set at0.025(note that this adjusted default is only applicable via the easy-API and not via the complete-API).n_g: This is the number of groups in the study (it is the number of location sites and should not to be confused with the number of sequences in a design). By defaultn_g = 1. For standard (average) bioequivalence formulated as a ratio, namelyRatioTOST, we may use other values ofn_gif carrying out subject level simulations (subject_level = true). See more details withsubject_levelbelow.robust: Set this to true for a determination of degrees of freedom using a robust formulation. Default isfalse.test_group_effect: Set this to true for the specific caseRatioTOSTwithn_gset to greater than one andsubeject_level = true. In this case a model for testing group effect is first executed. Default isfalse.
Special arguments for reference scaling and/or expanding limits
reg_symbol: This is the symbol for theRegulatoryConstantsobject set in eitherReferenceScaledRatioTOSTorExpandingLimitsRatioTOSTstudies. For the former the default is:fdaand for the latter it is:ema. You may set other regulatory constants objects if you wish.
Special arguments for narrow therapeutic drug index products
highly_variable: This boolean value with defaultfalsedetermines if the study is an NTDI or HVNTDI study. The casehighly_variable= true yields different behavior for the hypothesis test.regulatory_constant: Default is-log(0.9)/0.10(which is about1.053605), used only inhighly_variable = false.ratio_threshold: Default is2.5.
Special arguments for two simultaneous end points
ρ: When usingTwoRatioTOSTsorTwoDifferenceTOSTs, this is the assumed correlation coefficient between the two endpoints. Default is0.0and it can be set to any value such that-1 ≤ ρ ≤ 1.
Special arguments for dose proportionality study
design_matrix: Use this only withDoseProportionalityStudyandEDGeneralspecified in the 1st and 2nd arguments respectively. In this casedesign_matrixshould be set to anEDGeneraldesign object which encapsulates adesign_matrixthat can be specified.
Arguments for simulation and computation
Note that the arguments num_sims, seed, and subject_level are specific to a case where Monte Carlo sample size calculation is used (this means the power calculation used by samplesize uses Monte Carlo). In study types where exact power calculation is used by default and Monte Carlo is also supported, the default is overridden and the calculation is changed to Monte Carlo if one of these arguments is set. In other cases, where Monte Carlo is already the default, setting these parameters just updates the nature of the Monte Carlo.
The study types with default as exact calculation and an option for Monte Carlo are: RatioTOST, DifferenceTOST.
The study types with only numerical calculation are: DoseProportionalityStudy (note that this is an approximate calculation), NonInferiorityRatioOST, and NonInferiorityDifferenceOST.
The study types with only Monte Carlo are: ReferenceScaledRatioTOST, ExpandingLimitsRatioTOST, NarrowTherapeuticIndexDrugRatioTOST, FiducialRatioTOST, TwoRatioTOSTs, and TwoDifferenceTOSTs.
When using Monte Carlo, these are the possible arguments.
num_sims: This is the number of simulation runs to execute for each individual power calculation. The default is1e5.seed: This is the simulation seed to use for reproducibility. The default value is an arbitrary1984value, yet can be set to any integer value. Settingseed = nothing, implies no random seed is set. Warning: sample size search without a fixed seed is not recommended..details: Set this to true to output additional simulation and/or computation output. Default isfalse.subject_level: This argument is by defaultfalseand this implies simulations are based on randomly generating statistics. If set totruethen it means that each simulation run randomly generates sample data and uses this random data to estimate the power. In general,subject_level = trueis slower, yet in certain cases it yields better accuracy. You may setsubject_level = trueonly for the following cases:RatioTOST, yet only with one of the designsED2x2Crossover,ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover, orED2x3x3PartialReplicate.ReferenceScaledRatioTOSTwith any of the supported designs of the study.ExpandingLimitsRatioTOSTwith any of the supported designs of the study.
Arguments for Bayesian computation
When setting the 3rd and 4th parameters for Bayesian computation, you must also supply prior parameters. See the Priors on parameters in power studies section of the docs for more details.
Counting iterations
An additional argument is count_iter with default value false. If set to true the return value is a tuple where the second argument is the number of power computations computed until finding the sample size.
Return value
The return value is an HypothesisTestMetaParams object. In this object, n is the determined sample size and the achieved_power field specifies the power obtained with such a sample size. If count_iter = true, the return value is a tuple with the first argument being an HypothesisTestMetaParams object, and the second argument being the number of iterations.
Power Analysis
BioequivalencePower.power_analysis — Methodpower_analysis(::Type{BS}, ::Type{D} = EDDefaultDesign;
kwargs...
) where {BS <: BioequivalencePowerStudy, D <: ExperimentalDesign}This is the easy-API power_analysis method. Its interface is designed to be as easy and simple to use as possible. However, since it encompasses all of the power_analysis functionality of the package, the docstring is long.
There are two mandatory positional arguments, first the study type BS and then the design type D. Type names are used for these arguments. For example:
power_analysis(RatioTOST, ED2x2x3ReplicateCrossover, ...)After these positional arguments, the remaining arguments are indicated in the method signature via kwargs (key word arguments). With these keywords we always need to set the variability parameter, CV. The order of the keywords does not matter. Many other keywords are also possible (see below). Here is a minimal working example:
power_analysis(RatioTOST, ED2x2x3ReplicateCrossover, CV = 0.32)The essence of the easy-API is that the it uses the complete-API under the hood, yet presents a simple interface. For example here the coefficient of variation CV = 0.32 is set in a RatioTOST{ED2x2x3ReplicateCrossover} object. This object is hidden from the user. The easy-API sees which arguments are supplied and constructs objects based on these arguments before invoking the complete-API internally.
Here is a full list of arguments:
1st argument: bioequivalence power study type (note that not only some of the
BioequivalencePowerStudysub-types are supported). One of:- Standard (average) bioequivalence:
RatioTOST - Reference scaling and/or expanding limits:
ReferenceScaledRatioTOSTorExpandingLimitsRatioTOST - Tests for NTID (Narrow Therapeutic Index Drug):
NarrowTherapeuticIndexDrugRatioTOST
- Standard (average) bioequivalence:
2nd argument: design.
- For the study type
RatioTOSTuse one of:ED2Parallel,ED2x2Crossover,ED3x3Crossover,ED3x6x3Crossover,ED4x4Crossover,ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover,ED2x4x4ReplicateCrossover,ED2x3x3PartialReplicate,ED2x4x2Balaam,ED2x2x2RepeatedCrossover, orEDPaired. - For the study types
ExpandingLimitsRatioTOSTorReferenceScaledRatioTOSTuse one of:ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover, orED2x3x3PartialReplicate. - For the study type
NarrowTherapeuticIndexDrugRatioTOSTuse one ofED2x2x3ReplicateCrossoverorED2x2x4ReplicateCrossover.
- For the study type
The keyword arguments following the initial two arguments are always set in the form KEY = VALUE, where for example KEY can be CV and value can be 0.32. Here is a full list, starting with mandatory arguments and following with optional arguments.
Mandatory Arguments
- Variability argument: This is
CV. It should always be a single positive value. Note that vector CV for heteroscedasticity is not supported as part ofpower_analysis.
Argument for "test/reference" ratio
A key input to the power analysis is the ratio between the test and reference formulation. That is, power is computed based on such a postulated point, and that point is varied. It is denoted θ₀ with variable name peθ₀. All of the study types set default for this argument, and you can naturally override that default.
peθ₀forRatioTOST: Default is at0.95.peθ₀forReferenceScaledRatioTOST,ExpandingLimitsRatioTOST: Default is at0.9.peθ₀forNarrowTherapeuticIndexDrugRatioTOST: Default is at0.975ifhighly_variable = false(default), and at0.95otherwise (the HVNTID case).
Argument for limits
These are set limits values θ₁ and θ₂ with θ₁ < θ₂. Default values are set for all of these with defaults θ₁ = 0.8 and θ₂ = 1/θ₁ (this is 1.25). You can set your own values to override the defaults. Note that in most cases θ₂ is defined in terms of θ₁. Hence you may set θ₁ and as a result, θ₂ will be adjusted accordingly, or you may set only θ₂, or set both.
Optional Arguments for hypothesis test meta parameters (including assumptions)
target_power: This is the target power for which sample size should be determined. Default value is0.8. When initially determining the sample size,power_analysiswill search fornthat hastarget_power ≤ achieved_power.α: By default,α = 0.05.robust: Set this to true for a determination of degrees of freedom using a robust formulation. Default isfalse.
Special arguments for reference scaling and/or expanding limits
reg_symbol: This is the symbol for theRegulatoryConstantsobject set in eitherReferenceScaledRatioTOSTorExpandingLimitsRatioTOSTstudies. For the former the default is:fdaand for the latter it is:ema. You may set other regulatory constants objects if you wish.
Special arguments for narrow therapeutic drug index products
highly_variable: This boolean value with defaultfalsedetermines if the study is an NTDI or HVNTDI study. The casehighly_variable= true yields different behavior for the hypothesis test.regulatory_constant: Default is-log(0.9)/0.10(which is about1.053605), used only inhighly_variable = false.ratio_threshold: Default is2.5.
Arguments for simulation and computation
Note that the arguments num_sims, seed, and subject_level are specific to a case where Monte Carlo power calculation is used. In study types where exact power calculation is used by default and Monte Carlo is also supported, the default is overridden and the calculation is changed to Monte Carlo if one of these arguments is set. In other cases, where Monte Carlo is already the default, setting these parameters just updates the nature of the Monte Carlo.
In the context of power_analysis, the study type with default as exact calculation and an option for Monte Carlo is: RatioTOST.
Similarly, the study types with only Monte Carlo are: ReferenceScaledRatioTOST, ExpandingLimitsRatioTOST, and NarrowTherapeuticIndexDrugRatioTOST.
When using Monte Carlo, these are the possible arguments.
num_sims: This is the number of simulation runs to execute for each individual power calculation. The default is1e5.seed: This is the simulation seed to use for reproducibility. The default value is an arbitrary1984value, yet can be set to any integer value. Settingseed = nothing, implies no random seed is set. Warning: sample size search or power analysis without a fixed seed is not recommended..details: Set this to true to output additional simulation and/or computation output. Default isfalse.subject_level: This argument is by defaultfalseand this implies simulations are based on randomly generating statistics. If set totruethen it means that each simulation run randomly generates sample data and uses this random data to estimate the power. In general,subject_level = trueis slower, yet in certain cases it yields better accuracy. You may setsubject_level = trueonly for the following cases:ReferenceScaledRatioTOSTwith any of the supported designs of the study.ExpandingLimitsRatioTOSTwith any of the supported designs of the study.
Return value
The return value is a tuple that represents the power analysis information.
Adjusted α
BioequivalencePower.adjusted_α — Methodadjusted_α(::Type{BS}, ::Type{D} = EDDefaultDesign;
kwargs...
) where {BS <: BioequivalencePowerStudy, D <: ExperimentalDesign}This is the easy-API adjusted_α method. Its interface is designed to be as easy and simple to use as possible. However, since it encompasses all of the adjusted α functionality of the package, the docstring is long.
There are two mandatory positional arguments, first the study type BS and then the design type D. Type names are used for these arguments. For example:
adjusted_α(ReferenceScaledRatioTOST, ED2x2x4ReplicateCrossover, ...)After these positional arguments, the remaining arguments are indicated in the method signature via kwargs (key word arguments). With these keywords we always need to set the variability parameter, CV. The order of the keywords does not matter. Many other keywords are also possible (see below). Here is a minimal working example:
adjusted_α(ReferenceScaledRatioTOST, ED2x2x4ReplicateCrossover, CV = 0.27)The essence of the easy-API is that the it uses the complete-API under the hood, yet presents a simple interface. For example here, the coefficient of variation CV = 0.27 is set in a ReferenceScaledRatioTOST{ED2x2x4ReplicateCrossover} object. This object is hidden from the user. The easy-API sees which arguments are supplied and constructs objects based on these arguments before invoking the complete-API internally.
Here is a full list of arguments:
1st argument: bioequivalence power study type (note that not only Reference scaling and/or expanding limits
BioequivalencePowerStudysub-types are supported). Hence choose one of:ReferenceScaledRatioTOSTorExpandingLimitsRatioTOST.2nd argument: design. Use one of:
ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover, orED2x3x3PartialReplicate.
The keyword arguments following the initial arguments are always set in the form KEY = VALUE, where for example KEY can be CV and value can be 0.27. Here is a full list, starting with mandatory argument and following with optional arguments.
Mandatory Arguments
- Variability argument: This is
CVor if wishing to consider heteroscedasticity, specify as a vector of length 2, with the first entry for the test formulation and the second entry for the reference formulation.
Argument for "test/reference" ratio
A key input is the ratio between the test and reference formulation. That is, power is computed based on such a postulated point. It is denoted θ₀ with variable name peθ₀. Default is at 0.9 and you can naturally override that default.
Argument for limits
These are set limits values θ₁ and θ₂ with θ₁ < θ₂. Default values are set for all of these with defaults θ₁ = 0.8 and θ₂ = 1/θ₁ (this is 1.25). You can set your own values to override the defaults. Note that in most cases θ₂ is defined in terms of θ₁. Hence you may set θ₁ and as a result, θ₂ will be adjusted accordingly, or you may set only θ₂, or set both.
Type I error and α
α: By default,α = 0.05. This is the desired type I error.pre_specified_α: Default isnothing. You may set this value and then the function will compute sample size using this pre specified value.
Further optional Arguments for hypothesis test meta parameters (including assumptions)
n: Can be an integer denoting the total number of subjects or an array of the number of subjects per sequence group, e.g.n = [12, 8]. In the typical case where the total number of subjects is given, the subjects are distributed as uniformly as possible among sequences of the design using thedistribute_groupsfunction. If this argument is not given,adjusted_αcallssamplesizeto obtain this value.
Special arguments for reference scaling and/or expanding limits
reg_symbol: This is the symbol for theRegulatoryConstantsobject set in eitherReferenceScaledRatioTOSTorExpandingLimitsRatioTOSTstudies. For the former the default is:fdaand for the latter it is:ema. You may set other regulatory constants objects if you wish.
Arguments for simulation
Note that the arguments num_sims, seed, and subject_level are for Monte Carlo power calculation
When using Monte Carlo, these are the possible arguments.
num_sims: This is the number of simulation runs to execute. The default is1e5.seed: This is the simulation seed to use for reproducibility. The default value is an arbitrary1984value, yet can be set to any integer value. Settingseed = nothing, implies no random seed is set. Warning: sample size search or power analysis without a fixed seed is not recommended..details: Set this to true to output additional simulation and/or computation output. Default isfalse.subject_level: This argument is by defaultfalseand this implies simulations are based on randomly generating statistics. If set totruethen it means that each simulation run randomly generates sample data and uses this random data to estimate the power. In general,subject_level = trueis slower, yet in certain cases it yields better accuracy.
Return value
In case no adjustment is made, the return value is a named tuple similar to this:
(before_adjustment = (α = 0.05, type_I_error = 0.03331, achieved_power = 0.82244, n = [13, 13]),
after_adjustment = :no_adjustment_made)In case an adjustment is made, the return value is a named tuple similar to this:
(before_adjustment = (α = 0.05, type_I_error = 0.08269, achieved_power = 0.80225, n = [15, 15]),
after_adjustment = (α = 0.028163596987724294, type_I_error = 0.05, achieved_power = 0.71536, n = [15, 15]))BioequivalencePower.adjusted_α_with_samplesize — Methodadjusted_α_with_samplesize(::Type{BS}, ::Type{D} = EDDefaultDesign;
kwargs...
) where {BS <: BioequivalencePowerStudy, D <: ExperimentalDesign}This is the easy-API adjusted_α_with_samplesize method.
There are two mandatory positional arguments, first the study type BS and then the design type D. Type names are used for these arguments. For example:
adjusted_α_with_samplesize(ExpandingLimitsRatioTOST, ED2x3x3PartialReplicate, ...)At the moment the only supported study type for BS is ExpandingLimitsRatioTOST.
After these positional arguments, the remaining arguments are indicated in the method signature via kwargs (key word arguments). With these keywords we always need to set the variability parameter, CV. The order of the keywords does not matter. Many other keywords are also possible (see below). Here is a minimal working example:
adjusted_α_with_samplesize(ExpandingLimitsRatioTOST, ED2x3x3PartialReplicate, CV = 0.35)The essence of the easy-API is that the it uses the complete-API under the hood, yet presents a simple interface. For example here, the coefficient of variation CV = 0.35 is set in a ExpandingLimitsRatioTOST{ED2x3x3PartialReplicate} object. This object is hidden from the user. The easy-API sees which arguments are supplied and constructs objects based on these arguments before invoking the complete-API internally.
Here is a full list of arguments:
1st argument: Must be
ExpandingLimitsRatioTOST.2nd argument: design. Use one of:
ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover, orED2x3x3PartialReplicate.
The keyword arguments following the initial arguments are always set in the form KEY = VALUE, where for example KEY can be CV and value can be 0.35. Here is a full list, starting with mandatory argument and following with optional arguments.
Mandatory Arguments
- Variability argument: This is
CVor if wishing to consider heteroscedasticity, specify as a vector of length 2, with the first entry for the test formulation and the second entry for the reference formulation.
Argument for "test/reference" ratio
A key input is the ratio between the test and reference formulation. That is, power is computed based on such a postulated point. It is denoted θ₀ with variable name peθ₀. Default is at 0.9 and you can naturally override that default.
Argument for limits
These are set limits values θ₁ and θ₂ with θ₁ < θ₂. Default values are set for all of these with defaults θ₁ = 0.8 and θ₂ = 1/θ₁ (this is 1.25). You can set your own values to override the defaults. Note that in most cases θ₂ is defined in terms of θ₁. Hence you may set θ₁ and as a result, θ₂ will be adjusted accordingly, or you may set only θ₂, or set both.
Type I error and α
α: By default,α = 0.05. This is the desired type I error.
Further optional Arguments for hypothesis test meta parameters (including assumptions)
n: Can be an integer denoting the total number of subjects or an array of the number of subjects per sequence group, e.g.n = [12, 8]. In the typical case where the total number of subjects is given, the subjects are distributed as uniformly as possible among sequences of the design using thedistribute_groupsfunction. If this argument is not given,adjusted_α_with_samplesizecallssamplesizeto obtain this value.
Special arguments for expanding limits
reg_symbol: This is the symbol for theRegulatoryConstantsobject set in eitherReferenceScaledRatioTOSTorExpandingLimitsRatioTOSTstudies. For the former the default is:fdaand for the latter it is:ema. You may set other regulatory constants objects if you wish.
Arguments for simulation
Note that the arguments num_sims, seed, and subject_level are for Monte Carlo power calculation
When using Monte Carlo, these are the possible arguments.
num_sims: This is the number of simulation runs to execute. The default is1e5.seed: This is the simulation seed to use for reproducibility. The default value is an arbitrary1984value, yet can be set to any integer value. Settingseed = nothing, implies no random seed is set. Warning: sample size search or power analysis without a fixed seed is not recommended..details: Set this to true to output additional simulation and/or computation output. Default isfalse.subject_level: This argument is by defaultfalseand this implies simulations are based on randomly generating statistics. If set totruethen it means that each simulation run randomly generates sample data and uses this random data to estimate the power. In general,subject_level = trueis slower, yet in certain cases it yields better accuracy.
Other arguments
The argument max_iter with a default value of 10 determines an upper bound on the number of adjusted_α function calls.
Return value
The same as adjusted_α yet with a corrected sample size if needed.
Confidence Interval
StatsAPI.confint — Methodconfint(::Type{BS}, ::Type{D} = EDDefaultDesign;
kwargs...
) where {BS <: BioequivalencePowerStudy, D <: ExperimentalDesign}This is the easy-API confint method.
There are two mandatory positional arguments, first the study type BS and then the design type D. Type names are used for these arguments. For example:
confint(RatioTOST, ED2x2x3ReplicateCrossover, ...)After these positional arguments, the remaining arguments are indicated in the method signature via kwargs (key word arguments). With these keywords we always need to set the number of subjects, n, the variability parameter, CV (can also be SE in certain cases), and the point estimate peθ₀ (note that the point estimate has a default value when we use the complete-API but with the easy-API we purposefully do not have a default value). The order of the keywords does not matter. Several other keywords are also possible (see below). Here is a minimal working example:
confint(RatioTOST, ED2x2x3ReplicateCrossover, n = 20, CV = 0.32, peθ₀ = 0.9)The essence of the easy-API is that the it uses the complete-API under the hood, yet presents a simple interface. For example here, the number of subjects, n = 20 is automatically set in an HypothesisTestMetaParams object, and the coefficient of variation CV = 0.32 is set in a RatioTOST{ED2x2x3ReplicateCrossover} object, similarly for peθ₀. These objects are hidden from the user. The easy-API sees which arguments are supplied and constructs the objects based on these arguments before invoking the complete-API internally.
Here is a full list of arguments:
1st argument: bioequivalence power study type. One of:
- Standard (average) bioequivalence:
RatioTOSTorDifferenceTOST - Tests in the context of fiducial inference:
FiducialRatioTOST
- Standard (average) bioequivalence:
2nd argument: design.
- For the study types
RatioTOSTorDifferenceTOST, use one of:ED2Parallel,ED2x2Crossover,ED3x3Crossover,ED3x6x3Crossover,ED4x4Crossover,ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover,ED2x4x4ReplicateCrossover,ED2x3x3PartialReplicate,ED2x4x2Balaam,ED2x2x2RepeatedCrossover, orEDPaired. - For the study type
FiducialRatioTOSTuse one ofED2ParallelorED2x2Crossover.
- For the study types
The keyword arguments following the initial arguments are always set in the form KEY = VALUE, where for example KEY can be n and value can be 20 for indicating the number of subjects. Here is a full list, starting with mandatory arguments and following with optional arguments.
Mandatory Arguments
n: Can be an integer denoting the total number of subjects or an array of the number of subjects per sequence group, e.g.n = [12, 8]. In the typical case where the total number of subjects is given, the subjects are distributed as uniformly as possible among sequences of the design using thedistribute_groupsfunction.- Variability arguments: The typical variability argument is
CV, but in certain casesSEis used instead. In other cases secondary variability arguments are required. Note that variability arguments are always positive.RatioTOST: SpecifyCVas a single value.DifferenceTOST: SpecifySEas a single value.FiducialRatioTOST: Specify bothSEandSEb, each as a single value.
peθ₀: This is the observed point estimate of the "test/reference" ratio or difference.
Optional Arguments for hypothesis test meta parameters (including assumptions)
α: By default,α = 0.05unless it usingFiducialRatioTOST, where it is set at0.025(note that this adjusted default is only applicable via the easy-API and not via the complete-API).robust: Set this to true for a determination of degrees of freedom using a robust formulation. Default isfalse.
Return value
The return value is a tuple that has the lower and upper limits of the confidence interval.
p-value
StatsAPI.pvalue — Methodpvalue(::Type{BS}, ::Type{D} = EDDefaultDesign;
kwargs...) where {BS <: BioequivalencePowerStudy, D <: ExperimentalDesign}This is the easy-API pvalue method.
There are two mandatory positional arguments, first the study type BS and then the design type D. Type names are used for these arguments. For example:
pvalue(RatioTOST, ED2x2x3ReplicateCrossover, ...)After these positional arguments, the remaining arguments are indicated in the method signature via kwargs (key word arguments). With these keywords we always need to set the number of subjects, n, the variability parameter, CV or SE, and the point estimate peθ₀ (note that the point estimate has a default value when we use the complete-API but with the easy-API we purposefully do not have a default value). The order of the keywords does not matter. Several other keywords are also possible (see below). Here is a minimal working example:
pvalue(RatioTOST, ED2x2x3ReplicateCrossover, n = 20, CV = 0.32, peθ₀ = 0.9)The essence of the easy-API is that the it uses the complete-API under the hood, yet presents a simple interface. For example here, the number of subjects, n = 20 is automatically set in an HypothesisTestMetaParams object, and the coefficient of variation CV = 0.32 is set in a RatioTOST{ED2x2x3ReplicateCrossover} object, similarly for peθ₀. These objects are hidden from the user. The easy-API sees which arguments are supplied and constructs the objects based on these arguments before invoking the complete-API internally.
Here is a full list of arguments:
1st argument: bioequivalence power study type and only standard (average) bioequivalence is supported. Hence the argument is one of
RatioTOSTorDifferenceTOST.2nd argument: design. One of:
ED2Parallel,ED2x2Crossover,ED3x3Crossover,ED3x6x3Crossover,ED4x4Crossover,ED2x2x3ReplicateCrossover,ED2x2x4ReplicateCrossover,ED2x4x4ReplicateCrossover,ED2x3x3PartialReplicate,ED2x4x2Balaam,ED2x2x2RepeatedCrossover, orEDPaired.
The keyword arguments following the initial arguments are always set in the form KEY = VALUE, where for example KEY can be n and value can be 20 for indicating the number of subjects. Here is a full list, starting with mandatory arguments and following with optional arguments.
Mandatory Arguments
n: Can be an integer denoting the total number of subjects or an array of the number of subjects per sequence group, e.g.n = [12, 8]. In the typical case where the total number of subjects is given, the subjects are distributed as uniformly as possible among sequences of the design using thedistribute_groupsfunction.- Variability arguments: The typical variability argument is
CV, but in certain casesSEis used instead. Note that variability arguments are always positive.RatioTOST: SpecifyCVas a single value.DifferenceTOST: SpecifySEas a single value.
peθ₀: This is the observed point estimate of the "test/reference" ratio or difference.
Optional Arguments for hypothesis test meta parameters (including assumptions)
robust: Set this to true for a determination of degrees of freedom using a robust formulation. Default isfalse.
Additional arguments
both_p_values: Set this totrueif you wish for the return value to be both the p-values (from each of the one sided tests that make up a TOST). Default is 'false'.
Return value
The return value is a p-value, unless both_p_values = true in which case the return value is a tuple of two p-values.