mpt (version 0.6-2)

simulate.mpt: Simulate Responses from MPT Models

Description

Simulates responses from the distribution corresponding to a fitted mpt model object.

Usage

# S3 method for mpt
simulate(object, nsim, seed, pool = TRUE, …)

Arguments

object

an object of class mpt, typically the result of a call to mpt.

nsim, seed

currently not used.

pool

logical, if TRUE (default), pooled responses (summed across respondents) are returned.

further arguments passed to or from other methods. None are used in this method.

Value

A named vector of (pooled) responses. Names identify the tree from which responses were simulated.

Details

Responses are simulated by (repeatedly) applying rmultinom with sizes taken from the original sample and probabilities computed from the model object.

See Also

mpt, rmultinom.

Examples

Run this code
# NOT RUN {
data(retroact)
 
m <- mpt(mptspec(
  c*r,
  (1 - c)*u^2,
  2*(1 - c)*u*(1 - u),
  c*(1 - r) + (1 - c)*(1 - u)^2,
  u,
  1 - u
), retroact[retroact$lists == 1, ])

simulate(m)

## Parametric bootstrap of goodness-of-fit test
LR.stat <- replicate(200, deviance(mpt(m$spec, simulate(m))))

hist(LR.stat, border="white", freq=FALSE, breaks=20,
     main="Parametric bootstrap")
curve(dchisq(x, df=1), add=TRUE)
abline(v=deviance(m), lty=2)
# }

Run the code above in your browser using DataLab