add_ibbu_stanfit_draws: Add MCMC draws from an NIW IBBU stanfit to a tibble.

View source: R/get-info-from-NIW-IA-stanfit.R

add_ibbu_stanfit_drawsR Documentation

Add MCMC draws from an NIW IBBU stanfit to a tibble.

Description

Add MCMC draws of all parameters from incremental Bayesian belief-updating (IBBU) to a tibble. Both wide ('wide=TRUE') or long format ('wide=FALSE') can be chosen as output. By default all post-warmup draws are returned, but if 'summarize=TRUE' then just the mean of each parameter is returned instead.

Usage

add_ibbu_stanfit_draws(
  fit,
  categories = get_category_levels_from_stanfit(fit),
  groups = get_group_levels_from_stanfit(fit, include_prior = TRUE),
  which = if ("prior" %in% groups) {
     if (length(groups) > 1) 
         "both"
    
    else "prior"
 } else "posterior",
  ndraws = NULL,
  untransform_cues = TRUE,
  summarize = FALSE,
  wide = FALSE,
  nest = TRUE,
  seed = if (!is.null(ndraws)) runif(1, -1e+06, 1e+06) else NULL
)

Arguments

fit

NIW_ideal_adaptor_stanfit object.

categories

Character vector of categories for which draws are to be returned. (default: all categories)

groups

Character vector of groups for which draws are to be returned. (default: all groups)

which

DEPRECATED. Use 'groups' instead. Should parameters for the prior, posterior, or both be added? (default: '"posterior"')

ndraws

Number of random draws or 'NULL' if all draws are to be returned. Only 'draws' or 'ndraws' should be non-zero. (default: 'NULL')

untransform_cues

Should m_0 and S_0 be transformed back into the original cue space? (default: 'TRUE')

summarize

Should the mean of the draws be returned instead of all of the draws? (default: 'FALSE')

wide

Should all parameters be returned in one row? (default: 'FALSE')

nest

Should the category mean vectors and scatter matrices be nested into one cell each, or should each element be stored in a separate cell? (default: 'TRUE')

seed

A seed to use when subsampling draws (i.e. when ndraws is not NULL).

Details

By default, the category means and scatter matrices are nested, rather than each of their elements being stored separately ('nest=TRUE').

Value

tibble with post-warmup (posterior) MCMC draws of the prior/posterior parameters of the IBBU model (kappa, nu, m, S, lapse_rate). kappa and nu are the pseudocounts that determine the strength of the beliefs into the mean and covariance matrix, respectively. m is the mean of the multivariate normal distribution over category means mu. S is the scatter matrix that determines both the covariance of the category means mu, and the Inverse Wishart distribution over category covariance matrices Sigma.

The expected value of the category mean mu is m. The expected value of the category covariance matrix Sigma is S / (nu - D - 1), where D is the dimension of the multivariate Gaussian category. For details, \insertCite@see @murphy2012 p. 134;textualMVBeliefUpdatr.

References

\insertRef

murphy2012MVBeliefUpdatr

See Also

TBD


hlplab/MVBeliefUpdatr documentation built on March 29, 2025, 10:42 p.m.