Returns the posterior (or approximate posterior) draws of a fit's parameters, as arrays named for the model matrices.
Usage
ctExtract(
object,
subjectMatrices = FALSE,
cores = getOption("mc.cores", 2L),
nsamples = "all",
subjects = "all",
state = NULL,
realid = TRUE,
...
)Arguments
- object
A fit from
ctFit, on either backend: sampled, or optimized with its approximate posterior draws.- subjectMatrices
Calculate subject specific system matrices? On a
backend='julia'fit whose random effects are coordinates (intoverpop='laplace', or a sampled fit), each draw's subject matrices are at that draw's plausible values – the population draw with a draw of the subject's own effects from their posterior given its data – so their spread over draws is the subject's whole uncertainty, asctSubjectParsreports by default.- cores
Only used if subjectMatrices = TRUE . For faster computation use more cores.
- nsamples
either 'all' or an integer denoting number of random samples to extract.
- subjects
either 'all', or the subjects to extract, as ids in the data (see
realid).- state
The latent state at which state dependent cells of the
pop_*matrices are evaluated:'T0MEANS'(the default),'mean','asymptotic', or a numeric state vector. Onlybackend='julia'can materialise the matrices anywhere other than the default, so anything else is an error on a stan fit rather than being silently ignored. Irrelevant to a linear model, whose matrices are the same everywhere. Note that it moves thepop_*arrays only: the subject matricessubjectMatrices=TRUEadds come from the filter, and are always at each subject's own last observed row.- realid
If TRUE (the default), subjects are read as the ids in the data, and integers that are not ids there are read as ctsem's numbering of the subjects, 1 to N, with a message. If FALSE, they are read as that numbering.
- ...
not used.
Value
A list of posterior sample arrays. The point the pop_*
matrices were evaluated at is recorded in the 'evaluatedAt' attribute;
nothing is messaged, because the summaries call this repeatedly and say it
once themselves. ctModelIsNonlinear answers whether the point
matters for this model at all.
Where parameters vary over subjects, the population of them, per draw:
popsd (draws by parameters), rawpopcov and rawpopcorr
(the raw scale's covariance and correlations, draws by parameters by
parameters) and popcov (the covariance on the natural scale). On a
backend='julia' fit they are named by parameter, and a model with
several grouping levels gives each level's as rawpopcov.<level> and so
on; its popcov combines popsd with the raw correlations, exact
where a parameter's transform is affine.
Examples
# \donttest{
e = ctExtract(ctstantestfit)
attr(e, 'evaluatedAt')
# }