simulate-nlme.RdThese methods generate simulated response vectors from
the multivariate normal distribution implied by a fitted
gls or lme model. The simulation accounts for the
fitted mean and covariance structure of the model.
A data frame with nsim simulated response vectors as
columns. Each column represents one simulated replicate of the
response under the model's implied distribution.
For gls objects, the mean vector is the
fitted values and the covariance matrix is obtained via
cov_matrix(). For lme objects, the mean vector
is the level-0 (population) predicted values and the covariance
matrix is also obtained via cov_matrix().
if (require(nlme)) {
NSIM <- 10
## Example for gls
fit_gls <- gls(distance ~ age, data = Orthodont)
sims_gls <- simulate(fit_gls, nsim = NSIM, seed = 123)
head(sims_gls)
## Example for lme
fit_lme <- lme(distance ~ age, random = ~ 1 | Subject, data = Orthodont)
sims_lme <- simulate(fit_lme, nsim = NSIM, seed = 123)
head(sims_lme)
}
#> Error in UseMethod("simulate"): no applicable method for 'simulate' applied to an object of class "gls"