Recomputes the approximate raw-parameter uncertainty for an optimized
ctFit object and refreshes the approximate raw-parameter
samples.
ctOptimUncertainty(
fit,
uncertainty = c("hessian", "surrogate", "is", "bootstrap", "fullbootstrap", "sandwich",
"opg"),
draws = c("auto", "normal", "empirical", "imis"),
finishsamples = NULL,
cores = NULL,
control = list(),
verbose = 0,
...
)Updated ctStanFit object.
Optimized ctStanFit object.
Uncertainty approximation. 'hessian' uses the
finite-difference Hessian, 'surrogate' fits a local quadratic
surrogate around the optimum, 'is' uses Hessian-based importance
sampling and computes uncertainty from the weighted importance-sampling
distribution, 'bootstrap' uses one-step score bootstrap draws with
Hessian bread, 'fullbootstrap' resamples subjects and fully
re-optimizes each sample from the original maximum likelihood or MAP
estimate using mize L-BFGS, 'sandwich' uses Hessian bread with score
covariance meat, and 'opg' uses an OPG-style score information
approximation.
Approximate raw-parameter draw method. 'auto' uses
empirical draws for uncertainty='bootstrap' and
uncertainty='fullbootstrap' and normal draws otherwise.
'normal' draws from a multivariate normal using the selected
covariance, 'empirical' uses empirical draws when available, and
'imis' runs the importance sampler using the selected covariance as
proposal. For uncertainty='is', draws is set to 'imis'.
Number of approximate raw-parameter samples. If
NULL, the existing number of rows in fit$stanfit$rawposterior
is reused when available; otherwise 1000 samples are used.
Number of cores. If NULL, one core is used. Hessian,
surrogate, and IMIS calculations use these cores by splitting each
log-probability/gradient evaluation across subjects. Score-based methods use
these cores for score contribution calculations. Transformed-quantity
calculations also use these cores.
List of method-specific options. Useful entries include
ridge, hessianStep, surrogateNpoints,
surrogateScale, surrogateProfile,
surrogateProfileTargetDrop, surrogateProfileMaxStep,
bootstrapFitCores, bootstrapTol, imisMaxIter,
imisScaleInit, imisTailScale, isESS, and
isitersize. Omitted entries use
ridge = 1e-8, hessianStep = 1e-3,
surrogateScale = .5, surrogateNpoints = NULL,
surrogateProfile = TRUE,
surrogateProfileTargetDrop = NULL,
surrogateProfileMaxStep = 64,
bootstrapFitCores = 1, bootstrapTol = 1e-5,
imisMaxIter = 50, imisScaleInit = 1.1,
imisTailScale = 1.1, isESS = 100, and
isitersize = 1000. When
surrogateNpoints is NULL, the
surrogate uses at least max(4 * npars, 50) local directions. The
surrogate is fit in whitened coordinates relative to the proposal covariance.
Each direction is radially adjusted with a small evaluation budget so that
the retained points are close to an informative local log-probability drop,
rather than relying on a random cloud to land in the desired range. With
surrogateProfile = TRUE, all fitted surrogate curvature directions
are then profiled until they reach surrogateProfileTargetDrop, or the
surrogate target drop when NULL. The profile search uses the fitted
surrogate curvature to choose direction-specific starting distances, so very
flat directions can be checked beyond surrogateProfileMaxStep when
the surrogate itself predicts that a larger distance is needed. If the
observed profile is still flatter than the fitted surrogate predicted, a
small magnitude-adjusted expansion budget is used before reporting a missed
target. parsteps may be supplied internally to keep stepwise-fixed
raw parameters fixed while estimating uncertainty for the remaining
parameters.
Hessian-based covariance construction first attempts the unmodified
solve(-hessian) covariance and a Cholesky check. It warns when
numerical repair is needed, such as positive-definite projection, ridge
flooring of information eigenvalues, or fallback to MASS::ginv;
diagnostics are stored in
fit$stanfit$uncertainty$details$covariance.
Score-based methods use subject-level score contributions when there are
at least two subjects; single-subject models warn and use case-level
contributions. Score-based methods warn when there are fewer than ten
independent subjects or no more score rows than raw parameters. Full
bootstrap requires at least two subjects and warns below ten independent
subjects. Bootstrap-style methods require at least two returned samples /
refits.
Integer controlling progress detail.
Unused.