Learn R Programming

tramME (version 0.0.1)

simulate.tramME: Simulate outcome variable from an estimated model

Description

Utilizes the simulation method of mlt. When the vector of random effects is supplied, the simulation is conditional on it.

Usage

# S3 method for tramME
simulate(object, nsim = 1, seed = NULL,
  newdata = NULL, ranef = NULL, what = c("response", "ranef",
  "joint"), bysim = TRUE, ...)

Arguments

object

A fitted tramME object.

nsim

number of samples to generate

seed

optional seed for the random number generator

newdata

an optional data frame of observations

ranef

If NULL, random effects are simulated from their estimated distribution for each draw in nsim, i.e. the simulation is from the marginal/joint distribution of the response (and random effects). Otherwise the simulation is conditional on the supplied random effects. When ranef = "zero", a vector of zeros with the right size is substituted.

what

Defaults to 'response'. 'ranef' returns draws from the random effects distribution, 'joint' results in simulated data from the joint distribution of random effects and responses. When it is set to other than 'response', ranef=NULL and bysim=TRUE must be set.

bysim

logical, if TRUE a list with nsim elements is returned, each element is of length nrow(newdata) and contains one sample from the conditional distribution for each row of newdata. If FALSE, a list of length nrow(newdata) is returned, its ith element of length nsim contains nsim samples from the conditional distribution given newdata[i,].

...

Additional arguments, passed to simulate.mlt.

Value

A simulate.tramME object with the structure defined by the inputs.

Examples

Run this code
# NOT RUN {
data("sleepstudy", package = "lme4")
fit <- BoxCoxME(Reaction ~ Days + (Days | Subject), data = sleepstudy)
sim <- simulate(fit, nsim = 10, seed = 123)
# }

Run the code above in your browser using DataLab