Generalized linear mixedeffects model class
A GeneralizedLinearMixedModel
object represents a regression model
of a response variable that contains both fixed and random effects. The object comprises
data, a model description, fitted coefficients, covariance parameters, design matrices,
residuals, residual plots, and other diagnostic information for a generalized linear
mixedeffects (GLME) model. You can predict model responses with the
predict
function and generate random data at new design points
using the random
function.
You can fit a generalized linear mixedeffects (GLME) model to sample data using
fitglme(
. For
more information, see tbl
,formula
)fitglme
.
tbl
— Input dataInput data, which includes the response variable, predictor variables,
and grouping variables, specified as a table or dataset array. The
predictor variables can be continuous or grouping variables (see Grouping Variables). You must specify
the model for the variables using formula
.
Data Types: table
formula
— Formula for model specification'y ~ fixed +
(random1grouping1) + ... + (randomRgroupingR)'
Formula for model specification, specified as a character vector or
string scalar of the form 'y ~ fixed + (random1grouping1) +
... + (randomRgroupingR)'
. For a full description, see
Formula.
Example: 'y ~ treatment +(1block)'
Coefficients
— Estimates of fixedeffects coefficientsEstimates of fixedeffects coefficients and related statistics, stored as a dataset array that has one row for each coefficient and the following columns:
Name
— Name of the coefficient
Estimate
— Estimated coefficient
value
SE
— Standard error of the
estimate
tStat
— tstatistic
for a test that the coefficient is equal to 0
DF
— Degrees of freedom associated with
the t statistic
pValue
— pvalue for
the tstatistic
Lower
— Lower confidence limit
Upper
— Upper confidence limit
To obtain any of these columns as a vector, index into the property using dot notation.
Use the coefTest
method to perform other
tests on the coefficients.
CoefficientCovariance
— Covariance of estimated fixedeffects vectorCovariance of estimated fixedeffects vector, stored as a matrix.
Data Types: single
 double
CoefficientNames
— Names of fixedeffects coefficientsNames of fixedeffects coefficients, stored as a cell array of character
vectors. The label for the coefficient of the constant term is
(Intercept)
. The labels for other coefficients
indicate the terms that they multiply. When the term includes a categorical
predictor, the label also indicates the level of that predictor.
Data Types: cell
DFE
— Degrees of freedom for errorDegrees of freedom for error, stored as a positive integer value.
DFE
is the number of observations minus the number of
estimated coefficients.
DFE
contains the degrees of freedom corresponding to
the 'Residual'
method of calculating denominator degrees
of freedom for hypothesis tests on fixedeffects coefficients. If
n is the number of observations and
p is the number of fixedeffects coefficients, then
DFE
is equal to n – p.
Data Types: double
Dispersion
— Model dispersion parameterModel dispersion parameter, stored as a scalar value. The dispersion parameter defines the conditional variance of the response.
For observation i, the conditional variance of the response y_{i}, given the conditional mean μ_{i} and the dispersion parameter σ^{2}, in a generalized linear mixedeffects model is
$$\mathrm{var}\left({y}_{i}{\mu}_{i},{\sigma}^{2}\right)=\frac{{\sigma}^{2}}{{w}_{i}}v\left({\mu}_{i}\right)\text{\hspace{0.17em}},$$
where w_{i} is the ith observation weight and
v is the variance function for the specified
conditional distribution of the response. The Dispersion
property contains an estimate of σ^{2} for the specified GLME model. The value of
Dispersion
depends on the specified conditional
distribution of the response. For binomial and Poisson distributions, the
theoretical value of Dispersion
is equal to σ^{2} =
1.0.
If FitMethod
is MPL
or
REMPL
and the
'DispersionFlag'
namevalue pair argument in
fitglme
is
true
, then a dispersion parameter is
estimated from data for all distributions, including binomial and
Poisson distributions.
If FitMethod
is
ApproximateLaplace
or
Laplace
, then the
'DispersionFlag'
namevalue pair argument in
fitglme
does not apply,
and the dispersion parameter is fixed at 1.0 for binomial and
Poisson distributions. For all other distributions,
Dispersion
is estimated from data.
Data Types: double
DispersionEstimated
— Flag indicating if dispersion parameter was estimatedtrue
 false
