Fits one ctsem model per subject using the model prior, estimates the empirical marginal distribution of the raw parameters, then fits each subject again using the resulting empirical Bayes prior.
ctEmpiricalBayesFit(
datalong,
model,
subjects = "all",
priors = TRUE,
optimize = TRUE,
cores = 2,
subjectFitArgs = list(),
Npasses = 2,
ebUse = c("rawest", "rawposterior"),
ebRobust = TRUE,
ebOutlierMAD = 6,
ebOutlierQuantiles = c(0.025, 0.975),
ebWinsorize = TRUE,
minsd = 1e-06,
verbose = 0,
progress = TRUE,
...
)Object of class ctEmpiricalBayesFit, containing the subject
fit lists and metadata. $initialfits contains the first-pass model
prior fits, $fits contains the final empirical Bayes prior fits, and
$passfits contains every pass. Use summary() to compute final
transformed-parameter means, SDs, covariances, correlations, and outlier
diagnostics.
Long format data containing multiple subjects.
Model object from ctModel. Time independent
predictors are not supported. A random-effect-free copy of this model is used
for the per-subject fits.
Vector of subject identifiers to fit, or 'all'.
Logical. Passed to ctFit; defaults to TRUE.
Logical. Passed to ctFit; defaults to
TRUE.
Number of subjects to fit in parallel. Each individual
subject-level ctFit call uses one core.
Named list of additional arguments passed to each
ctFit call. For optimized fits, optimcontrol$stochastic
defaults to FALSE for all EB passes unless supplied here or in
.... First-pass fits force optimcontrol$estonly=TRUE.
Total number of subject-wise fitting passes. The default
2 fits once with the model prior, builds a marginal empirical Bayes
prior, then fits once with that prior. Values above 2 repeatedly map
the previous pass estimates back to the original raw scale, rebuild the
marginal EB prior, and refit.
'rawest' to build the empirical Bayes prior from first
pass point estimates, or 'rawposterior' to pool raw posterior samples.
Logical. If TRUE, the empirical Bayes prior is built from robust raw summaries after outlier handling.
Positive numeric. Raw values farther than this
many MAD-scaled deviations from the median are treated as outliers. Use
Inf or NULL to disable this rule.
Length two numeric vector of lower and upper
quantiles used to bound first-pass raw values, or NULL to disable.
Logical. If TRUE, outlying first-pass raw values are clamped to the outlier bounds before computing the EB prior. If FALSE, they are set to missing for EB prior construction.
Lower bound used for empirical raw SDs before model adjustment.
Integer from 0 to 2. Passed to ctFit.
Logical. If TRUE, report the current EB fitting stage and overwrite a single console line with the subject fitting percentage.
Additional arguments passed to each ctFit call.
# \donttest{
model <- ctModel(type='ct', manifestNames='Y1', LAMBDA=matrix(1))
eb <- ctEmpiricalBayesFit(ctstantestdat, model, cores=2,
subjectFitArgs=list(optimcontrol=list(finishsamples=20)))
summary(eb)
# }
Run the code above in your browser using DataLab