### Example: Concordance Probability Estimate for Cox Model Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Demonstrates how to use the `coxphCPE` function with the `pbc` dataset. It fits a Cox model and then calculates the CPE. This example is not run by default. ```R library(survival) data(pbc) pbcfit <- coxph(Surv(time, status==2) ~ trt + log(copper), pbc, subset=(trt>0 & copper>0)) coxphCPE(pbcfit) ``` -------------------------------- ### Example: Explained Relative Risk for Cox Model (Subset of Covariates) Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Demonstrates calculating the explained relative risk (ERR) for a subset of covariates (age and ECOG performance status) using `coxphERR`. The indices of the covariates are provided. ```R library(survival) ovarianfit <- coxph(Surv(futime, fustat) ~ age + resid.ds + rx + ecog.ps, data=ovarian,x=T) # Compute the contribution of age and ECOG performance status to # the explained relative risk. Age and ECOG performance status are # the first and fourth covariates in the model. coxphERR(ovarianfit, c(1,4)) ``` -------------------------------- ### Example: Explained Relative Risk for Cox Model (Full Model) Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Demonstrates calculating the full explained relative risk (ERR) and its standard error using `coxphERR` with the `ovarian` dataset. The model is fitted with `x=T`. ```R library(survival) ovarianfit <- coxph(Surv(futime, fustat) ~ age + resid.ds + rx + ecog.ps, data=ovarian,x=T) # Compute the explained relative risk (ERR) and # its standard error (se.ERR) for the full model. coxphERR(ovarianfit) ``` -------------------------------- ### Jonckheere-Terpstra Test Examples Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Demonstrates the jonckheere.test function for ordered alternatives, including handling tied data and specifying permutations. Requires no specific imports. ```R set.seed(1234) g <- rep(1:5, rep(10,5)) x <- rnorm(50) jonckheere.test(x+0.3*g, g) x[1:2] <- mean(x[1:2]) # tied data jonckheere.test(x+0.3*g, g) jonckheere.test(x+0.3*g, g, nperm=5000) ``` -------------------------------- ### Normal Data Group Sequential Design Example Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Example of using gsdesign.normal for normal data. The first call uses a two-sided alternative and specifies a futility boundary, while the second uses a one-sided alternative with a lower significance level. ```R gsdesign.normal(1:4/4, 0.25, sig.level=0.05, alt="t", delta.fb=0.5) gsdesign.normal(1:4/4, 0.25, sig.level=0.025, alt="o", delta.fb=0.5) ``` -------------------------------- ### Get Boundary for Sequential Designs Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Determines the boundary for sequential clinical trial designs. This function is used internally and not typically called directly by the user. ```R getBoundary(pLo, pHi, n, cP0=0.1, cP1=0.9, ngrid=6, niter=10, delta=0, priorityNull=TRUE) ``` -------------------------------- ### Initialize clinfun Package Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Loads the clinfun library. Ensure this is run before using any functions from the package. ```r library(clinfun) ``` -------------------------------- ### Plotting and Cox Proportional Hazards Model with clinfun Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Demonstrates plotting survival data and fitting a Cox proportional hazards model using the survival package, followed by using coxphQuantile from clinfun for quantile estimation. ```R library(survival) data(pbc) pbcfit <- coxph(Surv(time, status==2) ~ trt + log(copper), pbc, subset=(trt>0 & copper>0)) plot(log(pbc$copper[pbc$trt>0 & pbc$copper>0]), pbc$time[pbc$trt>0 & pbc$copper>0], pch=c("o","x")[1+pbc$status[pbc$trt>0 & pbc$copper>0]], xlab="log Copper", ylab="Survival time") coxphQuantile(pbcfit, c(2.5,6), whichx=2, otherx=1) coxphQuantile(pbcfit, c(2.5,6), p=0.75, whichx=2, otherx=2, col=2) ``` -------------------------------- ### Calculate Selection Probabilities with pselect Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Demonstrates various uses of the pselect function for calculating selection probabilities under different scenarios, including type I error, differing probabilities, and unequal sample sizes. ```r # selection when no diffrence i.e. type I error pselect(18, c(0.2, 0.2, 0.2)) # selection probability pselect(18, c(0.2, 0.2, 0.4)) pselect(26, c(0.2, 0.2, 0.4), min.diff=2, min.resp=3) # unequal sample size case pselect(c(27,54), c(0.5, 0.65), min.diff=0.05) # unequal sample size case pselect(c(27,54), c(0.5, 0.65), min.diff=0.05, min.resp=c(14,27)) ``` -------------------------------- ### Calculate Two-Stage Simon Design Parameters Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Defines parameters for a two-stage Simon design, specifying null and alternative probabilities, and type I/II error rates. Use this to set up the trial's operating characteristics. ```r # Specify the parameters and constraints trial = ph2simon(0.05, 0.2, 0.1, 0.1) # Print trial ``` -------------------------------- ### print.futilbdry Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Prints the results of a futility boundary calculation. ```APIDOC ## print.futilbdry ### Description Prints the results of a futility boundary calculation. ### Usage ```R print(x, ...) ``` ### Arguments - `x`: Object returned by the function `futilbdry`. - `...`: Additional arguments to print. ``` -------------------------------- ### Simulate Two-Stage Phase II Designs Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Simulates two-stage Phase II clinical trial designs. Use to explore different scenarios for trial parameters. ```R ph2simon(0.2, 0.4, 0.1, 0.1) ph2simon(0.2, 0.35, 0.05, 0.05) ph2simon(0.2, 0.35, 0.05, 0.05, nmax=150) ``` -------------------------------- ### Admissible Two-Stage Design Options Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Lists admissible two-stage design options based on the output of ph2simon. Use to find designs that balance efficacy and toxicity considerations. ```R oo = ph2simon(0.5, 0.7, 0.05, 0.1) twostage.admissible(oo) ``` -------------------------------- ### futilbdry Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Computes a stopping rule and its operating characteristics for futility monitoring. ```APIDOC ## futilbdry ### Description Computes a stopping rule and its operating characteristics for futility monitoring. ### Usage ```R futilbdry(rLo, rHi, n, size=0.1, power=0.9, ngrid=3, niter=10, delta=0.5) ``` ### Arguments - `rLo` (numeric): Baseline (null) response rate. - `rHi` (numeric): Desirable response rate. Stop when it is too unlikely. - `n` (numeric vector): Vector of times (sample size) when response is monitored. - `size` (numeric, optional): Probability of calling drug effective if response rate is `rLo`. Defaults to 0.1. - `power` (numeric, optional): Probability of calling drug effective if response rate is `rHi`. Defaults to 0.9. - `ngrid` (integer, optional): The number of response rates from `rLo` to `rHi` for which the operating characteristics are computed. Defaults to 3. - `niter` (integer, optional): The number of iterations run to obtain the boundary. Defaults to 10. - `delta` (numeric, optional): Power determining the shape of the boundary. Should be between 0 and 0.5. Defaults to 0.5. ### Details For futility monitoring, instead two sets of probabilities - `pstop` and `peffective` - are given corresponding to the probability of stopping early for futility and probability of finishing the trial and declaring it a success. Note that `peffective` is the complement of `pcross` in toxicity monitoring. The futility boundary can have a -1 in earlier looks which means that even zero responses is not sufficient for stopping at that look. Default values of `delta` for futility stopping is 0.5. ``` -------------------------------- ### Sample Size Calculation using Casagrande, Pike, Smith (CPS.ssize) Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates sample size using the CPS approximation, which is suitable for small differences between proportions (large sample sizes) and provides instantaneous results. ```R CPS.ssize(p1, p2, alpha=0.05, power=0.8, r=1) ``` -------------------------------- ### Calculate Single-Stage Trial Parameters Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Defines and prints the parameters for a single-stage clinical trial. This function is used for simpler trial designs. ```r # Specify the parameters and constraints & print ph2single(0.4, 0.6, 0.1, 0.1) ``` -------------------------------- ### ktau Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates Kendall's tau-b estimate, providing a faster algorithm than the default cor() method. ```APIDOC ## Kendall's tau-b estimate ### Description Calculates the Kendall's tau-b. ### Usage ```R ktau(x, y) ``` ### Arguments `x` | first variable ---|--- `y` | second variable ### Details `ktau` computes the same quantity as `cor(x, y, method="kendall")`. It uses a faster algorithm than pairwise comparisons used by `cor`. ### Value `ktau` returns Kendall's tau-b. ### Examples ```R set.seed(1234) x <- rnorm(10000); y <- x+rnorm(10000) cor(x, y, method="k") clinfun:::ktau(x,y) ``` ``` -------------------------------- ### print.toxbdry Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Prints the results of a toxicity boundary calculation. ```APIDOC ## print.toxbdry ### Description Prints the results of a toxicity boundary calculation. ### Usage ```R print(x, ...) ``` ### Arguments - `x`: Object returned by the function `toxbdry`. - `...`: Additional arguments to print. ``` -------------------------------- ### Kendall's Tau-b Estimate Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates Kendall's tau-b, an alternative to cor(x, y, method="kendall"). Uses a faster algorithm than pairwise comparisons. Requires no specific imports. ```R set.seed(1234) x <- rnorm(10000); y <- x+rnorm(10000) cor(x, y, method="k") clinfun:::ktau(x,y) ``` -------------------------------- ### Obtain Admissible Two-Stage Simon Design Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Calculates and returns an admissible design for a two-stage Simon trial based on predefined parameters. This is used to find optimal trial configurations. ```r # Obtain admissible design twostage.admissible(trial) ``` -------------------------------- ### Futility Boundary Calculation Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Computes a stopping rule for futility monitoring. Requires baseline and desirable response rates, and sample sizes for monitoring. The 'delta' parameter influences the boundary shape. ```R futilbdry(rLo, rHi, n, size=0.1, power=0.9, ngrid=3, niter=10, delta=0.5) ``` -------------------------------- ### ph2simon Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates Optimal and Minimax 2-stage Phase II clinical trial designs based on Simon's methodology. ```APIDOC ## Simon's 2-stage Phase II design ### Description Calculates Optimal and Minimax 2-stage Phase II designs given by Richard Simon ### Usage ```R ph2simon(pu, pa, ep1, ep2, nmax=100) ## S3 method for class 'ph2simon' print(x, ...) ## S3 method for class 'ph2simon' plot(x, ...) ``` ### Arguments `pu` | unacceptable response rate; baseline response rate that needs to be exceeded for treatment to be deemed promising ---|--- `pa` | response rate that is desirable; should be larger than pu `ep1` | threshold for the probability of declaring drug desirable under pu (target type 1 error rate); between 0 and 1 `ep2` | threshold for the probability of rejecting the drug under pa (target type 2 error rate); between 0 and 1 `nmax` | maximum total sample size (default 100; can be at most 1000) `x` | object returned by ph2simon `...` | arguments to be passed onto plot and print commands called within ### Value `ph2simon` returns a list with pu, pa, alpha, beta and nmax as above and: `out` | matrix of best 2 stage designs for each value of total sample size n. The 6 columns in the matrix are: | r1 | number of responses needed to exceeded in first stage ---|--- n1 | number of subjects treated in first stage r | number of responses needed to exceeded at the end of trial n | total number of subjects to be treated in the trial EN(pu) | expected number pf patients in the trial under pu PET(pu) | probability of stopping after the first stage under pu Trial is stopped early if <= r1 responses are seen in the first stage and treatment is considered desirable only when >r responses seen. ### Methods (by generic) * `print(ph2simon)`: formats and returns the minimax, optimal and any admissible designs. * `plot(ph2simon)`: plots the expected sample size against the maximum sample size as in Jung et al., 2001 ``` -------------------------------- ### Simon's 2-stage Phase II Design Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates Optimal and Minimax 2-stage Phase II designs. Requires unacceptable and desirable response rates, and thresholds for type I and II error rates. An optional maximum sample size can be specified. ```R ph2simon(pu, pa, ep1, ep2, nmax=100) ``` -------------------------------- ### Sample Size Calculation for Fisher's Exact Test (fe.ssize) Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates sample size for comparing two binomial proportions using Fisher's exact test. It returns a matrix with sample sizes for both CPS and Fisher's exact methods. ```R fe.ssize(p1, p2, alpha=0.05, power=0.8, r=1, npm=5, mmax=1000) ``` -------------------------------- ### Inference for Two-Stage Binary Response Design Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates p-value, UMVUE, and confidence intervals for data from a two-stage design. Use for hypothesis testing and estimation after a study. ```R twostage.inference(x, r1, n1, n, pu, alpha=0.05) ``` -------------------------------- ### Plot Two-Stage Simon Design Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Generates a plot visualizing the operating characteristics of a two-stage Simon design. This helps in understanding the trial's performance. ```r # Plot plot(trial) ``` -------------------------------- ### Group Sequential Design - Constant Boundary Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates parameters for a group sequential design with a constant efficacy boundary. It requires the fraction of information and the desired error probabilities. ```R gsd.bdryconstant(ifrac, eprob = 0.05, delta = 0.5, alternative = c("two.sided", "one.sided"), tol = 0.00001, ...) ``` -------------------------------- ### Group Sequential Designs Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Functions to calculate sample size for group sequential designs. ```APIDOC ## Group Sequential Designs ### Description Functions to calculate sample size for group sequential designs ``` -------------------------------- ### Group Sequential Design - Drift Both Efficacy and Futility Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates parameters for a group sequential design considering drift in both efficacy and futility. This is useful for complex trial designs. ```R gsd.drift.both(ifrac, delta.eb, delta.fb, sig.level = 0.05, pow=0.8, alternative = c("two.sided", "one.sided"), tol = 0.00001, ...) ``` -------------------------------- ### Create Smoothed MRC Object Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Constructs a smoothed MRC object, likely for use in non-parametric modeling. Requires coefficients, design matrix, sample sizes, and a bandwidth parameter. ```R smmrcobj(coefs, xmat, n, nn, bw) ``` -------------------------------- ### permlogrank Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Performs a small sample survival difference test using permutation reference distributions, serving as the permutation version of survdiff. ```APIDOC ## Permutation version of survdiff ### Description Small sample survdiff using permutation reference distributions. ### Usage ```R permlogrank(formula, data, subset, na.action, rho=0, nperm=5000) ``` ### Arguments `nperm` | number of permutations for the reference distribution ---|--- `formula`, `data`, `subset`, `na.action`, `rho` | see survdiff for details ### Details `permlogrank` is the permutation version of k-sample survdiff. see survdiff in survival package for details. ### References Heller G, Venkatraman ES. (1996). Resampling procedures to compare two survival distributions in the presence of right censored data. _Biometrics_ 52:1204-1213. ``` -------------------------------- ### Trial Designs Based On Fisher's Exact Test Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Functions to calculate sample size, effect size, and power based on Fisher's exact test and other related methods. ```APIDOC ## Trial Designs Based On Fisher's Exact Test ### Description Calculates sample size, effect size and power based on Fisher's exact test ### Usage ``` fe.ssize(p1, p2, alpha=0.05, power=0.8, r=1, npm=5, mmax=1000) CPS.ssize(p1, p2, alpha=0.05, power=0.8, r=1) fe.mdor(ncase, ncontrol, pcontrol, alpha=0.05, power=0.8) mdrr(n, cprob, presp, alpha=0.05, power=0.8, niter=15) fe.power(d, n1, n2, p1, alpha = 0.05) or2pcase(pcontrol, OR) ``` ### Arguments `p1` | response rate of standard treatment ---|--- `p2` | response rate of experimental treatment `d` | difference = p2-p1 `pcontrol` | control group probability `n1` | sample size for the standard treatment group `n2` | sample size for the standard treatment group `ncontrol` | control group sample size `ncase` | case group sample size `alpha` | size of the test (default 5%) `power` | power of the test (default 80%) `r` | treatments are randomized in 1:r ratio (default r=1) `npm` | the sample size program searches for sample sizes in a range (+/- npm) to get the exact power `mmax` | the maximum group size for which exact power is calculated `n` | total number of subjects `cprob` | proportion of patients who are marger positive `presp` | probability of response in all subjects `niter` | number of iterations in binary search `OR` | odds-ratio ### Details CPS.ssize returns Casagrande, Pike, Smith sample size which is a very close to the exact. Use this for small differences p2-p1 (hence large sample sizes) to get the result instantaneously. Since Fisher's exact test orders the tables by their probability the test is naturally two-sided. fe.ssize return a 2x3 matrix with CPS and Fisher's exact sample sizes with power. fe.mdor return a 3x2 matrix with Schlesselman, CPS and Fisher's exact minimum detectable odds ratios and the corresponding power. fe.power returns a Kx2 matrix with probabilities (p2) and exact power. mdrr computes the minimum detectable P(resp|marker+) and P(resp|marker-) configurations when total sample size (n), P(response) (presp) and proportion of subjects who are marker positive (cprob) are specified. or2pcase give the probability of disease among the cases for a given probability of disease in controls (pcontrol) and odds-ratio (OR). ### References Casagrande, JT., Pike, MC. and Smith PG. (1978). An improved approximate formula for calculating sample sizes for comparing two binomial distributions. _Biometrics_ 34, 483-486. Fleiss, J. (1981) Statistical Methods for Rates and Proportions. Schlesselman, J. (1987) Re: Smallest Detectable Relative Risk With Multiple Controls Per Case. _Am. J. Epi._ ``` -------------------------------- ### Create MRC Object Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Constructs an MRC (Marginal Regression Coefficients) object from coefficients, design matrix, and sample sizes. This is an internal function. ```R mrcobj(coefs, xmat, n, nn) ``` -------------------------------- ### Exact Null Distribution Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates the exact null distribution for a given group size and keyword. ```R exactNull(gsize, kw) ``` -------------------------------- ### Calculate Probability of Selection Under Pick the Winner Rule Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates the probability of selecting the treatment with the higher response rate using the pick the winner rule. Can handle single or unequal sample sizes per arm. ```R pselect(n, p, min.diff=NULL, min.resp=NULL) ``` -------------------------------- ### bdrycross.prob Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates the probability of boundary crossing for futility monitoring. ```APIDOC ## bdrycross.prob ### Description Computes the probability of boundary crossing for futility monitoring. ### Usage ```R bdrycross.prob(n, r, ptox) ``` ### Arguments - `n` (numeric vector): Vector of times (sample size) when toxicity/response is monitored. - `r` (numeric vector): Vector of maximum acceptable toxicities (non-responders for futility) corresponding to `n`. - `ptox` (numeric vector): The toxicity rates for which the operating characteristics are calculated. For futility this is the non-response rate. ``` -------------------------------- ### Toxicity Boundary Calculation Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Computes a stopping rule for toxicity monitoring based on repeated significance testing. Requires acceptable and unacceptable toxicity rates, and sample sizes for monitoring. ```R toxbdry(pLo, pHi, n, cP0=0.1, cP1=0.9, ngrid=6, niter=10, delta=0, priority=c("null","alt")) ``` -------------------------------- ### Group Sequential Design Functions for Clinfun Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html These functions are used to design group sequential clinical trials. They allow specification of information fractions, treatment effects, and desired statistical properties like significance level and power. Use these for planning trials where interim analyses are planned. ```R gsdesign.binomial(ifrac, pC, pE, r = 1, sig.level = 0.05, power = 0.8, delta.eb=0.5, delta.fb = NULL, alternative = c("two.sided", "one.sided"), pooled.variance = FALSE, CPS = TRUE, tol=0.00001, ...) gsdesign.normal(ifrac, delta, sd = 1, r = 1, sig.level = 0.05, power = 0.8, delta.eb = 0.5, delta.fb = NULL, alternative = c("two.sided", "one.sided"), tol=0.00001, ...) gsdesign.survival(ifrac, haz.ratio, r = 1, sig.level = 0.05, power = 0.8, delta.eb = 0.5, delta.fb = NULL, alternative = c("two.sided", "one.sided"), tol=0.00001, ...) ``` -------------------------------- ### Recalculate Admissible Two-Stage Simon Design Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Redefines parameters for a two-stage Simon design and then obtains an admissible design. This is useful for exploring different parameter settings. ```r # Specify the parameters and constraints trial = ph2simon(0.25, 0.45, 0.05, 0.1) # Obtain admissible design twostage.admissible(trial) ``` -------------------------------- ### Permutation Version of survdiff Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Performs a small sample survival difference test using permutation reference distributions. It is the permutation version of k-sample survdiff from the survival package. Requires formula and data inputs, with optional arguments for subset, na.action, rho, and nperm. ```R permlogrank(formula, data, subset, na.action, rho=0, nperm=5000) ``` -------------------------------- ### Two-stage Boundary Operating Characteristics Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates the operating characteristics of a two-stage boundary. Requires parameters for unacceptable and desirable response rates, thresholds, and sample sizes. ```R oc.twostage.bdry(pu, pa, r1, n1, r, n) ``` -------------------------------- ### Convert Odds Ratio to Probability of Case Disease (or2pcase) Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Converts an odds ratio to the probability of disease among cases, given the probability of disease in controls. ```R or2pcase(pcontrol, OR) ``` -------------------------------- ### Calculate Proportion Power Test Sample Size Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Performs a power and sample size calculation for a two-sample proportion test. Specify the proportions under the null and alternative hypotheses, and the desired power. ```r power.prop.test(p1 = 0.2, p2 = 0.3, power = 0.8) ``` -------------------------------- ### toxbdry Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Computes a stopping rule and its operating characteristics for toxicity monitoring based on repeated significance testing. ```APIDOC ## toxbdry ### Description Computes a stopping rule and its operating characteristics for toxicity monitoring based repeated significance testing. ### Usage ```R toxbdry(pLo, pHi, n, cP0=0.1, cP1=0.9, ngrid=6, niter=10, delta=0, priority=c("null","alt")) ``` ### Arguments - `pLo` (numeric): The toxicity rate that is acceptable. - `pHi` (numeric): The toxicity rate that is too high and hence unacceptable. - `n` (numeric vector): Vector of times (sample size) when toxicity is monitored. - `cP0` (numeric, optional): Boundary crossing probability under `pLo` (type I error). Defaults to 0.1. - `cP1` (numeric, optional): Boundary crossing probability under `pHi` (power). Defaults to 0.9. - `ngrid` (integer, optional): The number of toxicity rates from `pLo` to `pHi` for which the operating characteristics are computed. Defaults to 6. - `niter` (integer, optional): The number of iterations run to obtain the boundary. Defaults to 10. - `delta` (numeric, optional): Power determining the shape of the boundary. Should be between 0 (default) and 0.5. Defaults to 0. - `priority` (character vector, optional): The error threshold to prioritize when the max sample size is too small to have both error thresholds satisfied. Default is the null i.e. error under `pLo`. Defaults to c("null","alt"). ### Details The shape parameter `delta` is used to determine the stopping boundary with 0 corresponding to the Pocock boundary where the same significance level is used for all looks and 0.5 corresponding to the O'Brien-Fleming boundary which has smaller probability of stopping at early looks. Default value of `delta` for toxicity monitoring is 0; value between 0.1 and 0.2 is a reasonable choice to make it less likely to stop early. For toxicity monitoring two sets of probabilities - `pstop` and `pcross` - are given which correspond to probability of stopping early and probability of declaring the treatment too toxic with the full complement of study subjects accrued and treated. ``` -------------------------------- ### Group Sequential Design - General Drift Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html A general function for group sequential designs that accounts for drift. It can handle various scenarios including efficacy and futility drift. ```R gsd.drift(ifrac, sig.level = 0.05, pow = 0.8, delta.eb = 0.5, delta.fb = NULL, alternative = c("two.sided", "one.sided"), tol = 0.00001, ...) ``` -------------------------------- ### Calculate Exact Single Stage Phase II Design Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates the exact one-stage Phase II clinical trial design. Specify unacceptable and desirable response rates along with probability thresholds. ```R ph2single(pu,pa,ep1,ep2,nsoln=5) ``` -------------------------------- ### oc.twostage.bdry Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates the operating characteristics of a two-stage boundary for clinical trials. ```APIDOC ## Two-stage boundary operating characteristics ### Description Calculates the operating characteristics of a two-stage boundary. ### Usage ```R oc.twostage.bdry(pu, pa, r1, n1, r, n) ``` ### Arguments `pu` | unacceptable response rate ---|--- `pa` | response rate that is desirable `r1` | first stage threshold to declare treatment undesirable `n1` | first stage sample size `r` | overall threshold to declare treatment undesirable `n` | total sample size ### Value `oc.twostage.bdry` returns the type I and II error rates as well as the probability of early temination and expected sample size under `pu` for a specific boundary. ``` -------------------------------- ### jonckheere.test Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Performs the exact Jonckheere-Terpstra test for ordered alternatives. Handles ties and provides permutation p-values when exact calculation is not possible. ```APIDOC ## jonckheere.test ### Description Performs the exact Jonckheere-Terpstra test. ### Details `jonckheere.test` is the exact (permutation) version of the Jonckheere-Terpstra test. It uses the statistic \(\\sum_{kr respenses seen. ``` -------------------------------- ### Minimum Detectable Relative Risk (mdrr) Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Computes the minimum detectable probability of response for marker-positive and marker-negative subjects given total sample size, overall response probability, and proportion of marker-positive subjects. ```R mdrr(n, cprob, presp, alpha=0.05, power=0.8, niter=15) ``` -------------------------------- ### Calculate Fixed-Outcome Sample Size Source: https://cran.r-project.org/web/packages/clinfun/vignettes/clinical-trial-functions.R Computes the required sample size for a fixed-outcome trial based on two proportions, a desired power, and a significance level. This is a common calculation for planning study size. ```r fe.ssize(p1 = 0.2, p2 = 0.3, power = 0.8) ``` -------------------------------- ### Exact Power Calculation for Fisher's Exact Test (fe.power) Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Calculates the exact power of Fisher's exact test for a given difference in proportions, sample sizes, and significance level. ```R fe.power(d, n1, n2, p1, alpha = 0.05) ``` -------------------------------- ### twostage.inference Source: https://cran.r-project.org/web/packages/clinfun/refman/clinfun.html Performs statistical inference for a two-stage clinical trial design. It calculates p-values, Uniformly Minimum Variance Unbiased Estimators (UMVUE), and confidence intervals for the response rate. ```APIDOC ## Inference following a two-stage design for binary response ### Description Calculates the p-value, UMVUE and CI for the data from a study using a two stage design for response. ### Usage twostage.inference(x, r1, n1, n, pu, alpha=0.05) ### Arguments `x` | number of responses observed at the end of the study `r1` | first stage threshold to declare treatment undesirable `n1` | first stage sample size `n` | total sample size `pu` | unacceptable response rate (null hypothesis) `alpha` | the confidence level. For consistency with the design use the same value from the design. (default is 0.05) ### Value twostage.inference returns the UMVUE (Jung & Kim, 2004), p-value and CI (Koyama & Chen, 2008). The CI has confidence level 1-2*alpha and the one-sided (1-alpha) interval consistent with the design is obtained by changing the upper confidence limit (UCL) to 1. ### References Jung SH and Kim KM. (2004). On the estimation of the binomial probability in multistage clinical trials. _Statistics in Medicine_ 23, 881-896. Koyama T and Chen H. (2008). Proper inference from Simon's two-stage designs. _Statistics in Medicine_ 27, 3145-3154. ```