Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

**Class: **LinearMixedModel

Generate random responses from fitted linear mixed-effects model

`ysim = random(lme)`

`ysim = random(lme,tblnew)`

`ysim = random(lme,Xnew,Znew)`

`ysim = random(lme,Xnew,Znew,Gnew)`

returns
a vector of simulated responses `ysim`

= random(`lme`

)`ysim`

from the
fitted linear mixed-effects model `lme`

at the
original fixed- and random-effects design points, used to fit `lme`

.

`random`

simulates new random-effects vector
and new observation errors. So, the simulated response is

$${y}_{sim}=X\widehat{\beta}+Z\widehat{b}+\epsilon ,$$

where $$\widehat{\beta}$$ is the estimated fixed-effects
coefficients, $$\widehat{b}$$ is the new random
effects, and *ε* is the new observation error.

`random`

also accounts for the effect of observation
weights, if you use any when fitting the model.

returns
a vector of simulated responses `ysim`

= random(`lme`

,`Xnew`

,`Znew`

)`ysim`

from the
fitted linear mixed-effects model `lme`

at the
values in the new fixed- and random-effects design matrices, `Xnew`

and `Znew`

,
respectively. `Znew`

can also be a cell array of
matrices. Use the matrix format for `random`

if you
use design matrices for fitting the model `lme`

.

returns
a vector of simulated responses `ysim`

= random(`lme`

,`Xnew`

,`Znew`

,`Gnew`

)`ysim`

from the fitted
linear mixed-effects model `lme`

at the values in
the new fixed- and random-effects design matrices, `Xnew`

and `Znew`

,
respectively, and the grouping variable `Gnew`

.

`Znew`

and `Gnew`

can also
be cell arrays of matrices and grouping variables, respectively.

Was this topic helpful?