ctsem (version 3.0.4)

ctGenerateFromFit: Generates data according to the model estimated in a ctsemFit object.

Description

Generates data according to the model estimated in a ctsemFit object.

Usage

ctGenerateFromFit(fit, timestep = "asdata", n.subjects = 100,
  timerange = "asdata", predictorSubjects = "all", ...)

Arguments

fit

object of class ctsemFit as returned from ctFit

timestep

positive numeric value indicating the time interval to use for data generation.

n.subjects

integer. Number of subjects worth of data to generate

timerange

either 'asdata' to calculate range based on data in fit object, or vector of length 2 specifying min and max times for generation.

predictorSubjects

vector of integers, or string 'all', defining which subjects to sample time dependent and independent predictors from.

...

parameters to pass to ctGenerate function, such as wide=FALSE.

Value

matrix of generated data

Examples

Run this code
# NOT RUN {
data(AnomAuth) 
AnomAuthmodel <- ctModel(LAMBDA = matrix(c(1, 0, 0, 1), nrow = 2, ncol = 2), 
  Tpoints = 5, n.latent = 2, n.manifest = 2, MANIFESTVAR=diag(0, 2)) 
AnomAuthfit <- ctFit(AnomAuth, AnomAuthmodel)

dwide <- ctGenerateFromFit(AnomAuthfit,timestep=1,n.subjects=5)

par(mfrow=c(1,2))
ctIndplot(datawide = dwide,n.subjects = 5,n.manifest = 2,vars=1,Tpoints = 4)
ctIndplot(datawide = AnomAuth+rnorm(length(AnomAuth)),vars=1,n.subjects = 5,
n.manifest = 2,Tpoints = 4)

# }

Run the code above in your browser using DataLab