Flag indicating estimated dispersion parameter, stored as a logical value.
If FitMethod
is
ApproximateLaplace
or
Laplace
, then the dispersion parameter is
fixed at its theoretical value of 1.0 for binomial and Poisson
distributions, and DispersionEstimated
is
false
. For other distributions, the
dispersion parameter is estimated from the data, and
DispersionEstimated
is
true
.
If FitMethod
is MPL
or
REMPL
, and the
'DispersionFlag'
namevalue pair argument in
fitglme
is specified as
true
, then the dispersion parameter is
estimated for all distributions, including binomial and Poisson
distributions, and DispersionEstimated
is
true
.
If FitMethod
is MPL
or
REMPL
, and the
'DispersionFlag'
namevalue pair argument in
fitglme
is specified as
false
, then the dispersion parameter is fixed
at its theoretical value for binomial and Poisson distributions, and
DispersionEstimated
is
false
. For distributions other than binomial
and Poisson, the dispersion parameter is estimated from the data,
and DispersionEstimated
is
true
.
Data Types: logical
Distribution
— Response distribution name'Normal'
 'Binomial'
 'Poisson'
 'Gamma'
 'InverseGaussian'
Response distribution name, stored as one of the following:
'Normal'
— Normal distribution
'Binomial'
— Binomial
distribution
'Poisson'
— Poisson distribution
'Gamma'
— Gamma distribution
'InverseGaussian'
— Inverse Gaussian
distribution
FitMethod
— Method used to fit the model'MPL'
 'REMPL'
 'ApproximateLaplace'
 'Laplace'
Method used to fit the model, stored as one of the following.
'MPL'
— Maximum pseudo likelihood
'REMPL'
— Restricted maximum pseudo
likelihood
'ApproximateLaplace'
— Maximum
likelihood using the approximate Laplace method, with fixed effects
profiled out
'Laplace'
— Maximum likelihood using the
Laplace method
Formula
— Model specification formulaModel specification formula, stored as an object. The model specification formula uses Wilkinson’s notation to describe the relationship between the fixedeffects terms, randomeffects terms, and grouping variables in the GLME model. For more information see Formula.
Link
— Link function characteristicsLink function characteristics, stored as a structure containing the
following fields. The link is a function G
that links the
distribution parameter MU
to the linear predictor
ETA
as follows: G(MU) =
ETA
.
Field  Description 

Name  Name of the link function 
Link  Function that defines G 
Derivative  Derivative of G 
SecondDerivative  Second derivative of G 
Inverse  Inverse of G 
Data Types: struct
LogLikelihood
— Log of likelihood functionLog of likelihood function evaluated at the estimated coefficient values,
stored as a scalar value. LogLikelihood
depends on the
method used to fit the model.
If you use 'Laplace'
or
'ApproximateLaplace'
, then
LogLikelihood
is the maximized log
likelihood.
If you use 'MPL'
, then
LogLikelihood
is the maximized log likelihood
of the pseudo data from the final pseudo likelihood
iteration.
If you use 'REMPL'
, then
LogLikelihood
is the maximized restricted log
likelihood of the pseudo data from the final pseudo likelihood
iteration.
Data Types: double
ModelCriterion
— Model criterionModel criterion to compare fitted generalized linear mixedeffects models, stored as a table with the following fields.
Field  Description 

AIC  Akaike information criterion 
BIC  Bayesian information criterion 
LogLikelihood 

Deviance  –2 times LogLikelihood 
NumCoefficients
— Number of fixedeffects coefficientsNumber of fixedeffects coefficients in the fitted generalized linear mixedeffects model, stored as a positive integer value.
Data Types: double
NumEstimatedCoefficients
— Number of estimated fixedeffects coefficientsNumber of estimated fixedeffects coefficients in the fitted generalized linear mixedeffects model, stored as a positive integer value.
Data Types: double
NumObservations
— Number of observationsNumber of observations used in the fit, stored as a positive integer
value. NumObservations
is the number of rows in the table
or dataset array tbl
, minus rows excluded using the
'Exclude'
namevalue pair of fitglme
or rows containing
NaN
values.
Data Types: double
NumPredictors
— Number of predictorsNumber of variables used as predictors in the generalized linear mixedeffects model, stored as a positive integer value.
Data Types: double
NumVariables
— Total number of variablesTotal number of variables, including the response and predictors, stored
as a positive integer value. If the sample data is in a table or dataset
array tbl
, then NumVariables
is the
total number of variables in tbl
, including the response
variable. NumVariables
includes variables, if any, that
are not used as predictors or as the response.
Data Types: double
ObservationInfo
— Information about the observationsInformation about the observations used in the fit, stored as a table.
ObservationInfo
has one row for each observation and
the following columns.
Name  Description 

