| Type: | Package |
| Title: | Creates Group Sequential Trial Designs when Early Outcomes are Available |
| Version: | 1.0.0 |
| Maintainer: | Nick Parsons <nick.parsons@warwick.ac.uk> |
| 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>. |
| Depends: | R (≥ 4.1.2) |
| Imports: | graphics, grDevices, gsDesign (≥ 3.2.1), methods, mvtnorm (≥ 1.2-4), nlme (≥ 3.1-160), stats, utils |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| Encoding: | UTF-8 |
| LazyData: | true |
| NeedsCompilation: | no |
| Packaged: | 2026-01-20 13:31:42 UTC; nickr |
| Author: | Nick Parsons |
| Repository: | CRAN |
| Date/Publication: | 2026-01-23 21:20:12 UTC |
Group sequential designs with early outcomes
Description
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.
Details
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.
References
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/
See Also
gsearlyModel, gsearlyUser,
gsearlySimulate
Exponential correlation matrix
Description
Constructs an exponential correlation matrix.
Usage
corrExp(rho=0, tfu)
Arguments
rho |
Correlation parameter. |
tfu |
Follow-up time points, in standardized format from function
|
Value
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.
Examples
# 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)))
Uniform correlation matrix
Description
Constructs a uniform correlation matrix.
Usage
corrUnif(rho=0, tfu)
Arguments
rho |
Correlation parameter. |
tfu |
Follow-up time points, in standardized format from function
|
Value
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.
Examples
# 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)))
Order a data frame by subject and ordered time variable
Description
Orders a user supplied data frame by subject and ordered time variable.
Usage
dataOrder(data, datanames=c("id","atime","catime",
"intervention","outcome"))
Arguments
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
|
Value
Returns an ordered data frame.
Examples
data(qol)
oqol <- dataOrder(qol,datanames=c("Subject","Weeks","STime","Treat","QoL"))
head(qol, n=50)
Expected sample size for a gsearly model
Description
Calculates the expected sample size for a fitted gsearly model,
from functions gsearlyModel or gsearlyUser.
Usage
expectSampsize(mod, signif=3)
Arguments
mod |
A gsearly model. |
signif |
Rounds the sample size to the specified number of significant digits. |
Value
Returns the sample size for the control and treatment groups and total.
See Also
Examples
# 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)
Fixed model sample size for a gsearly model
Description
Calculates the fixed model sample size, assuming no correlation
between early and final outcomes, for a fitted gsearly model, from functions
gsearlyModel or gsearlyUser.
Usage
fixedSampsize(mod, pow=NULL, direct="u", signif=3)
Arguments
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. |
Value
Returns a list with the following items.
n |
Sample size for the control and treatment groups and total. |
power |
Study power. |
See Also
Examples
# 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)
Fit a generalized least squares model
Description
Fits a generalized least squares model using function gls
(from package nlme)
Usage
gsearlyFit(data, datanames = c("id","atime","catime",
"intervention","outcome"), cmodel=FALSE, vmodel=TRUE, full=FALSE)
Arguments
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 |
Value
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
|
See Also
gsearlySimulate, simdataExtract,
modelParameters
Examples
# 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 based estimates of sample size and power for group sequential designs with early outcomes
Description
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.
Usage
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)))
Arguments
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 |
Value
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 ( |
See Also
expectSampsize, fixedSampsize,
roundInterims, corrExp, corrUnif
Examples
# 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 data for a previously fitted gsearly model
Description
Simulates multivariate Normal datasets based on a previously fitted
gsearly model (see gsearlyModel).
Usage
gsearlySimulate(mod, nsim=1, minsamp=c(1,1), mean=NULL, cmodel=NULL,
sd=NULL, rho=NULL, full=FALSE)
Arguments
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. |
Value
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 |
See Also
gsearlyModel, simdataExtract, modelParameters, gsearlyFit
Examples
# 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
User input estimates of sample size and power for group sequential designs with early outcomes
Description
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.
Usage
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)))
Arguments
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 |
Value
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 |
See Also
Examples
# 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
Estimates model parameters from raw data
Description
Provides estimates of the variance of beta (vbeta) and beta, the treatment effect, directly from raw data and a user supplied covariance matrix.
Usage
modelParameters(data, datanames=c("id", "atime", "intervention", "outcome"),
vcovmat)
Arguments
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 |
Value
Returns the variance of beta (vbeta), beta and test statistic z.
See Also
gsearlySimulate, simdataExtract
Examples
# 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)
Plot a gsearly model
Description
Plots data from a gsearly model constructed using either
gsearlyModel or gsearlyUser.
Usage
## S3 method for class 'gsearly'
plot(x, plottype=1, ...)
Arguments
x |
A gsearly model from function either |
plottype |
A value which is one of either 1 or |
... |
Further graphical parameters for lines and points. |
Value
A plot of the selected type.
Examples
# 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
Description
A boundary plot for a gsearly model.
Usage
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), ...)
Arguments
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. |
Value
A plot of the selected type or a list consisting of interim information fractions and lower and upper boundaries.
Examples
# 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 plot for a gsearly model
Description
An information or variance plot for a gsearly model.
Usage
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, ...)
Arguments
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. |
Value
A plot of the selected type or a list consisting of the plotted line and interim point data.
Examples
# 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
Description
A power plot for a gsearly model.
Usage
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, ...)
Arguments
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. |
Value
A plot of the selected type or a list consisting of the plotted line and interim point data.
Examples
# 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
Description
A recruitment plot for a gsearly model.
Usage
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, ...)
Arguments
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. |
Value
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.
Examples
# 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)
Print a gsearly model
Description
Prints gsearly model details.
Usage
## S3 method for class 'gsearly'
print(x, digits=4, ...)
Arguments
x |
A fitted gsearly object from |
digits |
The number of digits required for numeric output. |
... |
Further arguments passed to print (not currently implemented). |
Value
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 |
Examples
# 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))
Print a gsearly model summary
Description
Prints a gsearly model summary.
Usage
## S3 method for class 'gsearly'
print.summary(x, digits=4, ...)
Arguments
x |
A fitted gsearly object from function |
digits |
The number of digits required for numeric output. |
... |
Further arguments passed to print (not currently implemented). |
Value
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 |
Examples
# 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 index for patients with knee pain
Description
Quality of life scores for 175 participants, from a randomized controlled trial, at 2, 4 and 8 weeks after treatment.
Usage
data(qol)
Format
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.
Examples
data(qol)
head(qol)
Round a gsearly design interim sample size to integer values
Description
Rounds the interim sample size to integer values.
Usage
roundInterims(mod, direct="u", full=FALSE)
Arguments
mod |
A fitted gsearly object from function |
direct |
Rounds interim sample sizes to nearest integer, upwards
|
full |
Either |
Value
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.
See Also
Examples
# 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 simulated data for a single trial
Description
Extract data created using function gsearlySimulate.
Usage
simdataExtract (simmod, simn, tinterims,
datanames=c("id", "atime", "catime", "intervention", "outcome"),
full=FALSE)
Arguments
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 |
Value
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. |
See Also
Examples
# 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)
Summarise a gsearly model
Description
Provides a summary of a gsearly model.
Usage
## S3 method for class 'gsearly'
summary(object, ...)
Arguments
object |
A fitted gsearly object from function |
... |
Further arguments passed to function (not currently implemented). |
Value
A gsearly model summary.
Examples
# 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 follow-up times
Description
Standardize the follow-up (early) time-points.
Usage
tfuStandard(tfu, tref=c(1,2))
Arguments
tfu |
A vector of length |
tref |
A vector of integers of length 2 that defines the correlation
parameter |
Value
A list containing the following components.
tfu |
Follow-up time points. |
stfu |
Standardized follow-up time-points, depending on the selected
reference categories |
Examples
# 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))