Learn R Programming

gsearly (version 1.0.0)

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

Value

A list containing the following components.

model

A list of s, tinterims, tfu and mean, covariance and correlation matrices and parameters and sample sizes.

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.

Arguments

simmod

A simulation model created using function gsearlySimulate, where full data are available i.e. where full=TRUE.

simn

Simulation number.

tinterims

A vector of ordered numeric valid (i.e. a subset of those in simmod) interim analysis time-points. If unset, these are taken from simmod.

datanames

Names of the five required data variables; participant identifier, time-point, standardized (continuous) time-point (see tfuStandard), intervention arm and outcome, in that order; e.g. c("id","atime","catime","intervention","outcome")).

full

Either FALSE, which provides a data frame only or TRUE which provides model details in addition to the data frame.

See Also

gsearlySimulate

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

Run the code above in your browser using DataLab