Weights  The weight value for the observation. The default value is 1. 
Excluded  If the observation was excluded from the fit using
the 'Exclude' namevalue pair
argument in fitglme , then
Excluded is
true , or 1 .
Otherwise, Excluded is
false , or
0 . 
Missing  If the observation was excluded from the fit
because any response or predictor value is missing,
then Missing
values include 
Subset  If the observation was used in the fit, then
Subset is
true . If the observation was not used
in the fit because it is missing or excluded, then
Subset is
false . 
BinomSize  Binomial size for each observation. This column only applies when fitting a binomial distribution. 
Data Types: table
ObservationNames
— Names of observationsNames of observations used in the fit, stored as a cell array of character vectors.
If the data is in a table or dataset array tbl
that contains observation names, then
ObservationNames
uses those names.
If the data is provided in matrices, or in a table or dataset
array without observation names, then
ObservationNames
is an empty cell
array.
Data Types: cell
PredictorNames
— Names of predictorsNames of the variables used as predictors in the fit, stored as a cell
array of character vectors that has the same length as
NumPredictors
.
Data Types: cell
ResponseName
— Name of response variableName of the variable used as the response variable in the fit, stored as a character vector.
Data Types: char
Rsquared
— Proportion of variability in the response explained by the fitted modelProportion of variability in the response explained by the fitted model,
stored as a structure. Rsquared
contains the
Rsquared value of the fitted model, also known as
the multiple correlation coefficient. Rsquared
contains
the following fields.
Field  Description 

Ordinary  Rsquared value, stored as a scalar value in a
structure.Rsquared.Ordinary =
1 — SSE./SST 
Adjusted  Rsquared value adjusted for the number of fixedeffects
coefficients, stored as a scalar value in a
structure.Rsquared.Adjusted =
1 —
(SSE./SST)*(DFT./DFE) ,where DFE = n – p , DFT = n –
1 , n is the total number of
observations, and p is the number of
fixedeffects coefficients. 
Data Types: struct
SSE
— Error sum of squaresError sum of squares, stored as a positive scalar value.
SSE
is the weighted sum of the squared conditional
residuals, and is calculated as
$$SSE={\displaystyle \sum _{i=1}^{n}{w}_{i}^{eff}{\left({y}_{i}{f}_{i}\right)}^{2}\text{\hspace{0.17em}},}$$
where n is the number of observations, w_{i}^{eff} is the ith effective weight, y_{i} is the ith response, and f_{i} is the ith fitted value.
The ith effective weight is calculated as
$${w}_{i}^{eff}=\left\{\frac{{w}_{i}}{{v}_{i}\left({\mu}_{i}\left(\widehat{\beta},\widehat{b}\right)\right)}\right\}\text{\hspace{0.17em}},$$
where v_{i} is the variance term for the ith observation, $$\widehat{\beta}$$ and $$\widehat{b}$$ are estimated values of β and b, respectively.
The ith fitted value is calculated as
$${f}_{i}={g}^{1}\left({x}_{i}^{T}\widehat{\beta}+{z}_{i}^{T}\widehat{b}+{\delta}_{i}\right)\text{\hspace{0.17em}},$$
where x_{i}^{T} is the ith row of the fixedeffects design matrix X, and z_{i}^{T} is the ith row of the randomeffects design matrix Z. δ_{i} is the ith offset value.
Data Types: double
SSR
— Regression sum of squaresRegression sum of squares, stored as a positive scalar value.
SSR
is the sum of squares explained by the
generalized linear mixedeffects regression, or equivalently the weighted
sum of the squared deviations of the conditional fitted values from their
weighted mean. SSR
is calculated as
$$SSR={\displaystyle \sum _{i=1}^{N}{w}_{i}^{eff}{\left({f}_{i}\overline{f}\right)}^{2}\text{\hspace{0.17em}},}$$
where n is the number of observations, w_{i}^{eff} is the ith effective weight, f_{i} is the ith fitted value, and $$\overline{f}$$ is a weighted average of the fitted values.
The ith effective weight is calculated as
$${w}_{i}^{eff}=\left\{\frac{{w}_{i}}{{v}_{i}\left({\mu}_{i}\left(\widehat{\beta},\widehat{b}\right)\right)}\right\}\text{\hspace{0.17em}},$$
where $$\widehat{\beta}$$ and $$\widehat{b}$$ are estimated values of β and b, respectively.
The ith fitted value is calculated as
$${f}_{i}={g}^{1}\left({x}_{i}^{T}\widehat{\beta}+{z}_{i}^{T}\widehat{b}+{\delta}_{i}\right)\text{\hspace{0.17em}},$$
where x_{i}^{T} is the ith row of the fixedeffects design matrix X, and z_{i}^{T} is the ith row of the randomeffects design matrix Z. δ_{i} is the ith offset value.
The weighted average of fitted values is calculated as
$$\overline{f}=\frac{\left[{\displaystyle \sum _{i=1}^{n}{w}_{i}^{eff}{f}_{i}}\right]}{{\displaystyle \sum _{i=1}^{n}{w}_{i}^{eff}}}\text{\hspace{0.17em}}.$$
Data Types: double
SST
— Total sum of squaresTotal sum of squares, stored as a positive scalar value. For a GLME model,
SST
is defined as SST = SSE +
SSR
.
Data Types: double
VariableInfo
— Information about the variablesInformation about the variables used in the fit, stored as a table.
VariableInfo
has one row for each variable and
contains the following columns.
Column Name  Description 

