Fixes one raw parameter at a sequence of values, re-optimising all the
others at each, and reports what the likelihood does. This answers the
identification question directly rather than through the curvature at the
estimate, which on a flat direction measures the transform rather than the
data – see the note in ctFitUncertainty on flat directions.
Usage
ctFitProfile(
fit,
parameters = NULL,
points = 8L,
step = NULL,
growth = 1.6,
level = 0.95,
maxiter = 500L,
verbose = 0,
cores = getOption("mc.cores", 2L)
)Arguments
- fit
a
ctJuliaFit.- parameters
which parameters to profile: raw parameter names, indices,
NULLfor all of them, or"flagged"for only those the fit's own diagnostics already doubt – the saturated coordinates, the unidentified directions, and the intervals wider than the curvature supports."flagged"is the cheap internal use; naming parameters is the usual one. Profiling every parameter of a large model is a great many optimisations.- points
maximum points per side.
- step
first displacement, in raw units.
NULLtakes half of each parameter's own standard error where the fit has one, so an identified parameter gets several points inside its interval instead of crossing the bar on the first step; it falls back to 0.5 raw, which is a small move in ctsem's standardised raw coordinates, when there is no curvature to ask.- growth
factor the step is multiplied by after a point that moved the likelihood by less than the target, so a flat direction is walked out quickly rather than in a hundred equal steps.
- level
confidence level setting the likelihood-ratio bar.
- maxiter
iteration cap for each constrained optimisation.
- verbose
0 for silence, 1 to report each point as it is computed.
- cores
The most CPU cores the profile uses at once. The walks – each parameter's two sides – run one after another in this session, on that many engine threads. Only when the fit itself took more than five minutes to optimise do they run up to
coresat a time instead, each in a background R session with a one-thread Julia (it needs the future package; the sessions persist for the next call, andctJuliaKill('workers')releases them): a session costs up to a minute to start. The walks are independent, so the profile is the same either way, except that with several sessions every walk finishes before$betteris reported.
Value
An object of class ctFitProfile, which
print and plot both understand. $profile is one row
per point (parameter, raw value, transformed value where the coordinate
has one, log likelihood, drop from the estimate); $summary is one
row per parameter (verdict, limits, how far each side was walked); and
$better is NULL unless a constrained fit beat the estimate,
in which case it holds that point and the run stopped there.
Details
Each point is a constrained optimisation, so a profile can discover that the
fit was not at a maximum. When that happens the run stops and the better
point is returned in $better; refit from there and profile again.
Examples
# \donttest{
# 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
fit <- ctFit(ctstantestdat, model, backend = 'julia', cores = 1)
# Two named parameters; parameters = "flagged" profiles only those the
# fit's own diagnostics doubt, and NULL profiles every one.
result <- ctFitProfile(fit, parameters = c('drift_eta1', 'mm_Y1'))
print(result)
plot(result)
# Julia keeps running between calls, holding what it has compiled;
# this ends it.
ctJuliaKill("session")
}
# }