GeneralizedLinearModel
statistics: GeneralizedLinearModel
Generalized linear regression model class.
A GeneralizedLinearModel object encapsulates a generalized linear
model (GLM) of a response on one or more predictors, fitted by iteratively
reweighted least squares. It is the GLM counterpart of LinearModel
and is normally created with the fitglm function.
The response is modelled through a distribution from the exponential family
('normal', 'binomial', 'poisson', 'gamma', or
'inverse gaussian') and a link function relating the mean
to the linear predictor .
The most useful properties are Coefficients (a table of estimates,
standard errors, -statistics and p-values), Deviance,
Dispersion, Residuals, Fitted, Diagnostics,
Distribution, and Link. ObservationInfo records which
rows were weighted, excluded, or missing, and Variables holds the data
the model was built from. For a binomial response given as an
-by- matrix of successes and trials, Variables holds
the success count alone, that being the response the model fits;
MATLAB stores both columns there. Fitted models support the
predict and feval methods for prediction.
Fitted, Residuals, Diagnostics, and
ObservationInfo have one row per input observation, not per
fitted observation. Rows that were excluded with the 'Exclude' pair
still carry a fitted value and a residual, since the model can be evaluated
there; rows dropped because a variable was missing carry NaN.
For a binomial response carrying a number of trials – given
either by the 'BinomialSize' pair or as the second column of a
two-column response – the response is the number of successes, as
fitglm documents. Fitted.Response is then the fitted count
and Residuals.Raw is on that same count scale, while
Fitted.Probability carries itself. predict returns
the probability, never a count: a trial count belongs to an observation,
and new predictor values do not carry one.
A categorical predictor expands to indicator columns, one per level bar the
reference level, which the intercept carries. When the model has no
intercept, the first categorical predictor is given an indicator for
every one of its levels instead, so that its coefficients are the group
means; any further categorical predictor stays reference coded, which keeps
the design full rank. This differs from MATLAB, which omits the reference
level whether or not an intercept is present and so cannot fit the reference
group at all – for a three-level grouping variable g, MATLAB fits
y ~ g - 1 with two coefficients, predicts exactly 0 for every
observation in the omitted group, and reports a negative . This
implementation returns three coefficients, one per group.
See also: fitglm, LinearModel, glmfit, glmval
Source Code: GeneralizedLinearModel
The GeneralizedLinearModel class contains the following properties:
A table with one row per coefficient and four columns:
Estimate - estimated coefficient value
SE - standard error of the estimate
tStat - the estimate divided by its standard error
pValue - p-value of that statistic
the dispersion is fixed, as it is for the binomial and Poisson families,
and to a
-distribution on DFE degrees of freedom where it is
estimated. Coefficients dropped as rank deficient have Estimate =
0,
SE = 0, and NaN for both statistics. Row names are the
coefficient names.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A cell array of character vectors, one per coefficient, in the order the
coefficients appear. The intercept is '(Intercept)', an
interaction joins its factors with a colon, and a categorical predictor
contributes one name per indicator, spelled
name_level, so these are not the term names.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A square matrix with one row and column per coefficient, whose diagonal
is the square of Coefficients.SE. It is scaled by
Dispersion, so it is the covariance under the estimated dispersion
wherever one was estimated.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A positive integer counting every coefficient the model carries, those dropped as rank deficient included. A categorical predictor with levels contributes of them.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A positive integer counting the coefficients that carry a degree of
freedom, which is NumCoefficients less however many were dropped
as rank deficient. It is the number the degrees of freedom and the
information criteria are computed from.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A nonnegative integer counting the predictors the model was given, whether or not each appears in a term. It counts variables, so a categorical predictor counts once however many indicators it expands to.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A positive integer giving the number of observations the fit actually
used. Rows holding a missing value and rows named by the
'Exclude' name-value argument are not counted.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A nonnegative scalar, twice the difference between the log-likelihood of the saturated model and that of this one. It is the generalized linear model’s counterpart of the residual sum of squares, and it is what a nested-model test compares.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A nonnegative integer, NumObservations less
NumEstimatedCoefficients.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A positive scalar. It is estimated from the Pearson statistic for the
normal, gamma, and inverse Gaussian families, and fixed at for
the binomial and Poisson families unless 'DispersionFlag' asked
otherwise. CoefficientCovariance and the standard errors are
scaled by it.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A logical scalar, true where Dispersion was estimated from the
data and false where it was held at . It decides whether a
coefficient’s statistic is referred to the normal or the
distribution.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A structure with three fields: Name, the distribution’s name;
DevianceFunction, a function handle giving the deviance
contribution of an observation from its response and mean; and
VarianceFunction, a function handle giving the variance of an
observation as a function of its mean.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A structure with four fields: Name, the link’s name; Link,
a function handle mapping the mean to the linear predictor;
Derivative, a handle giving that map’s derivative; and
Inverse, a handle mapping the linear predictor back to the mean.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A table with one row per input observation and two columns,
Response on the scale of the response and LinearPredictor
on the scale of the link. A binomial fit gains a third,
Probability, since its
Response is a count of successes while the fit works in the
proportion. Rows kept out of the fit by 'Exclude' still carry a
prediction; rows dropped as missing carry NaN.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A table with one row per input observation and five columns:
Raw - observed minus fitted, on the response scale
LinearPredictor - the working residual, on the link scale
Pearson - raw residuals divided by the estimated standard
deviation of the observation
Anscombe - the transform that makes the residuals as nearly
normal as the family allows
Deviance - the signed square root of each observation’s
contribution to Deviance
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A table with one row per input observation and three columns:
Leverage, the diagonal of the weighted hat matrix;
CooksDistance, the influence of the observation on every fitted
value at once; and HatMatrix, that observation’s row of the hat
matrix. Rows not used in the fit contain NaN.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A scalar, the log-likelihood of the observations under the fitted coefficients and the family’s own density. It is what the information criteria and the likelihood-ratio are computed from.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A structure with four fields, AIC, AICc, BIC, and
CAIC, each penalising LogLikelihood by a different function
of the coefficient count and the sample size. AICc is Inf
where the correction’s denominator is not positive.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A structure with five fields: Ordinary and Adjusted,
computed from the sums of squares on the response scale; Deviance,
one less the ratio of the model’s deviance to the null model’s;
LLR, the same ratio taken over log-likelihoods; and
AdjGeneralized, the Nagelkerke measure, which rescales the
generalized by its own attainable maximum so that it can reach
one.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A nonnegative scalar, the weighted sum of squared raw residuals on the
response scale. For a generalized linear model this is a descriptive
quantity rather than the fitted criterion, which is Deviance.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A nonnegative scalar, the weighted sum of squared differences between the fitted values and the weighted mean of the response, on the response scale.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A nonnegative scalar, the weighted sum of squared differences between the
response and its weighted mean. Unlike a linear model, a generalized
linear model does not in general satisfy SST = SSE + SSR.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A column vector with one element per input observation, added to the
linear predictor with a coefficient fixed at one, so that it shifts the
fit without being estimated. It is all zeros where no 'Offset'
was given.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A character vector, always 'none': no penalized-likelihood
fitting is offered, so the coefficients are always the plain
maximum-likelihood ones.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A character vector. It is taken from the table column, the
'ResponseVar' or 'VarNames' argument, or the formula, and
defaults to 'y' for a predictor matrix.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A cell array of character vectors naming the predictors in the order the
data lists them. A predictor matrix gives them the names 'x1',
'x2', and so on.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A cell array of character vectors naming every variable the model was given, the response included, in the order the data lists them.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A positive integer, the number of elements of VariableNames: the
predictors and the response together, whether or not each appears in a
term.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A table with one row per variable, named by it, and four columns:
Class, the class of the data column; Range, its two-element
range or, for a categorical, the list of its levels; InModel, true
where the variable appears in a term; and IsCategorical, true
where it was coded as indicators.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A table holding every variable, the response included, with one row per input observation. A model fitted from a predictor matrix gets a table assembled from it, so this property is a table either way.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A table with one row per input observation and four columns:
Weights, the weight it was given; Excluded, true where
'Exclude' named it; Missing, true where its data are
incomplete; and Subset, true where it was used in the fit, which
is neither excluded nor missing.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A cell array of character vectors, one per input observation, and empty unless the data carried row names.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A LinearFormula object describing the fitted model, with
properties including ResponseName, LinearPredictor,
PredictorNames,
TermNames, Terms, HasIntercept, and Link.
Its terms are expressed over the model’s variables, so a categorical
predictor contributes one term however many indicators it expands to.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
A structure recording the term-selection trace, populated whenever the
model was fit by stepwiseglm and [] otherwise. It has
seven fields:
| Field | Contents |
|---|---|
Start | a LinearFormula for the model the search
started from. |
Lower | a LinearFormula for the smallest model
considered; its terms are never removed. |
Upper | a LinearFormula for the largest model
considered. |
Criterion | the selection criterion, such as
'deviance_chi2'. |
PEnter | the threshold a term must beat to enter, empty unless one was given. |
PRemove | the threshold above which a term leaves, empty unless one was given. |
History | a table with one row per step. |
History always carries Action ('Start',
'Add', or 'Remove'), TermName, Terms (the
terms matrix after the step, over the model’s variables), DF (the
coefficient count after the step), and delDF (the change in it,
negative for a removal). The remaining columns follow the criterion:
Deviance, then
Chi2Stat or FStat, then PValue under
'Deviance';
FStat and pValue under 'sse'; and a single column
named
AIC or BIC holding the criterion’s value after the step
otherwise. The first row is the starting model, named by its right-hand
side.
This property is read-only.
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
The GeneralizedLinearModel class offers the following public methods:
GeneralizedLinearModel: mdl = GeneralizedLinearModel (data, resp, modelspec)
GeneralizedLinearModel: mdl = GeneralizedLinearModel (…, Name, Value)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: yhat = predict (mdl, Xnew)
GeneralizedLinearModel: [yhat, yci] = predict (mdl, Xnew)
GeneralizedLinearModel: […] = predict (…, Name, Value)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: yhat = feval (mdl, x1, x2, …)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: ci = coefCI (mdl)
GeneralizedLinearModel: ci = coefCI (mdl, alpha)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: p = coefTest (mdl)
GeneralizedLinearModel: [p, stat, df] = coefTest (mdl, H)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: tbl = devianceTest (mdl)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: ysim = random (mdl)
GeneralizedLinearModel: ysim = random (mdl, Xnew)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: h = plotResiduals (mdl)
GeneralizedLinearModel: h = plotResiduals (mdl, plottype)
GeneralizedLinearModel: h = plotResiduals (…, 'ResidualType', rt)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: h = plotDiagnostics (mdl)
GeneralizedLinearModel: h = plotDiagnostics (mdl, plottype)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: h = plotEffects (mdl)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: h = plotAdjustedResponse (mdl, var)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
GeneralizedLinearModel: h = plotAdded (mdl, var)
Fit a Poisson regression and inspect the model object.
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127
X = [0.1, 1.2; 0.4, 0.7; 1.1, 0.2; 1.5, 1.9; 0.3, 0.5; 1.8, 1.1; 0.9, 0.3]; y = [1; 0; 2; 3; 1; 4; 2]; mdl = fitglm (X, y, 'Distribution', 'poisson'); disp (mdl.Coefficients)
3x4 table
Estimate SE tStat pValue
__________ ________ _________ _________
(Intercept) -0.509786 0.708331 -0.7197 0.47171
x1 1.08685 0.567552 1.91498 0.0554956
x2 -0.0251014 0.515609 -0.048683 0.961172
printf ("Deviance = %g, AIC = %g\n", mdl.Deviance, mdl.ModelCriterion.AIC);
Deviance = 2.12771, AIC = 23.6127