ctStanGenerateFromFit: Add a '$generated' object to ctstanfit object, with random...

View source: R/ctStanGenerateFromFit.R

ctStanGenerateFromFitR Documentation

Add a $generated object to ctstanfit object, with random data generated from posterior of ctstanfit object

Description

Add a $generated object to ctstanfit object, with random data generated from posterior of ctstanfit object

Usage

ctStanGenerateFromFit(
  fit,
  nsamples = 200,
  fullposterior = FALSE,
  verboseErrors = FALSE,
  cores = 2
)

Arguments

fit

ctstanfit object

nsamples

Positive integer specifying number of datasets to generate.

fullposterior

Logical indicating whether to sample from the full posterior (original nsamples) or the posterior mean.

verboseErrors

if TRUE, print verbose output when errors in generation encountered.

cores

Number of cpu cores to use.

Value

Matrix of generated data – one dataset per iteration, according to original time and missingness structure.

Examples

gen <- ctStanGenerateFromFit(ctstantestfit, nsamples=3,fullposterior=TRUE,cores=1)
plot(gen$generated$Y[3,,2],type='l') #Third random data sample, 2nd manifest var, all time points. 

ctsem documentation built on Sept. 11, 2024, 9:06 p.m.