GeneralizedLinearMixedModel class
Generalized linear mixedeffects model class
Description
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.
Construction
You can fit a generalized linear mixedeffects (GLME) model to sample data using
fitglme(
. For
more information, see tbl
,formula
)fitglme
.
Input Arguments
tbl
— Input data
table  dataset array
Input 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
character vector or string scalar of the form '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)'
Properties
Coefficients
— Estimates of fixedeffects coefficients
dataset array
Estimates 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 coefficientEstimate
— Estimated coefficient valueSE
— Standard error of the estimatetStat
— tstatistic for a test that the coefficient is equal to 0DF
— Degrees of freedom associated with the t statisticpValue
— pvalue for the tstatisticLower
— Lower confidence limitUpper
— 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 vector
matrix
Covariance of estimated fixedeffects vector, stored as a matrix.
Data Types: single
 double
CoefficientNames
— Names of fixedeffects coefficients
cell array of character vectors
Names 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 error
positive integer value
Degrees 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 parameter
scalar value
Model 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
isMPL
orREMPL
and the'DispersionFlag'
namevalue pair argument infitglme
istrue
, then a dispersion parameter is estimated from data for all distributions, including binomial and Poisson distributions.If
FitMethod
isApproximateLaplace
orLaplace
, then the'DispersionFlag'
namevalue pair argument infitglme
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 estimated
true
 false
Flag indicating estimated dispersion parameter, stored as a logical value.
If
FitMethod
isApproximateLaplace
orLaplace
, then the dispersion parameter is fixed at its theoretical value of 1.0 for binomial and Poisson distributions, andDispersionEstimated
isfalse
. For other distributions, the dispersion parameter is estimated from the data, andDispersionEstimated
istrue
.If
FitMethod
isMPL
orREMPL
, and the'DispersionFlag'
namevalue pair argument infitglme
is specified astrue
, then the dispersion parameter is estimated for all distributions, including binomial and Poisson distributions, andDispersionEstimated
istrue
.If
FitMethod
isMPL
orREMPL
, and the'DispersionFlag'
namevalue pair argument infitglme
is specified asfalse
, then the dispersion parameter is fixed at its theoretical value for binomial and Poisson distributions, andDispersionEstimated
isfalse
. For distributions other than binomial and Poisson, the dispersion parameter is estimated from the data, andDispersionEstimated
istrue
.
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 formula
object
Model 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 characteristics
structure
Link 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 function
scalar value
Log 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'
, thenLogLikelihood
is the maximized log likelihood.If you use
'MPL'
, thenLogLikelihood
is the maximized log likelihood of the pseudo data from the final pseudo likelihood iteration.If you use
'REMPL'
, thenLogLikelihood
is the maximized restricted log likelihood of the pseudo data from the final pseudo likelihood iteration.
Data Types: double
ModelCriterion
— Model criterion
table
Model 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 coefficients
positive integer value
Number of fixedeffects coefficients in the fitted generalized linear mixedeffects model, stored as a positive integer value.
Data Types: double
NumEstimatedCoefficients
— Number of estimated fixedeffects coefficients
positive integer value
Number of estimated fixedeffects coefficients in the fitted generalized linear mixedeffects model, stored as a positive integer value.
Data Types: double
NumObservations
— Number of observations
positive integer value
Number 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 predictors
positive integer value
Number of variables used as predictors in the generalized linear mixedeffects model, stored as a positive integer value.
Data Types: double
NumVariables
— Total number of variables
positive integer value
Total 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 observations
table
Information 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 observations
cell array of character vectors
Names 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, thenObservationNames
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 predictors
cell array of character vectors
Names 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 variable
character vector
Name 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 model
structure
Proportion 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 squares
positive scalar
Error sum of squares, specified as a positive scalar.
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({f}_{i}\left(\widehat{\beta},\widehat{b}\right)\right)}\right\}\text{\hspace{0.17em}},$$
where w_{i} is the ith observation weight, v_{i} is the variance term for the ith observation, and $$\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 g is the link function, x_{i}^{T} is the ith row of the fixedeffects design matrix X, z_{i}^{T} is the ith row of the randomeffects design matrix Z, and δ_{i} is the ith offset value.
Data Types: double
SSR
— Regression sum of squares
positive scalar
Regression sum of squares, specified as a positive scalar.
SSR
is the sum of squares explained by the
generalized linear mixedeffects regression, and is equal to the sum of the
squared deviations between the fitted values and the mean of the response.
SSR
is calculated as
$$SSR={\displaystyle \sum _{i=1}^{N}{w}_{i}^{eff}{\left({f}_{i}\overline{y}\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{y}$$ is the weighted average of the response.
The ith effective weight is calculated as
$${w}_{i}^{eff}=\left\{\frac{{w}_{i}}{{v}_{i}\left({f}_{i}\left(\widehat{\beta},\widehat{b}\right)\right)}\right\}\text{\hspace{0.17em}},$$
where w_{i} is the ith observation weight, v_{i} is the variance term for the ith observation, and $$\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 g is the link function, x_{i}^{T} is the ith row of the fixedeffects design matrix X, z_{i}^{T} is the ith row of the randomeffects design matrix Z, and δ_{i} is the ith offset value.
Data Types: double
SST
— Total sum of squares
positive scalar
Total sum of squares, specified as a positive scalar.
For a GLME model with an intercept, SST
is calculated
as
SST = SSE + SSR
,
where SST
is the total sum of squares,
SSE
is the error sum of squares, and
SSR
is the regression sum of squares.
For a GLME model without an intercept, SST
is
calculated as
$$SST={\displaystyle \sum _{i=1}^{N}{w}_{i}^{eff}{\left({y}_{i}\overline{y}\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 value, and $$\overline{y}$$ is the weighted average of the response.
Data Types: double
VariableInfo
— Information about the variables
table
Information 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 variables
cell array of character vectors
Names of all the variables contained in the table or dataset array
tbl
, stored as a cell array of character
vectors.
Data Types: cell
Variables
— Variables
table
Variables, 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
Object Functions
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 
partialDependence  Compute partial dependence 
plotPartialDependence  Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots 
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 
Examples
Fit a 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
, orC
) 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
orB
, 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 Lower Upper {'(Intercept)'} 1.4689 0.15988 9.1875 94 9.8194e15 1.1515 1.7864 {'newprocess' } 0.36766 0.17755 2.0708 94 0.041122 0.72019 0.015134 {'time_dev' } 0.094521 0.82849 0.11409 94 0.90941 1.7395 1.5505 {'temp_dev' } 0.28317 0.9617 0.29444 94 0.76907 2.1926 1.6263 {'supplier_C' } 0.071868 0.078024 0.9211 94 0.35936 0.22679 0.083051 {'supplier_B' } 0.071072 0.07739 0.91836 94 0.36078 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
.
More About
Formula
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 variablesGrouping 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. 
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
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: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)