Class  Class of the variable ('double' ,
'cell' , 'nominal' ,
and so on). 
Range  Value range of the variable.

InModel  If the variable is a predictor in the fitted model,
If the variable
is not in the fitted model, 
IsCategorical  If the variable type is treated as a categorical
predictor (such as cell, logical, or categorical), then
If the variable
is a continuous predictor, then

Data Types: table
VariableNames
— Names of the variablesNames of all the variables contained in the table or dataset array
tbl
, stored as a cell array of character
vectors.
Data Types: cell
Variables
— VariablesVariables, stored as a table. If the fit is based on a table or dataset
array tbl
, then Variables
is identical
to tbl
.
Data Types: table
anova  Analysis of variance for generalized linear mixedeffects model 
coefCI  Confidence intervals for coefficients of generalized linear mixedeffects model 
coefTest  Hypothesis test on fixed and random effects of generalized linear mixedeffects model 
compare  Compare generalized linear mixedeffects models 
covarianceParameters  Extract covariance parameters of generalized linear mixedeffects model 
designMatrix  Fixed and randomeffects design matrices 
fitted  Fitted responses from generalized linear mixedeffects model 
fixedEffects  Estimates of fixed effects and related statistics 
plotResiduals  Plot residuals of generalized linear mixedeffects model 
predict  Predict response of generalized linear mixedeffects model 
random  Generate random responses from fitted generalized linear mixedeffects model 
randomEffects  Estimates of random effects and related statistics 
refit  Refit generalized linear mixedeffects model 
residuals  Residuals of fitted generalized linear mixedeffects model 
response  Response vector of generalized linear mixedeffects model 
Load the sample data.
load mfr
This simulated data is from a manufacturing company that operates 50 factories across the world, with each factory running a batch process to create a finished product. The company wants to decrease the number of defects in each batch, so it developed a new manufacturing process. To test the effectiveness of the new process, the company selected 20 of its factories at random to participate in an experiment: Ten factories implemented the new process, while the other ten continued to run the old process. In each of the 20 factories, the company ran five batches (for a total of 100 batches) and recorded the following data:
Flag to indicate whether the batch used the new process (newprocess
)
Processing time for each batch, in hours (time
)
Temperature of the batch, in degrees Celsius (temp
)
Categorical variable indicating the supplier (A
, B
, or C
) of the chemical used in the batch (supplier
)
Number of defects in the batch (defects
)
The data also includes time_dev
and temp_dev
, which represent the absolute deviation of time and temperature, respectively, from the process standard of 3 hours at 20 degrees Celsius.
Fit a generalized linear mixedeffects model using newprocess
, time_dev
, temp_dev
, and supplier
as fixedeffects predictors. Include a randomeffects term for intercept grouped by factory
, to account for quality differences that might exist due to factoryspecific variations. The response variable defects
has a Poisson distribution, and the appropriate link function for this model is log. Use the Laplace fit method to estimate the coefficients. Specify the dummy variable encoding as 'effects'
, so the dummy variable coefficients sum to 0.
The number of defects can be modeled using a Poisson distribution
$${\text{defects}}_{ij}\sim \text{Poisson}({\mu}_{ij})$$
This corresponds to the generalized linear mixedeffects model
$$\mathrm{log}({\mu}_{ij})={\beta}_{0}+{\beta}_{1}{\text{newprocess}}_{ij}+{\beta}_{2}{\text{time}\text{\_}\text{dev}}_{ij}+{\beta}_{3}{\text{temp}\text{\_}\text{dev}}_{ij}+{\beta}_{4}{\text{supplier}\text{\_}\text{C}}_{ij}+{\beta}_{5}{\text{supplier}\text{\_}\text{B}}_{ij}+{b}_{i},$$
where
$${\text{defects}}_{ij}$$ is the number of defects observed in the batch produced by factory $$i$$ during batch $$j$$.
$${\mu}_{ij}$$ is the mean number of defects corresponding to factory $$i$$ (where $$i=1,2,...,20$$) during batch $$j$$ (where $$j=1,2,...,5$$).
$${\text{newprocess}}_{ij}$$, $${\text{time}\text{\_}\text{dev}}_{ij}$$, and $${\text{temp}\text{\_}\text{dev}}_{ij}$$ are the measurements for each variable that correspond to factory $$i$$ during batch $$j$$. For example, $${\text{newprocess}}_{ij}$$ indicates whether the batch produced by factory $$i$$ during batch $$j$$ used the new process.
$${\text{supplier}\text{\_}\text{C}}_{ij}$$ and $${\text{supplier}\text{\_}\text{B}}_{ij}$$ are dummy variables that use effects (sumtozero) coding to indicate whether company C
or B
, respectively, supplied the process chemicals for the batch produced by factory $$i$$ during batch $$j$$.
$${b}_{i}\sim N(0,{\sigma}_{b}^{2})$$ is a randomeffects intercept for each factory $$i$$ that accounts for factoryspecific variation in quality.
glme = fitglme(mfr,'defects ~ 1 + newprocess + time_dev + temp_dev + supplier + (1factory)', ... 'Distribution','Poisson','Link','log','FitMethod','Laplace','DummyVarCoding','effects');
Display the model.
disp(glme)
Generalized linear mixedeffects model fit by ML Model information: Number of observations 100 Fixed effects coefficients 6 Random effects coefficients 20 Covariance parameters 1 Distribution Poisson Link Log FitMethod Laplace Formula: defects ~ 1 + newprocess + time_dev + temp_dev + supplier + (1  factory) Model fit statistics: AIC BIC LogLikelihood Deviance 416.35 434.58 201.17 402.35 Fixed effects coefficients (95% CIs): Name Estimate SE tStat DF pValue {'(Intercept)'} 1.4689 0.15988 9.1875 94 9.8194e15 {'newprocess' } 0.36766 0.17755 2.0708 94 0.041122 {'time_dev' } 0.094521 0.82849 0.11409 94 0.90941 {'temp_dev' } 0.28317 0.9617 0.29444 94 0.76907 {'supplier_C' } 0.071868 0.078024 0.9211 94 0.35936 {'supplier_B' } 0.071072 0.07739 0.91836 94 0.36078 Lower Upper 1.1515 1.7864 0.72019 0.015134 1.7395 1.5505 2.1926 1.6263 0.22679 0.083051 0.082588 0.22473 Random effects covariance parameters: Group: factory (20 Levels) Name1 Name2 Type Estimate {'(Intercept)'} {'(Intercept)'} {'std'} 0.31381 Group: Error Name Estimate {'sqrt(Dispersion)'} 1
The Model information
table displays the total number of observations in the sample data (100), the number of fixed and randomeffects coefficients (6 and 20, respectively), and the number of covariance parameters (1). It also indicates that the response variable has a Poisson
distribution, the link function is Log
, and the fit method is Laplace
.
Formula
indicates the model specification using Wilkinson’s notation.
The Model fit statistics
table displays statistics used to assess the goodness of fit of the model. This includes the Akaike information criterion (AIC
), Bayesian information criterion (BIC
) values, log likelihood (LogLikelihood
), and deviance (Deviance
) values.
The Fixed effects coefficients
table indicates that fitglme
returned 95% confidence intervals. It contains one row for each fixedeffects predictor, and each column contains statistics corresponding to that predictor. Column 1 (Name
) contains the name of each fixedeffects coefficient, column 2 (Estimate
) contains its estimated value, and column 3 (SE
) contains the standard error of the coefficient. Column 4 (tStat
) contains the $$t$$statistic for a hypothesis test that the coefficient is equal to 0. Column 5 (DF
) and column 6 (pValue
) contain the degrees of freedom and $$p$$value that correspond to the $$t$$statistic, respectively. The last two columns (Lower
and Upper
) display the lower and upper limits, respectively, of the 95% confidence interval for each fixedeffects coefficient.
Random effects covariance parameters
displays a table for each grouping variable (here, only factory
), including its total number of levels (20), and the type and estimate of the covariance parameter. Here, std
indicates that fitglme
returns the standard deviation of the random effect associated with the factory predictor, which has an estimated value of 0.31381. It also displays a table containing the error parameter type (here, the square root of the dispersion parameter), and its estimated value of 1.
The standard display generated by fitglme
does not provide confidence intervals for the randomeffects parameters. To compute and display these values, use covarianceParameters
.
In general, a formula for model specification is a character
vector or string scalar of the form 'y ~ terms'
. For generalized
linear mixedeffects models, this formula is in the form 'y ~ fixed +
(random1grouping1) + ... + (randomRgroupingR)'
, where
fixed
and random
contain the fixedeffects
and the randomeffects terms, respectively, and R is the number
of grouping variables in the model.
Suppose a table tbl
contains the following:
A response variable, y
Predictor variables,
X_{j}
, which
can be continuous or grouping variables
Grouping variables, g_{1}
,
g_{2}
, ...,
g_{R}
,
where the grouping variables in
X_{j}
and
g_{r}
can be
categorical, logical, character arrays, string arrays, or cell arrays of character
vectors.
Then, in a formula of the form, 'y ~ fixed +
(random_{1}g_{1}) + ... +
(random_{R}g_{R})'
,
the term fixed
corresponds to a specification of the
fixedeffects design matrix X
,
random
_{1} is a specification of the
randomeffects design matrix Z
_{1}
corresponding to grouping variable g
_{1}, and
similarly random
_{R} is a
specification of the randomeffects design matrix
Z
_{R}
corresponding to grouping variable
g
_{R}. You can
express the fixed
and random
terms using
Wilkinson notation.
Wilkinson notation describes the factors present in models. The notation relates to factors present in models, not to the multipliers (coefficients) of those factors.
Wilkinson Notation  Factors in Standard Notation 

