Skip to contents

Extract an array of subject specific parameters from a fit from ctFit, on either backend. ctStanSubjectPars is maintained as a backward-compatible alias.

Usage

ctSubjectPars(
  fit,
  pointest = TRUE,
  cores = getOption("mc.cores", 2L),
  nsamples = "all",
  level = NULL,
  uncertainty = NULL
)

Arguments

fit

A fit from ctFit.

pointest

if TRUE, returns only the set of individual difference parameters based on the max a posteriori estimate (or the median if sampling approaches were used).

cores

Number of cores to use. backend='stan' only – a julia fit already carries the subject matrices, so there is nothing here to split, and cores is refused by name rather than accepted and ignored.

nsamples

Number of samples to calculate parameters for. Not used if pointest=TRUE.

level

For a model with nested ids (id = c('person', 'couple') in ctModel), the level to report: the subject level (the default, the first id) or a grouping level above it, which gives each group's own parameter values – the population values shifted by that group's random effects and those of the levels above it, without the subject-level ones or TI predictor effects. Grouping levels need a backend='julia' fit; their draws take uncertainty as a subject's do.

uncertainty

For backend='julia' fits with pointest=FALSE: what the draws carry. 'total' (the default) pairs each draw of the population parameters with a draw of each subject's random effects from their posterior given that subject's data – plausible values, whose spread is both the population parameters' uncertainty and how well the subject's own data determine its parameters. 'conditional' keeps the population parameters at the estimate and draws only the subject's effects; 'population' varies only the population parameters, with each subject at its estimate given them, which understates a subject's uncertainty whenever its own data say little. A fit that sampled its random effects (optimize=FALSE) already has draws of both, so only 'total' applies there.

Value

an nsamples by nsubjects by nparams array, with the subjects (or groups, for a grouping level) labelled by their ids in the data.

Details

This function returns the estimates of individual parameters, taking into account any covariates and random effects, at every level of a nested model.

A julia fit also stores, for every level with random effects, each group's conditional posterior of its effects on the raw parameter scale – fit$randomeffects, one entry per level with the groups' mean deviation from the population value and their covariance packed column by column (cov). The draws with uncertainty='total' are built from the same posterior.

Examples

indpars <- ctSubjectPars(ctstantestfit)
dimnames(indpars)
plot(indpars[1,,'cint1'],indpars[1,,'cint2'])