Learn R Programming

optconerrf (version 1.0.1)

getDesignOptimalConditionalErrorFunction: Create a design object for the optimal conditional error function.

Description

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.

Usage

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,
  ...
)

Value

An object of class TrialDesignOptimalConditionalError, which can be passed to other package functions.

Arguments

alpha

The overall type I error rate \(\alpha\) of the design. Must be a numeric value between 0 and 1.

alpha1

Stage 1 efficacy boundary \(\alpha_1\) (p-value scale). Must be a numeric value between 0 and 1. Should be smaller than alpha0.

alpha0

Binding stage 1 futility boundary \(\alpha_0\) (p-value scale). Must be a numeric value between 0 and 1. Should be greater than alpha1. For use of a non-binding futility boundary, specify alpha0=1.

conditionalPower

The target conditional power \(CP\) of the design. Must be a numeric value.

delta1

Fixed effect assumption at which the conditional power should be achieved, expressed on the mean difference scale. Is only used if useInterimEstimate=FALSE. Alternatively, ncp1 can be specified. Must be a numeric value greater than 0.

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 delta1Min, delta1Min is used for it. Is only used if useInterimEstimate=TRUE. Alternatively, ncp1Min can be specified. Must be a numeric value.

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 delta1Max, delta1Max is used for it. Is only used if useInterimEstimate=TRUE. Alternatively, ncp1Max can be specified. Must be a numeric value. Default value is Inf, i.e., no upper restriction.

ncp1

Fixed effect assumption at which the conditional power should be achieved, expressed on the non-centrality parameter scale. Is only used if useInterimEstimate=FALSE. Alternatively, delta1 can be specified. Must be a numeric value greater than 0.

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 ncp1Min, ncp1Min is used for it. Is only used if useInterimEstimate=TRUE. Alternatively, delta1Min can be specified. Must be a numeric value.

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 ncp1Max, ncp1Max is used for it. Is only used if useInterimEstimate=TRUE. Alternatively, delta1Max can be specified. Must be a numeric value. Default value is Inf, i.e., no upper restriction.

useInterimEstimate

Logical. Defines whether or not an interim estimate should be used for conditional power. If TRUE, a lower cut-off for the interim estimate must be specified by delta1Min or ncp1Min. An upper cut-off may also be specified by delta1Max or ncp1Max. If FALSE, the fixed effect size must be specified by delta1 or ncp1.

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 "fixed", "normal", "exp", "unif", "maxlr" for fixed effect size, normally distributed, exponentially distributed, uniformly distributed prior of the effect size and maximum likelihood ratio, respectively. Each case requires different additional specifications:

  • likelihoodRatioDistribution="fixed" uses one (or more) fixed effect sizes for the likelihood ratio and requires the parameter deltaLR which provides the mean difference under which to calculate the likelihood ratio. If deltaLR contains multiple values, they may be weighted using an additional argument weightsDeltaLR. Omitting weightsDeltaLR automatically leads to equal weighting.

  • likelihoodRatioDistribution="normal" uses a normal prior for the effect size and requires parameters deltaLR and tauLR for the mean and standard deviation of the normal distribution (both on mean difference scale).

  • likelihoodRatioDistribution="exp" uses an exponential prior for the effect size and requires the parameter kappaLR which is the mean of the exponential distribution (on the mean difference scale).

  • likelihoodRatioDistribution="unif" uses a uniform prior for the effect size and requires the specification of deltaMaxLR, which is the maximum of the support for the uniform likelihood ratio distribution (on the mean difference scale).

  • likelihoodRatioDistribution="maxlr" estimates the non-centrality parameter to be used for the likelihood ratio from the data. No additional parameters must be specified.

minimumSecondStageInformation

The minimum information allowed in the second stage of the trial. Must be a numeric value. Default value is 0, i.e., no restriction.

maximumSecondStageInformation

The maximum information allowed in the second stage of the trial. Must be a numeric value. Default value is Inf, i.e., no restriction.

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 TRUE.

...

Additional arguments required for the specification of the likelihood ratio.

Likelihood ratio distribution

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 \(\Delta\). The non-centrality parameter of the likelihood ratio \(\vartheta\) is then computed as deltaLR*sqrt(firstStageInformation) and the likelihood ratio is calculated as: $$l(p_1) = e^{\Phi^{-1}(1-p_1)\vartheta - \vartheta^2/2}.$$ 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 \(\vartheta\) with mean deltaLR*sqrt(firstStageInformation) (\(\mu\)) and standard deviation tauLR*sqrt(firstStageInformation) (\(\sigma\)). The parameters deltaLR and tauLR must be specified on the mean difference scale. $$l(p_1) = (1+\sigma^2)^{-\frac{1}{2}}\cdot e^{-(\mu/\sigma)^2/2 + (\sigma\Phi^{-1}(1-p_1) + \mu/\sigma)^2 / (2\cdot (1+\sigma^2))}$$

  • likelihoodRatioDistribution="exp": calculates the likelihood ratio for an exponentially distributed prior of \(\vartheta\) with mean kappaLR*sqrt(firstStageInformation) (\(\eta\)). The likelihood ratio is then calculated as: $$l(p_1) = \kappa \cdot \sqrt{2\pi} \cdot e^{(\Phi^{-1}(1-p_1)-\eta)^2/2} \cdot \Phi(\Phi^{-1}(1-p_1)-\eta)$$

  • likelihoodRatioDistribution="unif": calculates the likelihood ratio for a uniformly distributed prior of \(\vartheta\) on the support \([0, \Delta\cdot\sqrt{I_1}]\), where \(\Delta\) is specified as deltaMaxLR and \(I_1\) is the firstStageInformation. $$l(p_1) = \frac{\sqrt{2\pi}}{\Delta\cdot\sqrt{I_1}} \cdot e^{\Phi^{-1}(1-p_1)^2/2} \cdot (\Phi(\Delta\cdot\sqrt{I_1} - \Phi^{-1}(1-p_1))-p_1)$$

  • likelihoodRatioDistribution="maxlr": the non-centrality parameter \(\vartheta\) is estimated from the data and no additional parameters must be specified. The likelihood ratio is estimated from the data as: $$l(p_1) = e^{max(0, \Phi^{-1}(1-p_1))^2/2}$$ The maximum likelihood ratio is always restricted to effect sizes \(\vartheta \geq 0\) (corresponding to \(p_1 \leq 0.5\)).

Effect for conditional power

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.

Sample size and information

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 (\(I_1\)) and sample size:

  • One-sample z-test with \(n\) total patients: \(I_1 = \frac{n}{\sigma^2}\), where \(\sigma^2\) is the variance of an individual observation

  • Balanced two-sample z-test with \(n_1\) patients per group: \(I_1 = \frac{1}{2}\cdot\frac{n_1}{\sigma^2}\), where \(\sigma^2\) is the common variance

  • General two-sample z-test with \(n_1\), \(n_2\) patients per group: \(I_1 = 1/(\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2})\), where \(\sigma_1^2\), \(\sigma_2^2\) are the group-wise variances

Monotonicity

By default, the optimal conditional error function returned by getDesignOptimalConditionalErrorFunction() is transformed to be non-increasing in the first-stage p-value \(p_1\) 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.

Constraints

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.

Level constant

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.

Generic functions

The print() and plot() functions are available for objects of class TrialDesignOptimalConditionalError. For details, see ?print.TrialDesignOptimalConditionalError and ?plot.TrialDesignOptimalConditionalError.

Details

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.

References

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

Examples

Run this code
# \donttest{
# 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
)
# }

Run the code above in your browser using DataLab