Recomputes the approximate raw-parameter uncertainty for an optimized
ctFit object and refreshes the approximate raw-parameter
samples, or samples the posterior by Markov chain Monte Carlo. This is the
entry point for both backends; ctFit itself calls it to finish an
optimized fit. ctOptimUncertainty is the previous name, kept
for code written against ctsem 3.11.1, with that release's arguments.
Usage
ctFitUncertainty(
fit,
method = c("hessian", "checked", "is", "sample", "sandwich", "opg", "bootstrap",
"fullbootstrap", "stored"),
intoverpop = NULL,
filter = c("kalman", "particle"),
checks = TRUE,
finishsamples = NULL,
cores = getOption("mc.cores", 2L),
control = list(),
verbose = 0,
...
)
ctOptimUncertainty(
fit,
uncertainty = c("hessian", "checked", "is", "bootstrap", "fullbootstrap", "sandwich",
"opg", "stored"),
draws = c("auto", "normal", "empirical", "imis"),
finishsamples = NULL,
cores = getOption("mc.cores", 2L),
control = list(),
verbose = 0,
...
)Arguments
- fit
Optimized
ctStanFitorctJuliaFitobject, or formethod = 'sample'a julia fit that is already sampled.- method
How the parameters' posterior is described:
'hessian'(the default),'checked','is','sample','sandwich','opg','bootstrap','fullbootstrap'or'stored'. See the Methods section, and Sampling for'sample'. The kind of draws follows from it: normal draws from a curvature, importance-weighted ones for'checked'and'is', the bootstrap's own, MCMC for'sample'.- intoverpop
How the random effects are integrated, in
ctFit's words;NULL(the default) keeps the fit's own ('laplace'or'augmented', asfit$args$resolvedrecords).'quadrature', for a Laplace fit, refines the fit from its estimate, with the units the random-effects check names integrated numerically – by adaptive Gauss-Hermite or lattice rules, whichever reaches the accuracy at the lower cost – and describes the posterior there, asctFit(intoverpop = 'quadrature')does when fitting; with'hessian','checked'or'is'. Withmethod = 'sample','none'samples the random effects jointly with the parameters, which takes no approximation of their integral, and'laplace'the Laplace marginal (see Sampling).- filter
How the latent states are integrated:
'kalman'(the default), the fit's Kalman filter (extended where the model is nonlinear), or'particle', a particle filter, the likelihoodctParticleLikmeasures the Kalman filter against; withmethod = 'is', on a fit whose random effects are not integrated by Laplace (see Methods).- checks
Which approximations to check where the method itself leaves them in place:
TRUE(the default) for both,FALSEfor neither, or one of'randomeffects'and'intervals'. The random-effects check (a julia fit onintoverpop = 'laplace') scores every unit's Laplace integral at draws of its random effects, and warns where integrating them exactly would move an estimate, namingintoverpop = 'quadrature'; a fit that has one on record is not checked again. The interval check (julia, withmethod = 'hessian') makes'checked''s check of the curvature's normal against the posterior's gradients, on the density the intervals come from, records it in$uncertainty$details$normalcheck, and says in a message, and insummary(), when the posterior departs from that normal, namingmethod = 'sample'. Both checks take seconds on the fit's own objective. Withintoverpop = 'quadrature'the interval check is made on the refined fit's objective, where each of its draws integrates the flagged units again: seconds on one level, but half an hour on a nested model whose refinement took minutes, longer than sampling;checks = 'randomeffects'leaves it out.- finishsamples
Number of approximate raw-parameter samples. If
NULL, the existing number of rows in the fit's raw posterior (fit$stanfit$rawposteriorfor stan,fit$estimate$rawposteriorfor julia) is reused when available; otherwise 1000 samples are used. Not used by'sample', whose draw count iscontrol$draws.- cores
The most CPU cores the call uses at once, counting every process it starts.
'sample'shares them between at most that many worker processes, which run the chains. On actJuliaFitthere is no R cluster; the value becomes the engine's subject-loop chunk ceiling for the duration of the call, and the engine caps it at its own thread count. ActStanFithas no threads, so more than one core means R worker processes, which take seconds to start and are used only for work slow enough to repay that: the refits of'fullbootstrap', and'is'on data of a few thousand rows or more, where each log-probability evaluation is split across subjects. Everything else runs in this session. Neither route changes what is computed, though both change the order things are summed in, so results are reproducible atcores = 1and agree to rounding above it.- control
List of method-specific options.
accuracy(julia only), an accuracy in posterior standard deviations, applies to every method but'sample': once the method has run, its own account of its error – for'checked'and'is'the Stein check's per-parameter mean error and spread – is read against it, and where the method falls short, or has no account ('hessian', the score methods), the fit is sampled to that accuracy ('sample'withminESSandrhatTargetset from it: 0.5 is a tail effective size of about 125 and R-hat 1.07, 0.3 about 350 and 1.025). The method reached is the one reported, and$uncertainty$escalationrecords what was read and done. Formethod = 'sample'the entries are the sampler settings described in the Sampling section (chains,warmup,draws,seed,saveEffects,processes,tipredMissing,sampler,particles,coreset,placement,minESS,meanESS,rhatTarget,maxDraws,settleTol,init_scale, and NUTS'smaxdepth,target_accept,adapt_metricandadapt_effects); none of the entries below apply to it. For every other method, useful entries includeridge,hessianStep,bootstrapFitCores,bootstrapTol,imisMaxIter,imisScaleInit,imisTailScale,imisDf,isESS, andisitersize. Omitted entries useridge = 1e-8,hessianStep = 1e-3,bootstrapFitCores = 1,bootstrapTol = 1e-5,imisMaxIter = 50(100 for'checked'),imisScaleInit = 1.1,imisTailScale = 1.1(1.5 and 1.2 for'is'on julia),imisDf = 5(the proposal components' t degrees of freedom;Inffor normal),isESS = 200, andisitersize = 1000(100 for'checked').imisBudgetcaps the log density evaluations importance sampling spends (no cap by default).imisComplement = TRUE('checked') weighs the sampled directions with the others integrated over, rather than held at the centre with the volume their spread adds to first order: exact where the others' spread moves with them, as a large covariance's scale does, at up to seven times the evaluations. On a julia fit, importance sampling evaluates a weighted subset of the units chosen and checked as it runs, and corrects its weights where that subset strays;coreset = FALSEevaluates every unit instead. Where the check of'checked'names a direction, the normal is first moved to the posterior's moments by doubly adaptive importance sampling (van den Boom, Cremaschi and Thiery 2026; julia fits, in the engine) and checked again there before anything is sampled;dais = FALSEskips that,daisDrawssets its draws an iteration (the dimension, between 64 and 256) anddaisMaxIterits iterations (150).parstepskeeps stepwise-fixed raw parameters fixed (stan only).analyticHessian = FALSE(julia only) asks for the finite-difference Hessian instead of the engine's exact one.flat = 'natural'('checked'and'is', julia only) makes the parameters without a prior flat on their natural scale rather than their raw one in the density sampled: the standard deviation itself rather than its log, say, so that a likelihood that levels off as an sd goes to zero still has a proper posterior. The estimate is unchanged. Withintoverpop = 'quadrature'orfilter = 'particle',nodes,particles,substeps,transition,seedandcorrectEstimateare as described under Methods. A Hessian covariance that needs numerical repair – positive-definite projection, ridge flooring, orMASS::ginv– warns, with diagnostics in$uncertainty$details$covariance.- verbose
Integer controlling progress detail.
- ...
Not used. Anything passed here is an error rather than ignored: a method's settings are entries of
control.- uncertainty, draws
ctOptimUncertainty()only, the names of ctsem 3.11.1:uncertaintyismethod;draws('auto','normal','empirical'or'imis') overrides the kind of draws the method makes.
Value
The fit, of the class it came in as. For every method except
'sample': the resolved method, draw strategy, sample count, cores,
and non-internal controls are recorded in
fit$stanfit$uncertainty$settings for a ctStanFit and in
fit$uncertainty$settings for a ctJuliaFit; see Backend
differences for the other slots each writes. For
method = 'sample': a ctJuliaFit with
estimate$rawposterior holding the draws and $sample holding
the chain diagnostics (split R-hat and effective sample size per
parameter, divergences, tree depths, step sizes, E-BFMI (NUTS only),
sampler naming the kernel, converged
and diagnosis, and target naming which posterior was
sampled), exactly as ctFit(optimize = FALSE) returns.
Details
Every method except 'sample' writes pseudo-posterior draws to
$rawposterior: a sample from a covariance fitted to the
log-posterior surface around the optimum, not a sample from the posterior
itself, and the point estimate stays at the optimum – unless the method
is taken against a more exact likelihood than the fit's
(intoverpop = 'quadrature', filter = 'particle'), when it
moves to the corrected point.
method = 'sample' is the other thing, genuine posterior draws
by Markov chain Monte Carlo, and it moves the point estimate too:
$estimate$raw becomes the posterior mean, the way
ctFit(optimize = FALSE) reports a sampled fit. Everything downstream
reads either kind of draw from the same slot, so the difference is recorded
rather than visible in the shape of the result: a curvature-based fit
carries $uncertainty$settings, a sampled one carries $sample.
Every method except 'sample' refuses a fit that already carries a
posterior rather than replacing its draws with an approximation;
'sample' may be run again on a sampled fit, to draw more, or
differently, from where it stands.
To change only the number of draws, use method = 'stored', which
redraws from the covariance the fit already carries and evaluates no model.
Functions
ctOptimUncertainty(): The name this function shipped under in ctsem 3.11.1, kept so that a call written against that release keeps meaning exactly what it did. The same asctFitUncertaintyin every respect but its argument names (uncertainty,draws) and that it has neitherintoverpop,filter,checksnor'sample'; new code should preferctFitUncertainty.
Methods
'checked'The Hessian's normal, checked, and corrected by importance sampling in the directions where it is wrong. The log posterior's gradient at draws from the normal says in which directions the posterior departs from it, in batches of 8 until the directions named would be the same with every departure two standard errors larger or smaller, and the directions named are fewer than half the draws (16 draws at least, and at most twice the parameters, between 64 and 256). Where a direction would leave some parameter's 95% interval covering under 90% or over 99%, or move one tail outside 0.5 to 5% by a skew or by a width that moves with another parameter, every departing direction is sampled as
'is'samples (below), the normal kept in all the rest. This is meant to correct a variance from few groups and the effects it scales, but it weighs the sampled directions with the others held near the centre, so where their spread moves with the sampled ones – a population sd and the effects it scales – intervals can remain too narrow, and nothing below detects it: on models with random effects, sample ('sample') for intervals to report. Where that sampling cannot correct the normal – a curved ridge such as a loading vector whose length the data determine and whose direction they barely do, where the Hessian's intervals can be many times too wide – the Hessian's normal is kept, with a warning naming the parameters it misstates. The normal is centred where the same gradients, and those at the draws reflected (at least 32 pairs), put the posterior's mean, which is not the estimate wherever the posterior is skewed or a covariance is estimated; the estimate stays the fit's, andsummary()reports it beside the draws. Where nothing is sampled, the same pairs' widths replace the Hessian's along the directions they resolve, where they move an sd by 5% or more. The sampled directions are weighed with the volume the others' spread adds to them, to first order, and the sampled draws are checked against the posterior's gradient at 100 of them (Stein's identity): where a mean is off along the sampled directions, sampling goes on from a component the gradient places (twice at most), and a warning names the parameters whose mean the gradient puts half a normal sd or more away, or whose spread it puts under half or over twice the posterior's. A fit with nothing named gets the Hessian's covariance, so corrected. The check is recorded in$uncertainty$details$normalcheck, and the sampling, when there was any, in$uncertainty$details$importance_sampling.'hessian'The default, as
ctFit's: a normal approximation from the Hessian at the estimate – exact on julia, which differentiates its own gradient, and by finite differences of the gradient on stan. On julia the interval check (checks) is made beside it, and the normal is reported as it is.'bootstrap','sandwich','opg'Built from per-subject score contributions: one-step score bootstrap draws with Hessian bread, Hessian bread with score covariance meat, and the outer product of the scores. A single-subject model uses case-level contributions, with a warning; fewer than ten subjects, or no more score rows than parameters, also warn.
'fullbootstrap'Resamples subjects and re-optimizes each resample from the estimate with mize L-BFGS. Stan only.
'is'Adaptive importance sampling against the fit's own objective. Each raw parameter is first walked out on both sides of the mode, from 3 to 96 standard errors, with the other parameters at their conditional mode, and a proposal component is placed wherever that walk finds a tail the curvature does not show – a skewed one, or one bending along a ridge, as a variance with few subjects often has. Rounds of
isitersizedraws from these multivariate t components then add components at the highest-weighted draws, and up to three more where the weights show the proposal falls short, each moved by a Newton step and shaped by the log posterior's curvature there, until the effective sample size reachesisESSand the Pareto k of the weights is below 0.7 (k needs the loo package). The effective size, k, the evaluations used and the parameters with a tail are recorded infit$uncertainty$details$importance_sampling; k above 0.7 warns, and so does a parameter whose walk has not fallen off by 96 standard errors, which is what an improper posterior looks like. A rank deficient Hessian covariance is sampled in the directions it has curvature in, holding the rest at the estimate.On a fit whose random effects are integrated (
intoverpop = 'laplace'or'augmented') the objective is the route's approximate marginal posterior, so by default'is'corrects the shape of the normal approximation but keeps the route's own approximation: where the Laplace approximation is biased – random effects on variances, in nonlinear dynamics, or with non-Gaussian indicators –'is'reproduces the bias. Expect it to cost several times the fit.intoverpop = 'quadrature'(julia, a Laplace fit) draws against a more exact density, with'is'or'checked': the quadrature hybrid, which has the units the screen flags, and those the fit's check named, integrated by quadrature rules (control$nodesper effect, 5 by default) or draws, the rest by their Laplace terms, with the error of that density reported infit$laplace$correction$errorand insummary(). A fit not refined when it was fitted – the default, which only checks and warns – is climbed to that density's optimum first; one refined when it was fitted stays where it is, as does any fit undercorrectEstimate = FALSE. With'quadrature','hessian'is taken too: the hybrid's curvature where the climb ends, which is whatctFit(intoverpop = 'quadrature')gives at fit time, with the interval check made on the hybrid there. Where the climb stops short of its optimum, the intervals are the Laplace objective's at its optimum, moved with the estimate, as at fit time.filter = 'particle', for a fit on the filter's route and with'is', replaces the filter's Gaussian likelihood by a particle filter's (control$particles, 1000;substeps, 10;transition,'exponential'or'euler';seed, 1, with drawiusingseed + i - 1), the likelihoodctParticleLikmeasures the filter against; its Monte Carlo noise widens the weights without biasing them, each draw costs one particle-filter evaluation, the proposal starts from the fit's covariance widened byimisScaleInit(1.5) and runs at mostimisMaxIter(10) rounds ofisitersizedraws, and the estimate moves to the weighted posterior mean unlesscorrectEstimate = FALSE. What was done is recorded infit$laplace$correctionor, printing,fit$particle_correction. Where too few effective draws survive the approximation is too far from the target to repair by reweighting, and'sample'withintoverpop = 'none'is the answer instead.'stored'Computes nothing: redraws
finishsamplesnormal draws from the covariance already on the fit, leaving the covariance, the Hessian and the recordedmethoduntouched, and marks$uncertainty$settings$redrawn = TRUE. It warns if the existing draws came from'is'or a bootstrap, which normal draws from that covariance do not reproduce.'sample'Markov chain Monte Carlo; see the next section.
backend = 'julia'only.
Every method that produces draws aims for the same effective sample size
unless told otherwise, 200: minESS for 'sample' (of the worst
parameter, since the 2.5% and 97.5% quantiles need it for each) and
isESS for 'is', whatever its likelihood. Each warns when it
ends short of its target.
Sampling (method = 'sample')
Draws from the posterior by Markov chain Monte Carlo, through the same
runner ctFit(backend = 'julia', optimize = FALSE) uses, and with the
same defaults. Its settings are entries of control, and
draws and finishsamples are not used: chains (4),
warmup (200), draws (800, after warmup), seed,
saveEffects (FALSE; whether to keep every draw of every random
effect rather than only their summary – either way they are each
parameter's deviation from its population value on the raw scale, per
subject or group, in fit$sample$effects, effect_mean and
effect_sd) and processes (TRUE).
What is sampled is what the fit's intoverpop says, read as
ctFit(optimize = FALSE) reads it: the filter's marginal for
'augmented', the Laplace marginal for a fit that named
'laplace' (an approximate posterior whose dimension does not grow
with the number of subjects), and the joint posterior over population
parameters and every subject's random effects for 'none' or
for a Laplace route that intoverpop = 'auto' chose, where the
Laplace fit only places the chains. The argument intoverpop overrides it
in the same words: 'none' for the joint posterior or
'laplace' for the Laplace marginal on a Laplace fit;
'augmented' needs a fit made that way, and an augmented fit takes
nothing else. Missing TI predictor values that the fit imputed are sampled
too, unless the fit's optimcontrol$tipredMissing or
control$tipredMissing is 'impute'.
The kernel. control$sampler chooses it for the joint
posterior. By default it is 'map'. 'saem' draws the random effects by
SAEM's Metropolis-within-Gibbs sweeps and the parameters given them by NUTS,
with moves that re-express the effects for each level's means and scales;
'nuts' runs NUTS on the parameters and every random effect at once;
'map' runs NUTS through a learnt map, with the random effects the
Kalman filter can integrate exactly (on intercepts, initial means, manifest
means and time dependent predictor effects, in a linear Gaussian model)
integrated out and the rest partially non-centred, unit by unit, from
Gaussian summaries of each subject's likelihood learnt in warm-up; it
starts from the fit's estimate (placement = 'fit') and reports every
random effect, the integrated ones drawn from their exact conditional.
All draw the same posterior. In comparisons on variance, nested,
categorical and nonlinear models the map reached the default effective
sample size where SAEM's kernel often ran out of draws, and was usually the
faster; SAEM's kernel was the more reliable and the faster than
'nuts', which mixes poorly on the joint vector. A marginal target is sampled by tempered
sequential Monte Carlo where the interval check of 'checked' named
directions in which the posterior departs from the fit's Hessian, and by
NUTS where it named none, or where the call sets a control only NUTS reads
(chains, warmup, stepsize, adapt_metric,
adapt_effects, settleTol); sampler = 'nuts' or
'smc' chooses, and 'smc' beside chains,
warmup or stepsize is an error, since it reads none of
them. A fit made without that check gets one first, at a few hundred
gradients. NUTS starts from a metric set to the widths the check measured
along those directions, or, where 'checked' moved the normal to the
posterior's moments, to that normal's covariance. Tempered SMC carries
draws from that normal to the posterior by stages of NUTS moves,
particles (200) chains a stage, keeping every state they visit,
then runs as many chains on as the effective sample size target needs.
It is for posteriors NUTS does not
converge on from the normal – a mass far from the mode, a loading shell –
and costs about what NUTS does in gradients. Its
particles move on a coreset of the units (coreset, TRUE): the
full density, evaluated once a particle a stage, corrects the moves
exactly, so a fit with many units pays a fraction of a gradient a move and
coreset = FALSE is the oracle. Its chains are short and start
from particles already drawn from the posterior, so it reports no
R-hat; the effective sample size is its stop. NUTS
too runs its trajectories on a coreset, fitted before warm-up and again
during it, each draw's end accepted or refused by the full density, which
keeps the draws exact whatever the coreset. adapt_metric, adapt_effects and
settleTol belong to NUTS's warmup and are refused with SAEM's kernel and with
tempered SMC, and the latter two with the map. control$placement says
where the chains start for SAEM's kernel and NUTS: 'saem', the
default on the joint posterior,
runs SAEM from the fit's estimate and starts each chain from SAEM's
estimate and its draws of the random effects; 'fit' starts them
around the fit's own estimate, and is the only placement for a marginal
target.
When it stops. A run stops once every parameter's effective sample
size reaches minESS (200) and the chains' R-hat is below
rhatTarget (1.01) – meanESS adds a target for the average –
within a budget of four times draws per chain, or maxDraws
when given; minESS = 0 takes exactly draws. A run that
reaches its budget short of the target warns. settleTol ends warmup
early once the metric stops moving (off by default). Lower targets give a
quicker, approximate posterior, and say how approximate: a reported
quantile's Monte Carlo error is about 1.96 * 2.1 / sqrt(ESS)
posterior sds at the 5% and 95% points and 1.96 * 1.25 / sqrt(ESS)
at the median, and chains whose means disagree by d posterior sds
give an R-hat of about sqrt(1 + d^2). So minESS = 50,
rhatTarget = 1.07 aims at about half a posterior sd at the centre and more
in the tails, and the defaults at about a fifth at the centre and two
fifths in the tails. Short runs are usually limited by whether the chains
agree, so R-hat is the binding check.
Processes. By default the chains run at once in this session,
sharing its cores. With processes = TRUE they run in up to
cores worker processes instead, each starting its own Julia session
– a fixed cost that a short run does not recover – and a worker runs its
share of the chains in turn, so four chains on two cores run two at a time.
ctJuliaKill('workers') releases the worker processes, which
persist for the next call.
Backend differences
The methods are the same on both backends and the covariance they produce is comparable, but some things differ and are worth knowing before comparing output.
Where the result is stored. A ctStanFit comes back with
fit$stanfit$cov, fit$stanfit$rawposterior and
fit$stanfit$uncertainty; a ctJuliaFit with
fit$estimate$cov, fit$estimate$se,
fit$estimate$rawposterior and fit$uncertainty. Both record the
resolved settings in $uncertainty$settings. On both backends the
draws, the covariance and the standard errors are labelled by raw parameter,
as is coef(fit), so fit$estimate$se['drift'] or
apply(fit$estimate$rawposterior, 2, quantile) reads without counting
columns. The two backends spell the population-SD and correlation blocks
differently (popsd_x/rawcor_x__y on julia,
x_SD/y_x_corr on stan); the order is the same.
The Hessian. The stan path finite-differences its gradient with a
single global step (control$hessianStep). The julia engine
differentiates its own reverse-mode gradient in forward mode, so its
Hessian is exact; control$analyticHessian = FALSE falls back to the
shared finite difference for comparison. The two agree to about 1e-4 on a
well-conditioned model.
Directions with no curvature. A direction whose curvature is
negligible against the sharpest one is left out of the inversion rather
than floored at control$ridge, so the parameters that carry it come
back with no spread at all instead of a standard error of 1/ridge.
Floored, that number leaks into the parameters the data does
determine, by an amount rounding decides. A direction with little
curvature along which the likelihood itself is measured flat – within the
likelihood-ratio bar of 1.92 over four raw units on one side, following the
ridge where it curves – is treated the same way. $uncertainty$cov
records which directions were dropped, and fit$identifiability names
the parameters.
Whether the intervals are as wide as the curvature allows. A julia
fit carries fit$uncertainty$intervalcheck: for each raw parameter,
the reported standard error against 1/sqrt(information[i,i]), the
width that parameter's own curvature supports. Their ratio is 1 when the
parameter is separable from the rest and grows without bound as it stops
being; anything past about 100 means the reported width comes from the
entanglement rather than from the data, and will not repeat between runs.
$nullmass is each coordinate's share of the directions left out of
the inversion, and $unidentified names those with enough of it that
their true asymptotic variance is infinite; summary() reports their
sd, interval and z as NA rather than as precisely estimated.
Backend-specific arguments. method = 'fullbootstrap' and
its control$bootstrapFitCores / control$bootstrapTol, and
control$parsteps, are stan-only and are refused by name on a
ctJuliaFit; method = 'sample' and
control$analyticHessian are julia-only. cores means R worker
processes on stan and engine threads on julia. The IMIS proposal defaults
also differ: imisScaleInit = 1.1 and imisTailScale = 1.1 on
stan; on julia the same for 'checked', whose proposal starts at the
widths its check measured, and 1.5 and 1.2 for 'is',
whose proposal starts at the Hessian curvature, the wider pair being what a
small-sample posterior wider than that curvature needs to be seen at all.
Set them explicitly to compare the two. Transformed-parameter
summaries are refreshed on stan and not on julia; the raw-scale covariance
and draws are complete on both.
See also
ctFitAddSamples is the deprecated stan-only
predecessor of method = 'stored'. ctFit for
optimize = FALSE, which reaches method = 'sample'
through the same pipeline that placed the fit being sampled.
ctLaplaceCheck and ctParticleLik measure the
approximations a julia fit's likelihood makes, which
intoverpop = 'quadrature' and filter = 'particle' correct.
Examples
# Redraw from the covariance already on the fit, evaluating no model:
fit <- ctFitUncertainty(ctstantestfit, method = 'stored',
finishsamples = 200)
fit$stanfit$uncertainty$settings$redrawn
# \donttest{
# The Hessian's normal, checked, and importance sampled where it is wrong
fit <- ctFitUncertainty(ctstantestfit, method = 'checked')
summary(fit)$popmeans
# Needs a working julia backend, so the example is inert where Julia is
# absent -- including on CRAN, whose check machines have none.
if (isTRUE(ctJuliaStatus()$available)) {
model <- ctModel(type = 'ct', manifestNames = 'Y1', latentNames = 'eta1',
LAMBDA = matrix(1))
model$pars$indvarying <- FALSE
jfit <- ctFit(ctstantestdat, model, backend = 'julia', cores = 1,
priors = TRUE)
# Posterior draws by MCMC, with lower targets for a quick look
jfit <- ctFitUncertainty(jfit, method = 'sample', cores = 1,
control = list(chains = 2, minESS = 50, rhatTarget = 1.05))
jfit$sample
# Julia keeps running between calls, holding what it has compiled;
# this ends it.
ctJuliaKill("session")
}
# }