simulate.mpt: Simulate Responses from MPT Models

View source: R/mpt.R

simulate.mptR Documentation

Simulate Responses from MPT Models

Description

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

Usage

## S3 method for class '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.

Details

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

Value

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

See Also

mpt, rmultinom.

Examples

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)

mpt documentation built on Oct. 11, 2024, 5:07 p.m.