lme4 (version 1.0-5)

simulate.merMod: Simulate responses from a merMod object

Description

Simulate responses from the model represented by a fitted model object

Usage

## S3 method for class 'merMod':
simulate(object, nsim = 1, seed = NULL,
    use.u = FALSE, ...)

Arguments

object
a fitted model object
nsim
positive integer scalar - the number of responses to simulate
seed
an optional seed to be used in set.seed immediately before the simulation so as to generate a reproducible sample.
use.u
(logical) if TRUE, generate a simulation conditional on the current random-effects estimates; if FALSE generate new Normally distributed random-effects values
...
optional additional arguments, none are used at present

Examples

Run this code
## test whether fitted models are consistent with the
##  observed number of zeros in CBPP data set:
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
             data = cbpp, family = binomial)
gg <- simulate(gm1,1000)
zeros <- sapply(gg,function(x) sum(x[,"incidence"]==0))
plot(table(zeros))
abline(v=sum(cbpp$incidence==0),col=2)

Run the code above in your browser using DataLab