Summarise model-implied parameter matrices from a ctsem fit object.
ctStanContinuousPars is maintained as a backward-compatible alias.
Usage
ctSummaryMatrices(
fit,
calcfunc = quantile,
calcfuncargs = list(probs = 0.5),
timeinterval = 1,
state = NULL,
...
)Arguments
- fit
fit object from
ctFit- calcfunc
Function to apply over samples, must return a single value. By default the median over all samples is returned using the
quantilefunction, but one might also be interested in themeanorsd, for instance.- calcfuncargs
A list of additional parameters to pass to calcfunc. For instance, with the default of calcfunc = quantile, the probs argument is needed to ensure only a single value is returned.
- timeinterval
time interval for discrete time parameter matrix computation.
- state
The latent state at which state dependent matrix cells are evaluated:
'T0MEANS'(the default),'mean','asymptotic', or a numeric state vector. The default is the population initial state, with time dependent predictors at zero, which for a model whose dynamics depend on the state can be far from where the data are;'mean'(the mean smoothed latent state) or'asymptotic'(the system's fixed point) is then usually the better point. The initial state and the fixed point are each draw's own;'mean'is the estimate's, used for every draw, so a summary of the draws there leaves out where that state is. 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.- ...
arguments passed to the method for the fit's backend.
Value
A named list of matrices, each summarised over the posterior (or
approximate posterior) draws by calcfunc: the model's own
(DRIFT, DIFFUSION, LAMBDA, ...), the covariances
built from them (DIFFUSIONcov, MANIFESTcov, and T0cov,
the initial latent covariance over subjects: T0VAR plus the
population covariance of any individually varying T0MEANS), the
asymptotic asymCINT and asymDIFFUSIONcov, and
dtDRIFT at timeinterval. Beside each covariance its
correlations, DIFFUSIONcor, MANIFESTcor, T0cor and
asymDIFFUSIONcor, taken draw by draw before calcfunc
summarises them; a variable whose variance is zero has NA there. On backend='julia', also the
Jacobians of the drift and of the measurement at the evaluation point,
JAx (latent by latent) and Jy (manifest by latent): the local
effects of the model linearised at state. They equal DRIFT and
LAMBDA for a linear model; where a cell is nonlinear in the state they
do not, since a DRIFT cell a + q*Y in the column of process
Y holds a + q*Y there and contributes a + 2*q*Y to
JAx. dtDRIFT is expm(JAx * timeinterval) where there is
a JAx, the transition ctDiscretePars reports, and
expm(DRIFT * timeinterval) on stan. For a model whose dynamics depend
on the state it holds JAx fixed over the interval: a fair interval
regression near a fixed point or over a short interval, and away from a fixed
point one ctDiscretePars(method = 'simulate') should check. Where parameters vary over subjects,
also their population covariance on the natural scale, popcov, and
their raw-scale correlations, rawpopcorr, named by parameter (with
several grouping levels, popcov.<level> and rawpopcorr.<level>).
popcov combines the sds summary() reports as popsd with
those correlations, so it is exact where a parameter's transform is affine,
as for intercepts and initial means.
On an optimised fit, estimate holds the same matrices at the fit's
estimate, unrounded: ctSummaryMatrices(fit)$estimate$DRIFT is the
estimated drift matrix, which a summary of the draws need not equal, and
ctSummaryMatrices(fit, state = s)$estimate$JAx the model linearised
at s at the estimate. A sampled fit has no estimate, and a
backend='stan' fit's has no popcov, which stan simulates.