1  Constant (intercept) term 
X^k , where k is a positive
integer  X ,
X^{2} , ...,
X^{k} 
X1 + X2  X1 , X2 
X1*X2  X1 , X2 , X1.*X2
(elementwise multiplication of X1 and X2) 
X1:X2  X1.*X2 only 
 X2  Do not include X2 
X1*X2 + X3  X1 , X2 ,
X3 , X1*X2 
X1 + X2 + X3 + X1:X2  X1 , X2 ,
X3 , X1*X2 
X1*X2*X3  X1:X2:X3  X1 , X2 ,
X3 , X1*X2 ,
X1*X3 , X2*X3 
X1*(X2 + X3)  X1 , X2 ,
X3 , X1*X2 ,
X1*X3 
Statistics and Machine
Learning Toolbox™ notation always includes a constant term unless you explicitly remove
the term using 1
. Here are some examples for linear
mixedeffects model specification.
Examples:
Formula  Description 

'y ~ X1 + X2'  Fixed effects for the intercept, X1 and
X2 . This is equivalent to 'y ~ 1 +
X1 + X2' . 
'y ~ 1 + X1 + X2'  No intercept and fixed effects for X1 and
X2 . The implicit intercept term is suppressed
by including 1 . 
'y ~ 1 + (1  g1)'  Fixed effects for the intercept plus random effect for the
intercept for each level of the grouping variable
g1 . 
'y ~ X1 + (1  g1)'  Random intercept model with a fixed slope. 
'y ~ X1 + (X1  g1)'  Random intercept and slope, with possible correlation between
them. This is equivalent to 'y ~ 1 + X1 + (1 +
X1g1)' . 
'y ~ X1 + (1  g1) + (1 + X1  g1)'  Independent random effects terms for intercept and slope. 
'y ~ 1 + (1  g1) + (1  g2) + (1 
g1:g2)'  Random intercept model with independent main effects for
g1 and g2 , plus an
independent interaction effect. 
A modified version of this example exists on your system. Do you want to open this version instead?
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
Select web siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.