Learn R Programming

gsearly (version 1.0.0)

gsearlySimulate: 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)

Value

A list containing the following components.

model

A list of model settings nsim, s, tinterims, tfu and mean, covariance and correlation matrices.

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 nsim simulations.

data

A list of length 2 (control and treatment), each comprising of a list of length nsim comprising a list of matrices of outcome data (if full=TRUE) at interims and final analyses.

Arguments

mod

A previously fitted model from function gsearlyModel.

nsim

Number of required simulated datasets.

minsamp

Simulations where numbers at the first interim are less than minsamp, a vector of length 2 giving the minimum study sample size for the control and treatment groups, are excluded.

mean

A matrix of dimension 2 x s giving mean values for the control (first row) and treatment (second row) groups for each of the s outcome time-points. If unset, these are taken directly from mod, where the control group mean is set to zero and the treatment group mean to theta for the primary outcome time-point with early means all set to zero (see gsearlyModel).

cmodel

Either a correlation model, c("uniform", "exponential"), defined by correlation parameter rho, or a correlation matrix of dimensions s x s. If unset, taken from mod.

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 s, allowing sd to differ at each time-point. If unset, taken from mod.

rho

Correlation parameter if cmodel is set to "uniform" or "exponential", otherwise ignored. If unset, taken from mod.

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.

See Also

gsearlyModel, simdataExtract, modelParameters, gsearlyFit

Examples

Run this code

 # 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

Run the code above in your browser using DataLab