simdataExtract: Extract simulated data for a single trial

View source: R/simulation_functions.R

simdataExtractR Documentation

Extract simulated data for a single trial

Description

Extract data created using function gsearlySimulate.

Usage

simdataExtract (simmod, simn, tlooks,
         datanames=c("id", "atime", "catime", "intervention", "outcome"),
         full=FALSE)

Arguments

simmod

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

simn

Simulation number.

tlooks

A vector of ordered numeric valid (i.e. a subset of those in simmod) interim analysis and final 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.

Value

A list containing the following components.

model

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

data

A data frame, if full is TRUE, consisting of five columns that are respectively the participant id, time-point, standardized time-point, intervention arm and outcome, in that order.

See Also

gsearlySimulate

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, contrat=c(1,2), 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, tlooks=18,
          full=TRUE, datanames=c("ID","Time", "cTime", "Treat", "Outcome"))
 head(simdat1$data,n=20)


gsearly documentation built on July 10, 2026, 5:09 p.m.