Learn R Programming

gesttools (version 1.0.1)

dataexamples: Generate Simulated Example Datasets

Description

The code simulates four datasets designed to demonstrate each of the four g-estimation functions of the package. These are used in the examples for each function in the user manual. Each dataset comprises of an outcome Y (time-varying or end of study), time-varying exposure A, time-varying confounder L, a baseline confounder U, and optionally a censoring indicator C over 3 time periods.

Usage

dataexamples(n = 1000, seed = seed, Censoring = FALSE)

Arguments

n

Number of individuals in the dataset.

seed

Random seed used for data generation.

Censoring

TRUE or FALSE indicator of whether to include a censoring indicator C. If Censoring=TRUE, data entries for A, Y, L and U are set to missing after censoring.

Value

Returns a list of four datasets labeled datagest, datagestmult, datagestcat, and datagestmultcat, designed to demonstrate the respective functions.

Examples

Run this code
# NOT RUN {
datas<-dataexamples(n=1000,seed=34567,Censoring=FALSE)
data<-datas$datagest
head(data,n=20)
#Multiple outcome data with censoring
datas<-dataexamples(n=100,seed=34567,Censoring=TRUE)
data<-datas$datagestmultcat
head(data,n=20)

# }

Run the code above in your browser using DataLab