post_prob_irtree: Calculate posterior predictive probabilities.

Description Usage Arguments Value Examples

View source: R/postpred.R

Description

Function takes an MCMC list of posterior samples and calculates the model-predicted probabilities. This can either be done for the persons in the sample or for out-of-sample predictions for new persons (new_theta = TRUE).

Usage

1
2
3
post_prob_irtree(fit_sum = NULL, mcmc.objects = NULL, iter = 100,
  N = NULL, traitItem = NULL, revItem = NULL, fitModel = NULL,
  new_theta = FALSE)

Arguments

fit_sum

List. Output from summarize_irtree_fit that contains mcmc.objects.

mcmc.objects

a list of MCMC or runjags objects, all with the same number of chains and matching variable names, or a single MCMC object/list or runjags object. No default.

iter

Numeric. Number of iterations to use, the maximum is the total number of retained iterations (via fit_irtree).

N

Numeric. Number of persons for whom posterior predictives should be drawn. Should be equal to the number of persons in the sample if new_theta = FALSE.

traitItem

vector of length J specifying the underlying traits (e.g., indexed from 1...5). Standard: only a single trait is measured by all items. If the Big5 are measured, might be something like c(1,1,1,2,2,2,...,5,5,5,5)

revItem

vector of length J specifying reversed items (1=reversed, 0=regular)

fitModel

Character. Either "2012" (Boeckenholt Model without acquiescence) or "ext" (Acquiescence Model). Details about all implemented models are described in the section Models below.

new_theta

Logical. Wheter to calculate the probabilities for the persons in the sample or for out-of-sample predictions for N 'new' persons (new_theta = TRUE).

Value

Returns an array of probabilities of dimension iter x N x J x 5 (for J items with 5 response categories).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
J <- 10
betas <- cbind(rnorm(J, .5), rnorm(J, .5), rnorm(J, 1.5), rnorm(J, 0))
dat <- generate_irtree_ext(N = 20, J = J, betas = betas, beta_ARS_extreme = .5)

# fit model
res1 <- fit_irtree(dat$X, revItem = dat$revItem, M = 200)
res2 <- summarize_irtree_fit(res1)

# posterior predictive probabilities
res3 <- post_prob_irtree(res2)
dim(res3)

## End(Not run)

hplieninger/mpt2irt documentation built on Aug. 4, 2018, 10:52 a.m.