Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

posteriorPredictive

Get Posterior Predictive Samples


Description

Draw predicted frequencies based on posterior distribution of (a) individual estimates (default) or (b) for a new participant (if numItems is provided; does not consider continuous or discrete predictors in traitMPT).

Usage

posteriorPredictive(
  fittedModel,
  M = 100,
  numItems = NULL,
  expected = FALSE,
  nCPU = 4
)

Arguments

fittedModel

fitted latent-trait or beta MPT model (traitMPT, betaMPT)

M

number of posterior predictive samples. As a maximum, the number of posterior samples in fittedModel is used.

numItems

optional: a vector with the number of items per MPT tree to sample predicted data for a new participant (first, a participant vector θ is sampled from the hierarchical posterior; second, frequencies are generated).

expected

if TRUE, the expected frequencies per person are returned (without additional sampling from a multinomial distribution)

nCPU

number of CPUs used for parallel sampling. For large models and many participants, this requires considerable computer-memory resources (as a remedy, use nCPU=1).

Value

by default, a list of M posterior-predictive samples (i.e., matrices) with individual frequencies (rows=participants, columns=MPT categories). For M=1, a single matrix is returned. If numItems is provided, a matrix with samples for a new participant is returned (rows=samples)

Examples

## Not run: 
# add posterior predictive samples to fitted model
#     (facilitates plotting using ?plotFit)
fittedModel$postpred$freq.pred <-
     posteriorPredictive(fittedModel, M=1000)

## End(Not run)

TreeBUGS

Hierarchical Multinomial Processing Tree Modeling

v1.4.7
GPL-3
Authors
Daniel W. Heck [aut, cre] (<https://orcid.org/0000-0002-6302-9252>), Nina R. Arnold [aut, dtc], Denis Arnold [aut], Alexander Ly [ctb], Marius Barth [ctb] (<https://orcid.org/0000-0002-3421-6665>)
Initial release
2021-01-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.