fitglme
statistics: glme = fitglme (tbl, formula)
statistics: glme = fitglme (…, name, value)
Fit a generalized linear mixed-effects model specified by a formula.
fitglme (tbl, formula) fits the generalized linear
mixed-effects model described by formula to the table tbl and
returns a GeneralizedLinearMixedModel object.
formula uses the same syntax as fitlme: a response, a
fixed-effects part, and one or more random-effects terms
(expr | group), for example
"y ~ x + (1 | g)". The model is fitted by penalized
quasi-likelihood.
The following name/value pairs are accepted:
"Distribution""normal" (default), "binomial", or
"poisson"."Link""identity", "logit", or "log".
The default is the canonical link of the chosen distribution."FitMethod""MPL" (maximum pseudo-likelihood, the default), "REMPL"
(restricted MPL), "Laplace", or "ApproximateLaplace". The
first two differ in the pseudo-likelihood used for the covariance parameters;
the last two report the Laplace-approximated marginal log-likelihood.Only the canonical links and the full (unstructured) random-effects covariance are currently supported.
See also: GeneralizedLinearMixedModel, fitlme, fitglm
Source Code: fitglme
Poisson mixed model with a random intercept per group.
rng (42);
randg ('state', 42);
randp ('state', 42);
g = reshape (repmat (1:6, 7, 1), [], 1);
x = randn (42, 1);
y = poissrnd (exp (0.3 + 0.5 * x + 0.2 * reshape (repmat (randn (1, 6), 7, 1), [], 1)));
tbl = table (y, x, g);
glme = fitglme (tbl, "y ~ x + (1 | g)", "Distribution", "poisson");
disp (glme.Coefficients);
2x7 table
Estimate SE tStat DF pValue Lower Upper
________ ________ _______ __ __________ _________ ________
(Intercept) 0.154353 0.154085 1.00174 40 0.32249 -0.157063 0.46577
x 0.626466 0.116139 5.39409 40 3.3487e-06 0.391739 0.861192