ppc_resp_irtree: Posterior predicitve checks of response frequencies.

Description Usage Arguments Value Examples

View source: R/postpred.R

Description

This function summarizes posterior predicted responses (1, ..., 5) for every item and category. For a single iteration/replication, this results in a response distribution (barplot); across multiple iterations, quantiles (using probs) are calculated. These quantiles should overlap the observed frequencies.

Usage

1
ppc_resp_irtree(ppc = NULL, probs = NULL)

Arguments

ppc

List. Output from ppc_irtree that contains posterior predicted responses with dimensions R x N x J (for N persons, J items, and R replications/iterations).

probs

Numeric. Vector of probabilities (passed to quantile) that is used to calculate quantiles of the posterior predictive distribution. Argument may be named (used to generate colnames). Defaults to c(.025, .975, .16, .84).

Value

Returns a data frame containing the specified quantiles of the posterior predictive distribution for every category of every item.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## 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 checking
res3 <- post_prob_irtree(res2)
res4 <- ppc_irtree(prob = res3, statistics = "resp", fit = res1)
res5 <- ppc_resp_irtree(res4)

library(ggplot2)
ggplot(res5, aes(x = Categ, y = Obs, ymin = q16, ymax = q84)) +
    geom_col() +
    geom_errorbar() +
    geom_point(aes(y = q50)) + 
    facet_wrap(~ Item)

## End(Not run)

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