Learn R Programming

ctsem (version 1.1.5.2)

ctWideToLong: ctWideToLong Convert ctsem wide to long format

Description

ctWideToLong Convert ctsem wide to long format

Usage

ctWideToLong(datawide, Tpoints, n.manifest, n.TDpred = 0, n.TIpred = 0,
  manifestNames = "auto", TDpredNames = "auto", TIpredNames = "auto")

Arguments

datawide
ctsem wide format data
Tpoints
number of measurement occasions in data
n.manifest
number of manifest variables
n.TDpred
number of time dependent predictors
n.TIpred
number of time independent predictors
manifestNames
Character vector of manifest variable names.
TDpredNames
Character vector of time dependent predictor names.
TIpredNames
Character vector of time independent predictor names.

Examples

Run this code
#First load the example ctsem wide format data with absolute times
 data('datastructure')
 datastructure #contains two time intervals (dTx), therefore 3 time points.
 #Then convert to long format
 longexample <- ctWideToLong(datawide = datastructure, Tpoints=3, 
 n.manifest=3, manifestNames = c("Y1", "Y2", "Y3"),
 n.TDpred=1, TDpredNames = "TD1", 
 n.TIpred=2, TIpredNames = c("TI1", "TI2"))

 #Then convert the time intervals to absolute time
 long <- ctDeintervalise(datalong = longexample, id='id', dT='dT')
 long

Run the code above in your browser using DataLab