| Title: | Optimal Monotone Conditional Error Functions |
|---|---|
| Description: | Design and analysis of confirmatory adaptive clinical trials using the optimal conditional error framework according to Brannath and Bauer (2004) <doi:10.1111/j.0006-341X.2004.00221.x>. An extension to the optimal conditional error function using interim estimates as described in Brannath and Dreher (2024) <doi:10.48550/arXiv.2402.00814> and functions to ensure that the resulting conditional error function is non-increasing are also available. |
| Authors: | Morten Dreher [aut, cre], Werner Brannath [aut, cph] (ORCID: <https://orcid.org/0000-0002-8622-3904>), Cornelia Ursula Kunz [ctb] (ORCID: <https://orcid.org/0000-0002-8900-9401>), Johanna zur Verth [aut] |
| Maintainer: | Morten Dreher <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.2 |
| Built: | 2026-05-15 09:12:17 UTC |
| Source: | https://github.com/morten-dreher/optconerrf |
This function performs very basic range checks for numeric variables and throws an error if the range is violated. A custom hint may be added to the message.
.rangeCheck(variable, range, allowedEqual, hint = "").rangeCheck(variable, range, allowedEqual, hint = "")
variable |
The (named) variable to be checked. |
range |
A vector of length 2 giving the minimum and maximum of the allowed range. |
allowedEqual |
Logical. Are the borders of range valid values? |
hint |
Additional message that may be printed after the error. |
Invisibly returns TRUE if the check was successful.
This function returns a design object which contains all important parameters for the specification of the optimal conditional error function.
The returned object is of class TrialDesignOptimalConditionalError and can be passed to other package functions.
getDesignOptimalConditionalErrorFunction( alpha, alpha1, alpha0, conditionalPower = NA_real_, delta1 = NA_real_, delta1Min = NA_real_, delta1Max = Inf, ncp1 = NA_real_, ncp1Min = NA_real_, ncp1Max = Inf, useInterimEstimate = TRUE, firstStageInformation, likelihoodRatioDistribution, minimumSecondStageInformation = 0, maximumSecondStageInformation = Inf, minimumConditionalError = 0, maximumConditionalError = 1, conditionalPowerFunction = NA, levelConstantMinimum = 0, levelConstantMaximum = 10, enforceMonotonicity = TRUE, ... )getDesignOptimalConditionalErrorFunction( alpha, alpha1, alpha0, conditionalPower = NA_real_, delta1 = NA_real_, delta1Min = NA_real_, delta1Max = Inf, ncp1 = NA_real_, ncp1Min = NA_real_, ncp1Max = Inf, useInterimEstimate = TRUE, firstStageInformation, likelihoodRatioDistribution, minimumSecondStageInformation = 0, maximumSecondStageInformation = Inf, minimumConditionalError = 0, maximumConditionalError = 1, conditionalPowerFunction = NA, levelConstantMinimum = 0, levelConstantMaximum = 10, enforceMonotonicity = TRUE, ... )
alpha |
The overall type I error rate |
alpha1 |
Stage 1 efficacy boundary |
alpha0 |
Binding stage 1 futility boundary |
conditionalPower |
The target conditional power |
delta1 |
Fixed effect assumption at which the conditional power should be achieved, expressed on the mean difference scale. Is only used if |
delta1Min |
The minimum for an interim estimate of the treatment effect, specified on the mean difference scale. If the interim estimate (on the mean difference scale) yields a value smaller than |
delta1Max |
The maximum for an interim estimate of the treatment effect, specified on the mean difference scale. If the interim estimate (on the mean difference scale) yields a value larger than |
ncp1 |
Fixed effect assumption at which the conditional power should be achieved, expressed on the non-centrality parameter scale. Is only used if |
ncp1Min |
The minimum for an interim estimate of the treatment effect, specified on the non-centrality parameter scale. If the interim estimate (on the non-centrality parameter scale) yields a value smaller than |
ncp1Max |
The maximum for an interim estimate of the treatment effect, specified on the non-centrality parameter scale. If the interim estimate (on the non-centrality parameter scale) yields a value larger than |
useInterimEstimate |
Logical. Defines whether or not an interim estimate should be used for conditional power.
If |
firstStageInformation |
Information of the first stage of the trial. Must be a positive numeric value. |
likelihoodRatioDistribution |
The distribution to be used for the effect size of the likelihood ratio in the optimal conditional error function. Options are
|
minimumSecondStageInformation |
The minimum information allowed in the second stage of the trial. Must be a numeric value. Default value is |
maximumSecondStageInformation |
The maximum information allowed in the second stage of the trial. Must be a numeric value. Default value is |
minimumConditionalError |
Lower boundary for the optimal conditional error function. Default 0 (no restriction). |
maximumConditionalError |
Upper boundary for the optimal conditional error function. Default value is 1, however, the optimal conditional error function is inherently bounded by the conditional power. |
conditionalPowerFunction |
A user-specified function which calculates the conditional power from the first-stage p-value. This function should not be increasing in the first-stage p-value or monotonicity issues may occur. |
levelConstantMinimum |
The minimum of the interval on which the value for the level constant should be searched. Default value is 0. |
levelConstantMaximum |
The maximum of the interval on which the value for the level constant should be searched. Default value is 10. |
enforceMonotonicity |
Logical. Determines whether or not the optimal conditional error function should automatically be modified to be non-increasing. Default is |
... |
Additional arguments required for the specification of the likelihood ratio. |
The design object contains the information required to determine the specific setting of the optimal conditional error function and can be passed to other package functions. From the given user specifications, the constant to achieve level condition for control of the overall type I error rate as well as the constants to ensure a non-increasing optimal CEF (if required) are automatically calculated.
An object of class TrialDesignOptimalConditionalError, which can be passed to other package functions.
To calculate the optimal conditional error function, an assumption about the true parameter under which the second-stage information is to be minimised is required.
Various options are available and can be specified via the argument likelihoodRatioDistribution:
likelihoodRatioDistribution="fixed": calculates the likelihood ratio for a fixed . The non-centrality parameter of the likelihood ratio is then computed as deltaLR*sqrt(firstStageInformation) and the likelihood ratio is calculated as:
deltaLR may also contain multiple elements, in which case a weighted likelihood ratio is calculated for the given values. Unless positive weights that sum to 1 are provided by the argument weightsDeltaLR, equal weights are assumed.
likelihoodRatioDistribution="normal": calculates the likelihood ratio for a normally distributed prior of with mean deltaLR*sqrt(firstStageInformation) () and standard deviation tauLR*sqrt(firstStageInformation) (). The parameters deltaLR and tauLR must be specified on the mean difference scale.
likelihoodRatioDistribution="exp": calculates the likelihood ratio for an exponentially distributed prior of with mean kappaLR*sqrt(firstStageInformation) (). The likelihood ratio is then calculated as:
likelihoodRatioDistribution="unif": calculates the likelihood ratio for a uniformly distributed prior of on the support , where is specified as deltaMaxLR and is the firstStageInformation.
likelihoodRatioDistribution="maxlr": the non-centrality parameter is estimated from the data and no additional parameters must be specified. The likelihood ratio is estimated from the data as:
The maximum likelihood ratio is always restricted to effect sizes (corresponding to ).
For the treatment effect at which the target conditional power should be achieved, either a fixed effect or an interim estimate can be used.
The usage of a fixed effect is indicated by setting useInterimEstimate=FALSE, in which case the fixed effect is provided by delta1 on the mean difference scale or by ncp1 on the non-centrality parameter scale (i.e., delta1*sqrt(firstStageInformation)).
For an interim estimate, specified by useInterimEstimate=TRUE, a lower cut-off for the interim estimate must be provided, either by delta1Min on the mean difference scale, or ncp1Min on the non-centrality parameter scale.
In addition, an upper limit of the estimate may be analogously provided by delta1Max or ncp1Max.
The first-stage information of the trial design must be specified to allow for calculations between the mean difference and non-centrality parameter scale.
It is provided to the design object via firstStageInformation.
Listed below are some examples for the calculation between information () and sample size:
One-sample z-test with total patients: , where is the variance of an individual observation
Balanced two-sample z-test with patients per group: , where is the common variance
General two-sample z-test with , patients per group: , where , are the group-wise variances
By default, the optimal conditional error function returned by getDesignOptimalConditionalErrorFunction() is transformed to be non-increasing in the first-stage p-value if found to be increasing on any interval.
The necessary intervals and constants for the transformation are calculated by getMonotonisationConstants().
Although not recommended for the operating characteristics of the design, the transformation may be omitted by setting enforceMonotonicity=FALSE.
In some applications, it may be feasible to restrict the optimal conditional error function by a lower and/or upper limit.
These constraints can be directly implemented on the function by using the arguments minimumConditionalError and maximumConditionalError.
By default, minimumConditionalError=0 and maximumConditionalError=1, i.e., no constraints are applied.
The constraints may also be specified on the second-stage information via minimumSecondStageInformation and maximumSecondStageInformation.
If both minimumConditionalError and maximumSecondStageInformation respectively maximumConditionalError and minimumSecondStageInformation
are provided, both constraints will be applied.
The level constant is determined by the helper function getLevelConstant(). It is identified using the uniroot() function and by default, the interval between 0 and 10 is searched for the level constant.
In specific settings, the level constant may lie outside of this interval. In such cases, the search interval can be changed by altering the parameters levelConstantMinimum and levelConstantMaximum.
If inappropriate constraints to the optimal conditional error function are provided via minimumConditionalError and maximumConditionalError
or minimumSecondStageInformation and maximumSecondStageInformation, it may be impossible to find a level constant which exhausts the full alpha level.
The print() and plot() functions are available for objects of class TrialDesignOptimalConditionalError.
For details, see ?print.TrialDesignOptimalConditionalError and ?plot.TrialDesignOptimalConditionalError.
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
Brannath, W., Dreher, M., zur Verth, J., Scharpenberg, M. (2024). Optimal monotone conditional error functions. https://arxiv.org/abs/2402.00814
# Create a single-arm design with fixed parameter for the likelihood ratio # and a fixed effect for conditional power. 80 patients are observed in the # first-stage (firstStageInformation = 80 in the one-sample test, variance 1). # The second-stage information is restricted to be between 40 and 160. getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, minimumSecondStageInformation = 40, maximumSecondStageInformation = 160 ) # Create a design comparing two groups using the maximum likelihood ratio # and an interim estimate for the effect for conditional power. # 160 patients per arm are observed in the first stage # (firstStageInformation = 80 in the balanced two-sample test, variance 1). getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1Min = 0.25, likelihoodRatioDistribution = "maxlr", firstStageInformation = 80, useInterimEstimate = TRUE )# Create a single-arm design with fixed parameter for the likelihood ratio # and a fixed effect for conditional power. 80 patients are observed in the # first-stage (firstStageInformation = 80 in the one-sample test, variance 1). # The second-stage information is restricted to be between 40 and 160. getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, minimumSecondStageInformation = 40, maximumSecondStageInformation = 160 ) # Create a design comparing two groups using the maximum likelihood ratio # and an interim estimate for the effect for conditional power. # 160 patients per arm are observed in the first stage # (firstStageInformation = 80 in the balanced two-sample test, variance 1). getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1Min = 0.25, likelihoodRatioDistribution = "maxlr", firstStageInformation = 80, useInterimEstimate = TRUE )
Calculate the expected second-stage information using the optimal conditional error function with specific assumptions.
getExpectedSecondStageInformation( design, likelihoodRatioDistribution = NULL, ... )getExpectedSecondStageInformation( design, likelihoodRatioDistribution = NULL, ... )
design |
An object of class |
likelihoodRatioDistribution |
The distribution to be used for the effect size of the likelihood ratio in the calculation of the expected second-stage information. Options are
The default is |
... |
Additional parameters required for the specification of |
The expected second-stage information is calculated as:
where
are the first-stage efficacy and futility boundaries
is the optimal conditional error calculated for
is the "true" likelihood ratio under which to calculate the expected sample size. This can be different from the likelihood ratio used to calibrate the optimal conditional error function.
is the assumed treatment effect to power for, expressed as a mean difference. It may depend on the interim data (i.e., ) in case useInterimEstimate = TRUE was specified for the design object.
is a factor calculated for the specific assumptions about the optimal conditional error function and the target conditional power .
Expected second-stage information.
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
getDesignOptimalConditionalErrorFunction(), getSecondStageInformation()
# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) # Calculate expected information under correct specification getExpectedSecondStageInformation(design) # Calculate expected information under the null hypothesis getExpectedSecondStageInformation( design = design, likelihoodRatioDistribution = "fixed", deltaLR = 0 )# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) # Calculate expected information under correct specification getExpectedSecondStageInformation(design) # Calculate expected information under the null hypothesis getExpectedSecondStageInformation( design = design, likelihoodRatioDistribution = "fixed", deltaLR = 0 )
Find the constant required such that the conditional error function meets the overall level condition.
getLevelConstant(design)getLevelConstant(design)
design |
An object of class |
The level condition is defined as:
The constant of the optimal conditional error function is calibrated such that it meets the level condition.
For a valid design, the additional following condition must be met to be able to exhaust the level :
This condition is checked by getLevelConstant() and the execution is terminated if it is not met.
In case a conditional power function is used, the condition is instead:
A list that contains the constant (element $root) and other components provided by uniroot().
The level constant is calculated corresponding to the mean difference scale.
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
Brannath, W., Dreher, M., zur Verth, J., Scharpenberg, M. (2024). Optimal monotone conditional error functions. https://arxiv.org/abs/2402.00814
Calculate the likelihood ratio of a p-value for a given distribution.
getLikelihoodRatio(firstStagePValue, design)getLikelihoodRatio(firstStagePValue, design)
firstStagePValue |
First-stage p-value or p-values. Must be a numeric vector between 0 and 1. |
design |
An object of class |
The calculation of the likelihood ratio for a first-stage p-value is done based on a distributional assumption, specified in the design object.
The different options require different parameters, elaborated in the following.
likelihoodRatioDistribution="fixed": calculates the likelihood ratio for a fixed . The non-centrality parameter of the likelihood ratio is then computed as deltaLR*sqrt(firstStageInformation) and the likelihood ratio is calculated as:
deltaLR may also contain multiple elements, in which case a weighted likelihood ratio is calculated for the given values. Unless positive weights that sum to 1 are provided by the argument weightsDeltaLR, equal weights are assumed.
likelihoodRatioDistribution="normal": calculates the likelihood ratio for a normally distributed prior of with mean deltaLR*sqrt(firstStageInformation) () and standard deviation tauLR*sqrt(firstStageInformation) (). The parameters deltaLR and tauLR must be specified on the mean difference scale.
likelihoodRatioDistribution="exp": calculates the likelihood ratio for an exponentially distributed prior of with mean kappaLR*sqrt(firstStageInformation) (). The likelihood ratio is then calculated as:
likelihoodRatioDistribution="unif": calculates the likelihood ratio for a uniformly distributed prior of on the support , where is specified as deltaMaxLR and is the firstStageInformation.
likelihoodRatioDistribution="maxlr": the non-centrality parameter is estimated from the data and no additional parameters must be specified. The likelihood ratio is estimated from the data as:
The maximum likelihood ratio is always restricted to effect sizes (corresponding to ).
The value of the likelihood ratio for the given specification.
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
Hung, H. M. J., O’Neill, R. T., Bauer, P. & Kohne, K. (1997). The behavior of the p-value when the alternative hypothesis is true. Biometrics. https://www.jstor.org/stable/2533093
# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) getLikelihoodRatio(firstStagePValue = c(0.05, 0.1, 0.2), design = design)# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) getLikelihoodRatio(firstStagePValue = c(0.05, 0.1, 0.2), design = design)
Applies the provided monotonisation constants to a specified, possibly non-monotone function. The returned function values are non-increasing.
getMonotoneFunction( x, fun, lower = NULL, upper = NULL, argument = NULL, nSteps = 10^4, epsilon = 10^(-5), numberOfIterationsQ = 10^4, design )getMonotoneFunction( x, fun, lower = NULL, upper = NULL, argument = NULL, nSteps = 10^4, epsilon = 10^(-5), numberOfIterationsQ = 10^4, design )
x |
Argument values. |
fun |
The function to be made monotone. |
lower |
The lower limit of the interval on which the function should be monotonised. Must be a numeric value. |
upper |
The upper limit of the interval on which the function should be monotonised. |
argument |
The argument in which the function should be monotonised, given as a character. |
nSteps |
The number of steps to be taken when checking the function for monotonicity. Must be a numeric value. Default 10^4. |
epsilon |
Maximum allowed difference between the initial and monotone integral. Must be a numeric value. Default 10^-5. |
numberOfIterationsQ |
Maximum number of iterations allowed to determine each value of q. Must be a numeric value. Default 10^4. |
design |
An object of class |
The exact monotonisation process is outlined in Brannath et al. (2024), but specified in terms of the first-stage test statistic rather than the first-stage p-value .
The algorithm can easily be translated to the use of p-values by switching the maximum and minimum functions, i.e., replacing by and by .
Monotone function values.
Brannath, W., Dreher, M., zur Verth, J., Scharpenberg, M. (2024). Optimal monotone conditional error functions. https://arxiv.org/abs/2402.00814
Computes the constants required to make a function non-increasing on the specified interval. The output of this function is necessary to calculate the monotone optimal conditional error function.
The output object is a list that contains the intervals on which constant values are required, specified by the minimum dls and maximum dus of the interval and the respective constants, qs.
getMonotonisationConstants( fun, lower = 0, upper = 1, argument, nSteps = 10^4, epsilon = 10^(-5), numberOfIterationsQ = 10^4, design )getMonotonisationConstants( fun, lower = 0, upper = 1, argument, nSteps = 10^4, epsilon = 10^(-5), numberOfIterationsQ = 10^4, design )
fun |
The function to be made monotone. |
lower |
The lower limit of the interval on which the function should be monotonised. Must be a numeric value. |
upper |
The upper limit of the interval on which the function should be monotonised. |
argument |
The argument in which the function should be monotonised, given as a character. |
nSteps |
The number of steps to be taken when checking the function for monotonicity. Must be a numeric value. Default 10^4. |
epsilon |
Maximum allowed difference between the initial and monotone integral. Must be a numeric value. Default 10^-5. |
numberOfIterationsQ |
Maximum number of iterations allowed to determine each value of q. Must be a numeric value. Default 10^4. |
design |
An object of class |
A list containing the monotonisation constants (element $qs) and the intervals on which they must be applied, specified via minimum (element qls) and maximum (element qus).
Brannath, W., Dreher, M., zur Verth, J., Scharpenberg, M. (2024). Optimal monotone conditional error functions. https://arxiv.org/abs/2402.00814
Calculate the factor which relates to the second-stage information for given conditional power.
getNu(alpha, conditionalPower)getNu(alpha, conditionalPower)
alpha |
The (conditional) type I error rate of the design. Must be a numeric vector with values between 0 and 1. |
conditionalPower |
The target conditional power |
Note that this function uses factor 1 instead of factor 2 (Brannath & Bauer 2004). This has no impact on the optimal conditional error function, as constant factors are absorbed by the level constant .
The calculation is:
Factor linking information and .
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
getNu(alpha = 0.05, conditionalPower = 0.9) # Returns 0 if alpha exceeds conditionalPower getNu(alpha = 0.8, conditionalPower = 0.7)getNu(alpha = 0.05, conditionalPower = 0.9) # Returns 0 if alpha exceeds conditionalPower getNu(alpha = 0.8, conditionalPower = 0.7)
Calculates the derivative of nu for a given conditional error and conditional power.
getNuPrime(alpha, conditionalPower)getNuPrime(alpha, conditionalPower)
alpha |
The (conditional) type I error rate of the design. Must be a numeric vector with values between 0 and 1. |
conditionalPower |
The target conditional power |
The function is defined as
Note that in this implementation, the the factor -2 is used instead of -4, which is used in by Brannath & Bauer (2004), who explicitly investigate the setting of a balanced two-group trial.
The argument conditionalPower is either the fixed target conditional power or the value of the conditional power function at the corresponding first-stage p-value.
Value for nu prime.
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
getNuPrime(alpha = 0.05, conditionalPower = 0.9)getNuPrime(alpha = 0.05, conditionalPower = 0.9)
Calculate the Optimal Conditional Error
getOptimalConditionalError(firstStagePValue, design)getOptimalConditionalError(firstStagePValue, design)
firstStagePValue |
First-stage p-value or p-values. Must be a numeric vector between 0 and 1. |
design |
An object of class |
The optimal conditional error given a first-stage p-value is calculated as:
The level constant as well as the specification of the effect size and the likelihood ratio
must be contained in the design object (see ?getDesignOptimalConditionalErrorFunction).
Early stopping rules are supported, i.e., for , the returned conditional error is 1 and for , the returned conditional error is 0.
Value of the optimal conditional error function.
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
getDesignOptimalConditionalErrorFunction()
# Create a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.5, firstStageInformation = 40, useInterimEstimate = FALSE, likelihoodRatioDistribution = "fixed", deltaLR = 0.5) # Calculate optimal conditional error getOptimalConditionalError( firstStagePValue = c(0.1, 0.2, 0.3), design = design )# Create a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.5, firstStageInformation = 40, useInterimEstimate = FALSE, likelihoodRatioDistribution = "fixed", deltaLR = 0.5) # Calculate optimal conditional error getOptimalConditionalError( firstStagePValue = c(0.1, 0.2, 0.3), design = design )
Calculate the overall power and other operating characteristics of a design.
getOverallPower(design, alternative)getOverallPower(design, alternative)
design |
An object of class |
alternative |
Assumed relative effect size. |
This function is used to evaluate the overall performance of a design.
The probabilities for first-stage futility, first-stage efficacy and overall efficacy (i.e., overall power) are saved in an object of class PowerResultsOptimalConditionalError.
The overall power of the design at the provided effect size.
getDesignOptimalConditionalErrorFunction(), getSimulationResults()
# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) getOverallPower(design, alternative = 0.25)# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) getOverallPower(design, alternative = 0.25)
Get point-wise values of psi (inverse of nu prime)
getPsi(nuPrime, conditionalPower)getPsi(nuPrime, conditionalPower)
nuPrime |
The function value to be inverted. |
conditionalPower |
The target conditional power |
The function is the inverse of:
.
If the conditional power lies outside of the range , the calculation is slightly more complicated.
The argument conditionalPower is either the fixed target conditional power or the value of the conditional power function at the corresponding first-stage p-value.
The value of alpha which corresponds to nuPrime and lies between 0 and conditionalPower.
# Returns 0.05 getPsi(getNuPrime(alpha = 0.05, conditionalPower = 0.9), conditionalPower = 0.9)# Returns 0.05 getPsi(getNuPrime(alpha = 0.05, conditionalPower = 0.9), conditionalPower = 0.9)
Calculate the ratio of likelihood ratio and squared effect size.
getQ(firstStagePValue, design)getQ(firstStagePValue, design)
firstStagePValue |
First-stage p-value or p-values. Must be a numeric vector between 0 and 1. |
design |
An object of class |
For more information on how to specify the likelihood ratio, see ?getLikelihoodRatio().
In case the optimal conditional error function is ever increasing in the first-stage p-value , a monotone transformation of getQ()
is needed for logical consistency and type I error rate control.
The formula for is:
where is the likelihood ratio and is the effect size at which the conditional power should be achieved.
The effect size may also depend on the interim data (i.e., on ) in case useInterimEstimate = TRUE was specified for the design object.
Ratio of likelihood ratio and squared effect size.
Brannath, W., Dreher, M., zur Verth, J., Scharpenberg, M. (2024). Optimal monotone conditional error functions. https://arxiv.org/abs/2402.00814
# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) getQ(firstStagePValue = c(0.05, 0.1, 0.2), design = design)# Get a design design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, likelihoodRatioDistribution = "fixed", deltaLR = 0.25, firstStageInformation = 80, useInterimEstimate = FALSE, ) getQ(firstStagePValue = c(0.05, 0.1, 0.2), design = design)
Calculate second-stage information for given first-stage p-value and design.
getSecondStageInformation(firstStagePValue, design)getSecondStageInformation(firstStagePValue, design)
firstStagePValue |
First-stage p-value or p-values. Must be a numeric vector between 0 and 1. |
design |
An object of class |
The second-stage information is calculated given a first-stage p-value as:
where
is the conditional error function
is the target conditional power
is the assumed treatment effect (expressed as a mean difference).
The conditional error is calculated according to the specification provided in the design argument.
For p-values smaller or equal to the first-stage efficacy boundary as well as p-values greater than the first-stage futility boundary,
the returned information is 0 (since the trial is ended early in both cases).
The second-stage information.
Brannath, W. & Bauer, P. (2004). Optimal conditional error functions for the control of conditional power. Biometrics. https://www.jstor.org/stable/3695393
getDesignOptimalConditionalErrorFunction(), getExpectedSecondStageInformation(), getOptimalConditionalError()
design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, useInterimEstimate = FALSE, firstStageInformation = 40, likelihoodRatioDistribution = "maxlr" ) getSecondStageInformation( firstStagePValue = c(0.05, 0.1, 0.2), design = design )design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, conditionalPower = 0.9, delta1 = 0.25, useInterimEstimate = FALSE, firstStageInformation = 40, likelihoodRatioDistribution = "maxlr" ) getSecondStageInformation( firstStagePValue = c(0.05, 0.1, 0.2), design = design )
Simulate the rejection probability for a given design and alternative.
getSimulationResults( design, maxNumberOfIterations = 10000, alternative, seed = NULL )getSimulationResults( design, maxNumberOfIterations = 10000, alternative, seed = NULL )
design |
An object of class |
maxNumberOfIterations |
Number of trials to be simulated. |
alternative |
Assumed relative effect size. |
seed |
An optional seed for reproducibility. |
Simulates the probabilities of overall rejection as well as early futility and early efficacy for the provided scenario and design. This is done by generating random normally distributed test statistics and calculating their p-values.
An object of class SimulationResultsOptimalConditionalError containing the simulation results.
getDesignOptimalConditionalErrorFunction(), getOverallPower()
design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, delta1 = 0.25, useInterimEstimate = FALSE, conditionalPower = 0.9, likelihoodRatioDistribution = "maxlr", firstStageInformation = 10 ) # Simulate under the null hypothesis and for a mean difference of 0.5 getSimulationResults( design = design, alternative = c(0, 0.5) )design <- getDesignOptimalConditionalErrorFunction( alpha = 0.025, alpha1 = 0.001, alpha0 = 0.5, delta1 = 0.25, useInterimEstimate = FALSE, conditionalPower = 0.9, likelihoodRatioDistribution = "maxlr", firstStageInformation = 10 ) # Simulate under the null hypothesis and for a mean difference of 0.5 getSimulationResults( design = design, alternative = c(0, 0.5) )
The returned plot is a ggplot2 object and can be supplemented with additional layers using ggplot2 commands.
## S3 method for class 'TrialDesignOptimalConditionalError' plot(x, range = c(0, 1), type = 1, plotNonMonotoneFunction = FALSE, ...)## S3 method for class 'TrialDesignOptimalConditionalError' plot(x, range = c(0, 1), type = 1, plotNonMonotoneFunction = FALSE, ...)
x |
Design object of class |
range |
Numeric vector with two entries specifying the range of the x-axis of the plot. |
type |
Type of plot to be created. Options are:
|
plotNonMonotoneFunction |
Logical. Should the non-monotone version of the plot be drawn? Not applicable for plot type 3. Default: |
... |
Additional arguments required for generic compatibility |
No return value, plots the design.
A class for power results of the optimal conditional error function.
Print an overview of exact power results.
## S3 method for class 'PowerResultsOptimalConditionalError' print(x, ...)## S3 method for class 'PowerResultsOptimalConditionalError' print(x, ...)
x |
Power results object of class |
... |
Additional arguments required for generic compatibility |
No return value, prints the power calculation results.
Print an overview of simulation results.
## S3 method for class 'SimulationResultsOptimalConditionalError' print(x, ...)## S3 method for class 'SimulationResultsOptimalConditionalError' print(x, ...)
x |
Simulation results object of class |
... |
Additional arguments required for generic compatibility |
No return value, prints the simulation results.
Print an overview of the specified design parameters.
## S3 method for class 'TrialDesignOptimalConditionalError' print(x, ...)## S3 method for class 'TrialDesignOptimalConditionalError' print(x, ...)
x |
Design object of class |
... |
Additional arguments required for generic compatibility |
No return value, prints the design.
A class for simulation results of the optimal conditional error function.
Provide an overview of the operating characteristics of the optimal conditional error trial design.
## S3 method for class 'TrialDesignOptimalConditionalError' summary(object, ...)## S3 method for class 'TrialDesignOptimalConditionalError' summary(object, ...)
object |
Design object of class |
... |
Additional arguments required for generic compatibility |
No return value, prints a summary of design performance.
A class for a trial design object using the optimal conditional error function.
This object should not be created directly; use getDesignOptimalConditionalErrorFunction() with suitable arguments to create a design.