ppp_binom: Posterior Predictive p-Values

View source: R/posterior_predictive.R

ppp_binomR Documentation

Posterior Predictive p-Values

Description

Uses posterior samples to get posterior-predicted frequencies and compare the Pearson's X^2 statistic for (1) the observed frequencies vs. (2) the posterior-predicted frequencies.

Usage

ppp_binom(prob, k, n, by)

ppp_multinom(prob, k, options, drop_fixed = TRUE)

Arguments

prob

vector with probabilities or a matrix with one probability vector per row. For rpbinom: probabilities of a success for each option. For rpmultinom: probabilities of all categories excluding the last category for each option (cf. drop_fixed). See also sampling_binom and sampling_multinom.

k

vector of observed response frequencies.

n

integer vector, specifying the number of trials for each binomial/multinomial distribution Note that this is the size argument in rmultinom, cf. Multinom.

by

optional: a vector of the same length as k indicating factor levels by which the posterior-predictive checks should be split (e.g., by item sets).

options

number of observable categories/probabilities for each item type/multinomial distribution, e.g., c(3,2) for a ternary and binary item.

drop_fixed

whether the output matrix includes the last probability for each category (which is not a free parameter since probabilities must sum to one).

References

Myung, J. I., Karabatsos, G., & Iverson, G. J. (2005). A Bayesian approach to testing decision making axioms. Journal of Mathematical Psychology, 49, 205-225. doi: 10.1016/j.jmp.2005.02.004

See Also

sampling_binom/sampling_multinom to get posterior samples and rpbinom/rpmultinom to get posterior-predictive samples.

Examples

# uniform samples:  p<.10
prob <- matrix(runif(300 * 3, 0, .1), 300)
n <- rep(10, 3)
ppp_binom(prob, c(1, 2, 0), n) # ok
ppp_binom(prob, c(5, 4, 3), n) # misfit

# multinomial (ternary choice)
prob <- matrix(runif(300 * 2, 0, .05), 300)
ppp_multinom(prob, c(1, 0, 9), 3) # ok

multinomineq documentation built on Nov. 22, 2022, 5:09 p.m.