Deprecated. Use ctGenerate(fromPriors = TRUE), which is the
same computation reached through the function that generates data from a
ctsem model generally. ctStanGenerate is a backward-compatible alias
and is deprecated with it.
Arguments
- cts
A model –
ctModelorctModelConvertOMX– or a fit from either backend, which is simply a model that arrives with a design attached. Nothing here needs a fit: generating from the prior needs the model and a set of subjects and times to generate over, and a fit is one way to supply both.- datastruct
Long format data structure as used by ctsem, giving the subjects, times and missingness to generate for. Ignored when
ctsis a fit, which carries its own. Left at NA for a model, a balanced design ofn.subjectssubjects observed atTpointsoccasionsdtmeanapart is built instead.- is
Deprecated and ignored, with a warning if set. Importance sampling reweights draws taken from a gaussian approximation onto a target that cannot be sampled directly. Fitted to an empty dataset there is no such target: the likelihood contributes nothing and what remains is the prior, which ctsem holds as independent univariate densities in the raw space these draws are taken in. There is no approximation to correct.
- fullposterior
Generate from the full prior, or from its mode (the raw origin)?
- nsamples
How many samples to generate?
- parsonly
If TRUE, only return samples of raw parameters, don't generate data.
- cores
Number of cpu cores to use.
- backend
Which engine turns a parameter draw into data:
'auto'(the default –'julia'when a julia session is available,'stan'otherwise),'julia'or'stan'. The draws themselves do not depend on this: they come from the model's prior, which is the same object either way.parsonly=TRUEreturns those draws and generates nothing, so it does not use this argument.- n.subjects, Tpoints, dtmean
The design to build when
ctsis a model and nodatastructis given, and unused otherwise.Tpointsfalls back to the model's own when it carries one.n.subjectsis deliberately smaller thanctGenerate's: this returnsnsamplesdatasets rather than one.
Value
List containing Y, an array of nsamples by data rows by manifest
variables, and llrow, an array of nsamples by data rows log likelihoods.
With parsonly=TRUE, the prepared model carrying the prior draws
under $stanfit$rawposterior and $stanfit$transformedpars.
Examples
# \donttest{
#generate and plot samples from prior predictive
priorpred <- ctGenerateFromPriors(cts = ctstantestfit,cores=2,nsamples = 50)
# backend = 'auto' generates with julia where it is available. Julia keeps
# running between calls, holding what it has compiled; this ends it.
if (isTRUE(ctJuliaStatus()$available)) ctJuliaKill("session")
# }