Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

Matrix (version 0.98-7)

simulate: Simulate responses from a fitted model

Description

This generic function generates a sample of responses from a fitted model object using the parameter estimates from the fit. Typically these simulated responses are used in a parametric bootstrap sample of a test statistic.

Usage

simulate(object, nsim, seed, ...)

Arguments

object
an object representing a fitted model.
nsim
number of response vectors to simulate. Defaults to 1.
seed
an integer that will be used in a call to set.seed before simulating the response vectors. The value is saved as an attribute named "seed" in the returned value. Defaults to a random integer between 0 a
...
additional optional arguments.

Value

  • A data frame with nsim columns and nobs, the number of observations in the fitted model object, rows.

Examples

Run this code
(fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0 + Days|Subject), sleepstudy))
sim2 <- simulate(fm2, nsim = 4)
head(sim2)
tail(sim2)

Run the code above in your browser using DataLab