| Title: | Creates Group Sequential Trial Designs when Early Outcomes are Available |
|---|---|
| Description: | Methods to construct and power group sequential clinical trial designs for outcomes at multiple times. Outcomes at earlier times provide information on the final (primary) outcome. A range of recruitment and correlation models are available as are methods to simulate data in order to explore design operating characteristics. For more details see Parsons (2024) <doi:10.1186/s12874-024-02174-w>. |
| Authors: | Nick Parsons [aut, cre] (ORCID: <https://orcid.org/0000-0001-9975-888X>) |
| Maintainer: | Nick Parsons <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0.0 |
| Built: | 2026-05-12 08:46:25 UTC |
| Source: | https://github.com/cran/gsearly |
Functions to implement group sequential clinical trial designs with early outcomes. Group sequential designs are one of the most widely used methodologies for adaptive design in randomized clinical trials. In such designs researchers collect data and undertake sequential analyses with the opportunity to either reject the null hypothesis, stop the study for futility or continue recruitment at an interim look, before reaching the planned sample size.
In situations where, for instance, outcomes are collected at long follow-up time-points, data at interim analyses are often available for not only the study primary (long-term) outcome time-point but also from early time-points for the same outcome (early outcomes); e.g. a primary outcome at 12 months and early outcomes at 3, 6 and 9 months. In settings where moderate to strong correlations exist between the sequence of such outcomes, information can be used from the early outcomes in addition to the final outcome at the interim analyses. The design, planning and sample size determination for such studies is more complex than for conventional group sequential designs and is generally achieved by simulating individual participant data for an assumed recruitment pattern as a means to determine information accrual during a proposed trial.
However, in practice, such simulations are complex and time-consuming to set-up and implement and provide a barrier to the use of group sequential designs. If we can assume approximate multivariate Normality for the distribution of the outcomes, and also make some assumptions about the expected correlation structure and recruitment patterns, then we can derive relatively simple analytic expressions for information accrual during a planned trial. Allowing a range of design options to be explored routinely without the burden of undertaking extensive simulation studies.
The two main functions (i) gsearlyModel and (ii)
gsearlyUser allow designs to be constructed based on a range of
typical clinical trial recruitment patterns and correlation models.
The function gsearlySimulate simulates multivariate Normal
datasets based on a previously fitted gsearly model.
Parsons NR, Basu J, Stallard N. Group sequential designs for pragmatic clinical
trials with early outcomes: methods and guidance for planning and
implementation. BMC Medical Research Methodology 2024; 24:42.
https://wrap.warwick.ac.uk/id/eprint/183449/
Parsons NR, Stallard N, Parsons H, Haque A, Underwood M, Mason J, Khan I,
Costa ML, Griffin DR, Griffin J, Beard DJ, Cook JA, Davies L, Hudson J,
Metcalfe A. Group sequential designs in pragmatic trials: feasibility and
assessment of utility using data from a number of recent surgical RCTs.
BMC Medical Research Methodology 2022; 22:256.
https://wrap.warwick.ac.uk/id/eprint/169801/
gsearlyModel, gsearlyUser,
gsearlySimulate
Constructs an exponential correlation matrix.
corrExp(rho=0, tfu)corrExp(rho=0, tfu)
rho |
Correlation parameter. |
tfu |
Follow-up time points, in standardized format from function
|
Returns an s x s correlation matrix. Where s is the number
of occasions (follow-up time points) at which the study outcome is observed.
# Exponential correlation model for outcomes at 3, 6, 12 and 24 months # Based on correlation 0.5 between outcomes separated by 3 month corrExp(0.5, tfuStandard(c(3,6,12,24), tref=c(1,2))) # Based on correlation 0.25 between outcomes separated by 1 year corrExp(0.25, tfuStandard(c(3,6,12,24), tref=c(3,4)))# Exponential correlation model for outcomes at 3, 6, 12 and 24 months # Based on correlation 0.5 between outcomes separated by 3 month corrExp(0.5, tfuStandard(c(3,6,12,24), tref=c(1,2))) # Based on correlation 0.25 between outcomes separated by 1 year corrExp(0.25, tfuStandard(c(3,6,12,24), tref=c(3,4)))
Constructs a uniform correlation matrix.
corrUnif(rho=0, tfu)corrUnif(rho=0, tfu)
rho |
Correlation parameter. |
tfu |
Follow-up time points, in standardized format from function
|
Returns an s x s correlation matrix. Where s is the number
of occasions (follow-up time points) at which the study outcome is observed.
# Uniform correlation model for outcomes at 3, 6, 12 and 24 months # Settings for tref argument of standardtfu do not change correlation matrix corrUnif(0.5, tfuStandard(c(3,6,12,24), tref=c(1,2))) # Based on correlation 0.5 between outcomes separated by 1 year corrUnif(0.5, tfuStandard(c(3,6,12,24), tref=c(3,4)))# Uniform correlation model for outcomes at 3, 6, 12 and 24 months # Settings for tref argument of standardtfu do not change correlation matrix corrUnif(0.5, tfuStandard(c(3,6,12,24), tref=c(1,2))) # Based on correlation 0.5 between outcomes separated by 1 year corrUnif(0.5, tfuStandard(c(3,6,12,24), tref=c(3,4)))
Orders a user supplied data frame by subject and ordered time variable.
dataOrder(data, datanames=c("id","atime","catime", "intervention","outcome"))dataOrder(data, datanames=c("id","atime","catime", "intervention","outcome"))
data |
A data frame structured as those from function
|
datanames |
Names of the five required data variables; participant
identifier, time-point, standardized (continuous) time-point (see
|
Returns an ordered data frame.
data(qol) oqol <- dataOrder(qol,datanames=c("Subject","Weeks","STime","Treat","QoL")) head(qol, n=50)data(qol) oqol <- dataOrder(qol,datanames=c("Subject","Weeks","STime","Treat","QoL")) head(qol, n=50)
Calculates the expected sample size for a fitted gsearly model,
from functions gsearlyModel or gsearlyUser.
expectSampsize(mod, signif=3)expectSampsize(mod, signif=3)
mod |
A gsearly model. |
signif |
Rounds the sample size to the specified number of significant digits. |
Returns the sample size for the control and treatment groups and total.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0010,0.0100,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) expectSampsize(rctdesign)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0010,0.0100,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) expectSampsize(rctdesign)
Calculates the fixed model sample size, assuming no correlation
between early and final outcomes, for a fitted gsearly model, from functions
gsearlyModel or gsearlyUser.
fixedSampsize(mod, pow=NULL, direct="u", signif=3)fixedSampsize(mod, pow=NULL, direct="u", signif=3)
mod |
A gsearly model. |
pow |
Power is set to a value between 0 and 1, or if unset is taken from
|
direct |
Rounds sample sizes to nearest integer, upwards |
signif |
Rounds power to the specified number of significant digits. |
Returns a list with the following items.
n |
Sample size for the control and treatment groups and total. |
power |
Study power. |
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) fixedSampsize(rctdesign)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) fixedSampsize(rctdesign)
Fits a generalized least squares model using function gls
(from package nlme)
gsearlyFit(data, datanames = c("id","atime","catime", "intervention","outcome"), cmodel=FALSE, vmodel=TRUE, full=FALSE)gsearlyFit(data, datanames = c("id","atime","catime", "intervention","outcome"), cmodel=FALSE, vmodel=TRUE, full=FALSE)
data |
A data frame structured as function |
datanames |
Names of the five required data variables; participant,
time-point, standardized (continuous) time-point (see
|
cmodel |
The correlation model is set to |
vmodel |
The variance model is set to either |
full |
Either |
Either a gls model (full=TRUE) or a summary of the model fit
(full=FALSE), which is a list with the components.
parameters |
Estimates of variance of beta (vbeta), beta and z (z=beta/sqrt(vbeta)). |
model |
A list comprised of data sample size N, number of estimated
|
gsearlySimulate, simdataExtract,
modelParameters
# Model for full data set data(qol) mod.fulldata <- nlme::gls(QoL~(Weeks-1)+(Weeks-1):Treat, data=qol, correlation=nlme::corSymm(form=~1|Subject), weights=nlme::varIdent(form =~1|Weeks), method="ML") summary(mod.fulldata) # Use data available at day 150 data.interim1 <- qol[qol$Day<=150,] mod.interim1 <- nlme::gls(QoL~(Weeks-1)+(Weeks-1):Treat, data=data.interim1, correlation=nlme::corSymm(form=~1|Subject), weights=nlme::varIdent(form=~1|Weeks), method="ML") summary(mod.interim1) # Use glsFit gsearlyFit(qol, datanames=c("Subject","Weeks","STime","Treat","QoL")) # vbeta vcov(mod.fulldata)[6,6] # beta coef(mod.fulldata)[6]# Model for full data set data(qol) mod.fulldata <- nlme::gls(QoL~(Weeks-1)+(Weeks-1):Treat, data=qol, correlation=nlme::corSymm(form=~1|Subject), weights=nlme::varIdent(form =~1|Weeks), method="ML") summary(mod.fulldata) # Use data available at day 150 data.interim1 <- qol[qol$Day<=150,] mod.interim1 <- nlme::gls(QoL~(Weeks-1)+(Weeks-1):Treat, data=data.interim1, correlation=nlme::corSymm(form=~1|Subject), weights=nlme::varIdent(form=~1|Weeks), method="ML") summary(mod.interim1) # Use glsFit gsearlyFit(qol, datanames=c("Subject","Weeks","STime","Treat","QoL")) # vbeta vcov(mod.fulldata)[6,6] # beta coef(mod.fulldata)[6]
Provides sample sizes and power for group sequential designs with early outcomes defined by a recruitment and correlation model, recruitment period and interim analysis time-points.
gsearlyModel(rmodel="fix", trecruit, s, tfu, tinterims, pow=0.9, n=NULL, theta, tref=c(1,2), vphi=0.5, m=2, cmodel="uniform", sd=1, rho=0.5, fp, tn, treatnames=c("control", "treat"), sopt=list(r=18, bisect=list(min=20, max=10000, niter=1000, tol=0.001)))gsearlyModel(rmodel="fix", trecruit, s, tfu, tinterims, pow=0.9, n=NULL, theta, tref=c(1,2), vphi=0.5, m=2, cmodel="uniform", sd=1, rho=0.5, fp, tn, treatnames=c("control", "treat"), sopt=list(r=18, bisect=list(min=20, max=10000, niter=1000, tol=0.001)))
rmodel |
Recruitment model, options are c( |
trecruit |
The recruitment period (an integer >1) which is used to define
the base units for all analyses and plotting functions (which are on a scale
of |
s |
The study outcome is observed at a sequence of |
tfu |
A vector of length |
tinterims |
A vector of ordered numeric interim analysis time-points, in
the same units as |
pow |
The study target power. If |
n |
The total study sample size (control + treatment groups). If this is
set to |
theta |
The treatment effect, in the same units as |
tref |
A vector of integers of length 2 that defines the correlation
parameter |
vphi |
A weight for unequal group sizes 0 < |
m |
A parameter (1 <= |
cmodel |
The correlation model is set to either |
sd |
The standard deviation (0 < |
rho |
The correlation parameter (0 <= |
fp |
A vector (of length |
tn |
A vector (of length |
treatnames |
Names used for the two study groups, referred to elsewhere
as the first (or 0) and second (or 1) groups, with default
|
sopt |
List of settings for the |
An object of class gsearly is a list containing the following components.
title |
Package title and version number. |
call |
Call to |
rdata |
A list of the recruitment model ( |
idata |
A list of the correlation model ( |
power |
A list of the total number of the looks ( |
expectSampsize, fixedSampsize,
roundInterims, corrExp, corrUnif
# RCT planning: # Recruitment is expected to take 36 months (trecruit) with three # follow-up times (s) for outcomes at 3, 6 and 12 months (tfu) and # interim analyses (tinterims) at 18 and 30 months. # Study procedures and experience suggest that "dilin" (m=2) is likely # to be a good approximation to temporal patterns of recruitment and data # accrual (rmodel). Correlations between outcomes at 3, 6 and 12 are # assumed to follow a uniform model (cmodel) with parameter (rho) set to 0.5. # Randomisation to the two study arms will be on a 1:1 basis (vphi=0.5). # The standard deviation of the final 12m outcome is expected to be 20, # and the anticipated treatment effect (theta) 8. # Primary interest for the RCT is in stopping early for futility. # Therefore the following values for the false positive and true # negative rates were selected. # Vectors of cumulative probabilities for crossing boundaries under the # null hypothesis (of no treatment difference). fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) # For 90 percent power (pow), a call to gsearlyModel provides a feasible design rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) rctdesign # If n is set, rather than pow, then we can explore power for lower n update(rctdesign, n=136) # Expected numbers of participants at interim analyses rctdesign$rdata$interims # Information at these interims and final analysis rctdesign$idata$interims # Upper and lower stopping boundaries and probabilities rctdesign$power$lowerror rctdesign$power$upperror# RCT planning: # Recruitment is expected to take 36 months (trecruit) with three # follow-up times (s) for outcomes at 3, 6 and 12 months (tfu) and # interim analyses (tinterims) at 18 and 30 months. # Study procedures and experience suggest that "dilin" (m=2) is likely # to be a good approximation to temporal patterns of recruitment and data # accrual (rmodel). Correlations between outcomes at 3, 6 and 12 are # assumed to follow a uniform model (cmodel) with parameter (rho) set to 0.5. # Randomisation to the two study arms will be on a 1:1 basis (vphi=0.5). # The standard deviation of the final 12m outcome is expected to be 20, # and the anticipated treatment effect (theta) 8. # Primary interest for the RCT is in stopping early for futility. # Therefore the following values for the false positive and true # negative rates were selected. # Vectors of cumulative probabilities for crossing boundaries under the # null hypothesis (of no treatment difference). fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) # For 90 percent power (pow), a call to gsearlyModel provides a feasible design rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) rctdesign # If n is set, rather than pow, then we can explore power for lower n update(rctdesign, n=136) # Expected numbers of participants at interim analyses rctdesign$rdata$interims # Information at these interims and final analysis rctdesign$idata$interims # Upper and lower stopping boundaries and probabilities rctdesign$power$lowerror rctdesign$power$upperror
Simulates multivariate Normal datasets based on a previously fitted
gsearly model (see gsearlyModel).
gsearlySimulate(mod, nsim=1, minsamp=c(1,1), mean=NULL, cmodel=NULL, sd=NULL, rho=NULL, full=FALSE)gsearlySimulate(mod, nsim=1, minsamp=c(1,1), mean=NULL, cmodel=NULL, sd=NULL, rho=NULL, full=FALSE)
mod |
A previously fitted model from function |
nsim |
Number of required simulated datasets. |
minsamp |
Simulations where numbers at the first interim are less than
|
mean |
A matrix of dimension |
cmodel |
Either a correlation model, |
sd |
The standard deviation of the outcome, that is assumed to be the same
in both arms. Either a single value or a vector of length |
rho |
Correlation parameter if cmodel is set to |
full |
Either FALSE, which provides model details and parameters only or TRUE which provides full details of numbers and datasets in addition to the model details. |
A list containing the following components.
model |
A list of model settings |
parameters |
A list of two matrices, comprising variances of beta (vbeta) and beta at each interim and final analysis. |
n |
A list of length 2 (control and treatment), each comprising of lists
of matrices (for recruitment and follow-up times) showing sample sizes at
each interim and final analysis for the |
data |
A list of length 2 (control and treatment), each comprising of a
list of length |
gsearlyModel, simdataExtract, modelParameters, gsearlyFit
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) # Simulate data from this model simdata <- gsearlySimulate(mod=modeldesign, nsim=10, full=FALSE) # Model parameters simdata$parameters # Change correlation model newsimdata <- gsearlySimulate(mod=modeldesign, nsim=10, cmodel="exponential", rho=0.75, full=FALSE) # Model parameters newsimdata$parameters# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) # Simulate data from this model simdata <- gsearlySimulate(mod=modeldesign, nsim=10, full=FALSE) # Model parameters simdata$parameters # Change correlation model newsimdata <- gsearlySimulate(mod=modeldesign, nsim=10, cmodel="exponential", rho=0.75, full=FALSE) # Model parameters newsimdata$parameters
Provides sample sizes and power for group sequential designs with early outcomes defined by a matrix of fixed numbers of participants with data for all outcomes (early and primary) at each interim time-point or a function that gives a similarly structured matrix for all sample sizes in a pre-set range and a correlation model or correlation matrix, recruitment period and interim analysis time-points.
gsearlyUser(trecruit, s, tfu, tinterims, ninterims, pow=0.9, n=NULL, tref=c(1,2), vphi=0.5, cmodel="uniform", sd=1, rho=0.5, theta, fp, tn, treatnames=c("control","treat"), sopt=list(r=18, bisect=list(min=20, max=10000, niter=1000, tol=0.001)))gsearlyUser(trecruit, s, tfu, tinterims, ninterims, pow=0.9, n=NULL, tref=c(1,2), vphi=0.5, cmodel="uniform", sd=1, rho=0.5, theta, fp, tn, treatnames=c("control","treat"), sopt=list(r=18, bisect=list(min=20, max=10000, niter=1000, tol=0.001)))
trecruit |
As for |
s |
As for |
tfu |
As for |
tinterims |
As for |
ninterims |
A matrix with |
pow |
As for |
n |
As for |
tref |
As for |
vphi |
As for |
cmodel |
Either a correlation model, |
sd |
As for |
rho |
As for |
theta |
As for |
fp |
As for |
tn |
As for |
treatnames |
As for |
sopt |
As for |
An object of class gsearly is a list containing the following components
title |
Package title and version number. |
call |
Call to |
rdata |
A list of same structure as for |
idata |
A list of same structure as for |
power |
A list of same structure as for |
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) modeldesign # This design can be replicated using gsearlyUser n <- modeldesign$rdata$n["total"] ninterims <- modeldesign$rdata$interims cmodel <- modeldesign$idata$cmodel$corrmat userdesign <- gsearlyUser(trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), ninterims=ninterims, n=n, vphi=0.5, cmodel=cmodel, sd=20, theta=8, fp=fp, tn=tn) userdesign # Expected numbers of participants at interim analyses modeldesign$rdata$interims userdesign$rdata$interims # Information at these interims and final analysis modeldesign$idata$interims userdesign$idata$interims # Upper and lower stopping boundaries and probabilities rbind(modeldesign$power$lowerror, modeldesign$power$upperror) rbind(userdesign$power$lowerror, userdesign$power$upperror) # Change correlation matrix and interim numbers cmodel <- matrix(c(1,0.2,0.1, 0.2,1,0.1, 0.1,0.1,1), nrow=3, byrow=TRUE) ninterims <- matrix(c(130,110,90,45, 200,175,160,120), nrow=2, byrow=TRUE) # For 90 percent power (pow), a call to gsearlyUser provides a feasible design nuserdesign <- gsearlyUser(trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), ninterims=ninterims, vphi=0.5, pow=0.9, cmodel=cmodel, sd=20, theta=8, fp=fp, tn=tn) nuserdesign# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) modeldesign # This design can be replicated using gsearlyUser n <- modeldesign$rdata$n["total"] ninterims <- modeldesign$rdata$interims cmodel <- modeldesign$idata$cmodel$corrmat userdesign <- gsearlyUser(trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), ninterims=ninterims, n=n, vphi=0.5, cmodel=cmodel, sd=20, theta=8, fp=fp, tn=tn) userdesign # Expected numbers of participants at interim analyses modeldesign$rdata$interims userdesign$rdata$interims # Information at these interims and final analysis modeldesign$idata$interims userdesign$idata$interims # Upper and lower stopping boundaries and probabilities rbind(modeldesign$power$lowerror, modeldesign$power$upperror) rbind(userdesign$power$lowerror, userdesign$power$upperror) # Change correlation matrix and interim numbers cmodel <- matrix(c(1,0.2,0.1, 0.2,1,0.1, 0.1,0.1,1), nrow=3, byrow=TRUE) ninterims <- matrix(c(130,110,90,45, 200,175,160,120), nrow=2, byrow=TRUE) # For 90 percent power (pow), a call to gsearlyUser provides a feasible design nuserdesign <- gsearlyUser(trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), ninterims=ninterims, vphi=0.5, pow=0.9, cmodel=cmodel, sd=20, theta=8, fp=fp, tn=tn) nuserdesign
Provides estimates of the variance of beta (vbeta) and beta, the treatment effect, directly from raw data and a user supplied covariance matrix.
modelParameters(data, datanames=c("id", "atime", "intervention", "outcome"), vcovmat)modelParameters(data, datanames=c("id", "atime", "intervention", "outcome"), vcovmat)
data |
A data frame structured as those from function
|
datanames |
Names of the four variables in the data frame |
vcovmat |
A covariance matrix of dimensions |
Returns the variance of beta (vbeta), beta and test statistic z.
gsearlySimulate, simdataExtract
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) # Simulate data from this model with raw data using full=TRUE simdata <- gsearlySimulate(mod=modeldesign, nsim=10, full=TRUE) # Extract raw data for a single simulation simdat1 <- simdataExtract(simdata, simn=1, tinterims=18, full=TRUE) # Get model parameters modelParameters(data=simdat1$data, vcovmat=simdat1$model$covariance) # Try alternative covariance model varmat <- diag(c(18,22,24)) vcovmat <- tcrossprod(crossprod(varmat,corrExp(rho=0.8, tfu=simdat1$model$tfu)),varmat) modelParameters(data=simdat1$data, vcovmat=vcovmat)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) # Simulate data from this model with raw data using full=TRUE simdata <- gsearlySimulate(mod=modeldesign, nsim=10, full=TRUE) # Extract raw data for a single simulation simdat1 <- simdataExtract(simdata, simn=1, tinterims=18, full=TRUE) # Get model parameters modelParameters(data=simdat1$data, vcovmat=simdat1$model$covariance) # Try alternative covariance model varmat <- diag(c(18,22,24)) vcovmat <- tcrossprod(crossprod(varmat,corrExp(rho=0.8, tfu=simdat1$model$tfu)),varmat) modelParameters(data=simdat1$data, vcovmat=vcovmat)
Plots data from a gsearly model constructed using either
gsearlyModel or gsearlyUser.
## S3 method for class 'gsearly' plot(x, plottype=1, ...)## S3 method for class 'gsearly' plot(x, plottype=1, ...)
x |
A gsearly model from function either |
plottype |
A value which is one of either 1 or |
... |
Further graphical parameters for lines and points. |
A plot of the selected type.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plot(rctdesign, "recruit")# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plot(rctdesign, "recruit")
A boundary plot for a gsearly model.
plotBoundary(mod, xlim=c(0,1), ylim=NA, xlab=NA, ylab=NA, title=NULL, col=1, lty=c(3, 3), pch=3, las=1, concol=grey(0.9), reglab=TRUE, signif=3, bounds=TRUE, pcol=1, labpos=c(2,2), ...)plotBoundary(mod, xlim=c(0,1), ylim=NA, xlab=NA, ylab=NA, title=NULL, col=1, lty=c(3, 3), pch=3, las=1, concol=grey(0.9), reglab=TRUE, signif=3, bounds=TRUE, pcol=1, labpos=c(2,2), ...)
mod |
A gsearly model from function |
xlim |
The |
ylim |
The |
xlab |
A label for the x axis; defaults to |
ylab |
A label for the y axis; defaults to
|
title |
A main title for the plot; default |
col |
Default plotting color for lines and points; default 1. |
lty |
A vector of line types for upper and lower boundaries; default
|
pch |
Plotting character or symbol for points; default 3. |
las |
A numeric value which is one of either 0, 1, 2 or 3; the style of axis labels, 0: always parallel to the axis, 1: always horizontal (default), 2: always perpendicular to the axis, 3: always vertical. |
concol |
Color for the continue region, default |
reglab |
Logical for plotting of region (Continue, Reject H0 and
Accept H0) labels; default |
signif |
Number of decimal places for the boundaries; default 3. |
bounds |
Logical for plotting boundary values; default |
pcol |
Color for region labels and points; default 1. |
labpos |
Position for upper and lower boundary values (if
|
... |
Further arguments to plot function. |
A plot of the selected type or a list consisting of interim information fractions and lower and upper boundaries.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotBoundary(rctdesign)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotBoundary(rctdesign)
An information or variance plot for a gsearly model.
plotInform(mod, xlim=NA, ylim=NA, xlab=NA, ylab=NA, title=NULL, col=1, lty=1, pch=3, las=1, tlag=c(0,0), wopcol=grey(0.9), intlab=NA, labpos=1, legpos="bottomleft", ptype="var", pcol=1, ...)plotInform(mod, xlim=NA, ylim=NA, xlab=NA, ylab=NA, title=NULL, col=1, lty=1, pch=3, las=1, tlag=c(0,0), wopcol=grey(0.9), intlab=NA, labpos=1, legpos="bottomleft", ptype="var", pcol=1, ...)
mod |
A gsearly model from function |
xlim |
The |
ylim |
The |
xlab |
A label for the x axis; defaults to |
ylab |
A label for the y axis; defaults to |
title |
A main title for the plot; default |
col |
Default plotting color for lines and points; default 1. |
lty |
Line type; default 1. |
pch |
Plotting character or symbol for points; 3 |
las |
A numeric value which is one of either 0, 1, 2 or 3; the style of axis labels, 0: always parallel to the axis, 1: always horizontal (default), 2: always perpendicular to the axis, 3: always vertical. |
tlag |
A vector of length 2, with positive values for time lags,
pre-recruitment and post-recruitment, over which to extend the plotted lines;
default |
wopcol |
Color for the window of opportunity region, default
|
intlab |
A vector of labels for the interim analyses; defaults to t[1],
t[2], etc. Set to |
labpos |
Position of interim labels; default 1 |
legpos |
Legend position is one of |
ptype |
Plot type, which is one of |
pcol |
Color for points; default 1. |
... |
Further arguments to plot function. |
A plot of the selected type or a list consisting of the plotted line and interim point data.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotInform(rctdesign)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotInform(rctdesign)
A power plot for a gsearly model.
plotPower(mod, xlim=NA, ylim=NA, xlab=NA, ylab=NA, title=NULL, col=c(1,2), lty=NA, pch=3, las=1, legpos=c("bottomright","topright"), xtype="theta", delta=seq(0,1,0.05), legstudy=NA, ...)plotPower(mod, xlim=NA, ylim=NA, xlab=NA, ylab=NA, title=NULL, col=c(1,2), lty=NA, pch=3, las=1, legpos=c("bottomright","topright"), xtype="theta", delta=seq(0,1,0.05), legstudy=NA, ...)
mod |
A gsearly model from function |
xlim |
The |
ylim |
The |
xlab |
A label for the x axis; default depends on |
ylab |
A label for the |
title |
A main title for the plot; default |
col |
Plotting colours for the lower and upper boundaries; default
|
lty |
Line types, which should be a numeric vector of length equal to the
number of looks ( |
pch |
Plotting character or symbol for points; default 3. |
las |
A numeric value which is one of either 0, 1, 2 or 3; the style of axis labels, 0: always parallel to the axis, 1: always horizontal (default), 2: always perpendicular to the axis, 3: always vertical. |
legpos |
Legend position is a vector of length 2 giving the positions of
the legends (interims and probabilities), which are one of
|
xtype |
X-axis options are either |
delta |
An ordered vector of values at which the probabilities are
calculated. Smoother curves are obtained if the intervals between values are
smaller; default |
legstudy |
A label for the study name in the legend; default is
|
... |
Further arguments to plot function. |
A plot of the selected type or a list consisting of the plotted line and interim point data.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0010,0.0100,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotPower(rctdesign)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0010,0.0100,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotPower(rctdesign)
A recruitment plot for a gsearly model.
plotRecruit(mod, xlim=NA, ylim=NA, xlab=NA, ylab=NA, title=NULL, col=NA, lty=c(1,2), pch=3, las=1, wopcol=grey(0.9), intlab=NA, labpos=3, legpos="topleft", tlag=c(0,0), pcol=1, ...)plotRecruit(mod, xlim=NA, ylim=NA, xlab=NA, ylab=NA, title=NULL, col=NA, lty=c(1,2), pch=3, las=1, wopcol=grey(0.9), intlab=NA, labpos=3, legpos="topleft", tlag=c(0,0), pcol=1, ...)
mod |
A gsearly model from function |
xlim |
The |
ylim |
The |
xlab |
A label for the x axis; defaults to |
ylab |
A label for the y axis; defaults to |
title |
A main title for the plot; default |
col |
Plotting colors for the lines showing recruited numbers;
defaults to |
lty |
A vector of length 2 indicating the line types for the lines showing
numbers recruited and the interim analyses times; default |
pch |
Plotting character or symbol for points; default 3. |
las |
A numeric value which is one of either 0, 1, 2 or 3; the style of axis labels, 0: always parallel to the axis, 1: always horizontal (default), 2: always perpendicular to the axis, 3: always vertical. |
wopcol |
Color for the window of opportunity region, default
|
intlab |
A vector of labels for the interim analyses; defaults to t[1],
t[2], etc. Set to |
labpos |
Position of interim labels; default 3. |
legpos |
Legend position is one of |
tlag |
A vector of length 2, with positive values for time lags,
pre-recruitment and post-recruitment, over which to extend the plotted lines;
default |
pcol |
Color for points and interim lines; default 1. |
... |
Further arguments to plot function. |
A plot of the selected type or a list consisting of the plotted line and interim point data and bounds for the window of opportunity.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotRecruit(rctdesign)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) plotRecruit(rctdesign)
Prints gsearly model details.
## S3 method for class 'gsearly' print(x, digits=4, ...)## S3 method for class 'gsearly' print(x, digits=4, ...)
x |
A fitted gsearly object from |
digits |
The number of digits required for numeric output. |
... |
Further arguments passed to print (not currently implemented). |
A list containing the following components.
title |
Package name and version number. |
call |
Call used to create |
rdata |
See details in |
idata |
See details in |
power |
See details in |
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) rctdesign print(rctdesign) str(print(rctdesign))# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) rctdesign print(rctdesign) str(print(rctdesign))
Prints a gsearly model summary.
## S3 method for class 'gsearly' print.summary(x, digits=4, ...)## S3 method for class 'gsearly' print.summary(x, digits=4, ...)
x |
A fitted gsearly object from function |
digits |
The number of digits required for numeric output. |
... |
Further arguments passed to print (not currently implemented). |
A list containing the following components
title |
Package name and version number. |
call |
Call used to create |
rdata |
See details in |
idata |
See details in |
power |
See details in |
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) summary(rctdesign) str(summary(rctdesign))# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) summary(rctdesign) str(summary(rctdesign))
Quality of life scores for 175 participants, from a randomized controlled trial, at 2, 4 and 8 weeks after treatment.
data(qol)data(qol)
A data frame with 455 observations on the following four variables.
SubjectA participant identifier variable.
WeeksRecorded at follow-up times of 2, 4 and 8 weeks.
STimeStandardized follow-up time variable; see
tfuStandard.
TreatRandom treatment allocation (A or B).
QoLQuality of life index (0-100), where a higher value indicates a higher QoL.
DayDay number (starting at 1), when QoL was assessed.
data(qol) head(qol)data(qol) head(qol)
Rounds the interim sample size to integer values.
roundInterims(mod, direct="u", full=FALSE)roundInterims(mod, direct="u", full=FALSE)
mod |
A fitted gsearly object from function |
direct |
Rounds interim sample sizes to nearest integer, upwards
|
full |
Either |
Returns a matrix (or matrices, if full=TRUE) of the total sample sizes
(and control and treatment groups, if full=TRUE) for each outcome at
interims analyses.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=10, fp=fp, tn=tn) rctdesign # Expected numbers of participants at interim analyses rctdesign$rdata$interims # Round design up to integer values round_rctdesign <- roundInterims(rctdesign, direct="u") round_rctdesign # Power for rounded design n <- rctdesign$rdata$n["total"] ninterims <- round_rctdesign cmodel <- rctdesign$idata$cmodel$corrmat userdesign <- gsearlyUser(trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), ninterims=ninterims, n=n, cmodel=cmodel, sd=20, theta=10, fp=fp, tn=tn) userdesign userdesign$rdata$interims# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="fix", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=10, fp=fp, tn=tn) rctdesign # Expected numbers of participants at interim analyses rctdesign$rdata$interims # Round design up to integer values round_rctdesign <- roundInterims(rctdesign, direct="u") round_rctdesign # Power for rounded design n <- rctdesign$rdata$n["total"] ninterims <- round_rctdesign cmodel <- rctdesign$idata$cmodel$corrmat userdesign <- gsearlyUser(trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), ninterims=ninterims, n=n, cmodel=cmodel, sd=20, theta=10, fp=fp, tn=tn) userdesign userdesign$rdata$interims
Extract data created using function gsearlySimulate.
simdataExtract (simmod, simn, tinterims, datanames=c("id", "atime", "catime", "intervention", "outcome"), full=FALSE)simdataExtract (simmod, simn, tinterims, datanames=c("id", "atime", "catime", "intervention", "outcome"), full=FALSE)
simmod |
A simulation model created using function
|
simn |
Simulation number. |
tinterims |
A vector of ordered numeric valid (i.e. a subset of those in
|
datanames |
Names of the five required data variables; participant
identifier, time-point, standardized (continuous) time-point (see
|
full |
Either |
A list containing the following components.
model |
A list of |
data |
A data frame consisting of five columns that are respectively the participant id, time-point, standardized time-point, intervention arm and outcome, in that order. |
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) # Simulate data from this model with raw data using full=TRUE simdata <- gsearlySimulate(mod=modeldesign, nsim=10, full=TRUE) # Extract raw data for a single simulation simdat1 <- simdataExtract(simdata, simn=1, tinterims=18, full=TRUE, datanames=c("ID","Time", "cTime", "Treat", "Outcome")) head(simdat1$data,n=20)# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.2400,0.7200,0.9750) modeldesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(18,30), pow=0.9, vphi=0.5, m=2, cmodel="uniform", sd=20, rho=0.5, theta=8, fp=fp, tn=tn) # Simulate data from this model with raw data using full=TRUE simdata <- gsearlySimulate(mod=modeldesign, nsim=10, full=TRUE) # Extract raw data for a single simulation simdat1 <- simdataExtract(simdata, simn=1, tinterims=18, full=TRUE, datanames=c("ID","Time", "cTime", "Treat", "Outcome")) head(simdat1$data,n=20)
Provides a summary of a gsearly model.
## S3 method for class 'gsearly' summary(object, ...)## S3 method for class 'gsearly' summary(object, ...)
object |
A fitted gsearly object from function |
... |
Further arguments passed to function (not currently implemented). |
A gsearly model summary.
# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) summary(rctdesign) str(summary(rctdesign))# For 90 percent power (pow), a call to gsearlyModel provides a feasible design fp <- c(0.0000,0.0010,0.0250) tn <- c(0.4800,0.7200,0.9750) rctdesign <- gsearlyModel(rmodel="dilin", trecruit=36, s=3, tfu=c(3,6,12), tinterims=c(16,31), pow=0.8, cmodel="exponential", sd=20, rho=0.75, theta=8, fp=fp, tn=tn) summary(rctdesign) str(summary(rctdesign))
Standardize the follow-up (early) time-points.
tfuStandard(tfu, tref=c(1,2))tfuStandard(tfu, tref=c(1,2))
tfu |
A vector of length |
tref |
A vector of integers of length 2 that defines the correlation
parameter |
A list containing the following components.
tfu |
Follow-up time points. |
stfu |
Standardized follow-up time-points, depending on the selected
reference categories |
# Early outcomes at 3, 6 and 12 months, and final at 24 months # Standardized to units of 3 months if tref is c(1,2) tfuStandard(c(3,6,12,24), tref=c(1,2)) # Standardized to yearly units if tref is c(1,2) tfuStandard(c(3,6,12,24), tref=c(3,4))# Early outcomes at 3, 6 and 12 months, and final at 24 months # Standardized to units of 3 months if tref is c(1,2) tfuStandard(c(3,6,12,24), tref=c(1,2)) # Standardized to yearly units if tref is c(1,2) tfuStandard(c(3,6,12,24), tref=c(3,4))