# doc-cache created by Octave 11.2.0
# name: cache
# type: cell
# rows: 3
# columns: 291
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
CompactLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3435
statistics: CompactLinearModel

Compact linear regression model

The CompactLinearModel class stores a fitted linear regression
model without the training data. A CompactLinearModel object is
returned by the compact method of a LinearModel object, and
retains everything needed to inspect, predict from, and run inference on
the fit, while discarding the observations and per-observation
diagnostics that a LinearModel object carries. This makes a
CompactLinearModel object smaller to store than the
LinearModel it was compacted from.

The properties of a CompactLinearModel object fall into four
groups:

Group Properties
Coefficient estimates Coefficients (a table of
estimates, standard errors, t-statistics, and p-values for each term),
CoefficientCovariance , CoefficientNames , and the
coefficient counts NumCoefficients and
NumEstimatedCoefficients .
Summary statistics of the fit DFE , MSE ,
RMSE , Rsquared (ordinary and adjusted), SSE ,
SSR , SST , LogLikelihood , and ModelCriterion
(AIC, BIC, etc.).
Fitting method information Robust , which records
the weighting function and tuning constant used when the model is fit by
robust regression, and is empty for an ordinary least squares fit.
Input data properties Formula , NumObservations ,
NumPredictors , NumVariables , PredictorNames ,
ResponseName , VariableInfo , and VariableNames .

Because the training data is discarded, a CompactLinearModel
object has no Fitted , Residuals , Diagnostics , or
ObservationInfo properties, and none of its methods refit the
model. Once created, the following methods are available on a
CompactLinearModel object:

Method Description
predict Predict responses at new predictor values
given in a matrix or table. Can also return pointwise or simultaneous
confidence intervals alongside the point predictions.
feval Predict responses given predictors as
separate scalar or vector arguments (one per predictor variable) instead
of a single matrix, so a CompactLinearModel object can be
evaluated the same way as a plain function handle. Returns point
predictions only.
random Simulate new response values at new
predictor locations by adding independent Gaussian noise, drawn from the
estimated error variance MSE , to the fitted response.
coefCI Return Wald confidence intervals for every
fitted coefficient at a chosen significance level (default 0.05 ).
coefTest Test a linear hypothesis on the fitted
coefficients. With no arguments, tests the overall model F-test that
all non-intercept coefficients are zero; a custom hypothesis can be
given as a contrast matrix and, if needed, right-hand-side values.
Returns the p-value, and optionally the F-statistic and its numerator
degrees of freedom.
plotEffects Plot the estimated main effect and
95% confidence interval of each predictor, evaluated between its
observed minimum and maximum with all other predictors held at their
observed means.
plotInteraction Plot the main and conditional effects
of two predictors, or the adjusted response as a function of one
predictor for several fixed values of the other, to visualize whether
the two predictors interact.
anova Analysis of variance for the fitted model.
Type 3 raises an error on a model missing a lower-order relative of one
of its terms, since a CompactLinearModel object has no data to
refit with.

Create a CompactLinearModel object by using the compact
method of a fitted LinearModel object.

See also:
LinearModel,
compact


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
Compact linear regression model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
CompactLinearModel.CoefficientCovariance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 289
CompactLinearModel: property CoefficientCovariance

Covariance matrix of coefficient estimates

A p -by- p numeric matrix of covariance values for the
coefficient estimates, where p is the number of coefficients in
the fitted model as given by NumCoefficients . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Covariance matrix of coefficient estimates



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
CompactLinearModel.CoefficientNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 226
CompactLinearModel: property CoefficientNames

Coefficient names

A cell array of character vectors, each containing the name of the
corresponding model term (e.g., '(Intercept)' , 'x1' ,
'x1:x2' ). This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
Coefficient names



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
CompactLinearModel.Coefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 416
CompactLinearModel: property Coefficients

Coefficient values

A table with one row for each coefficient and four columns:

Estimate - estimated coefficient value
SE - standard error of the estimate
tStat - t-statistic for a two-sided test
pValue - p-value for the t-statistic

Coefficients that are dropped due to rank deficiency have
Estimate = 0 , SE = 0 , tStat = NaN ,
pValue = NaN . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
Coefficient values



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
CompactLinearModel.CompactLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 866
CompactLinearModel: cmdl = CompactLinearModel ()
CompactLinearModel: cmdl = CompactLinearModel ( mdl )

Create a compact linear regression model.

cmdl = CompactLinearModel () returns a
CompactLinearModel object with all properties empty.

cmdl = CompactLinearModel ( mdl ) copies the
coefficient estimates, fit statistics, and input data description
from the fitted LinearModel object mdl into a new
CompactLinearModel object cmdl , discarding the training
data, per-observation diagnostics, and stepwise fitting history. If
mdl was fit using robust regression, the Weights field of
cmdl .Robust is emptied, although the rest of the
Robust structure is retained.

The usual way to obtain a CompactLinearModel object is to call
the compact method on an already-fitted LinearModel
object, rather than calling this constructor directly.

See also:
LinearModel,
compact


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
Create a compact linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CompactLinearModel.DFE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 241
CompactLinearModel: property DFE

Degrees of freedom for error

A positive integer equal to the number of observations minus the number
of estimated coefficients: DFE = NumObservations -
NumEstimatedCoefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Degrees of freedom for error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
CompactLinearModel.Formula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 274
CompactLinearModel: property Formula

Model formula information

A structure representing the model formula with fields including
ResponseName , LinearPredictor , PredictorNames ,
TermNames , HasIntercept , Terms (the terms
matrix), and InModel . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Model formula information



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
CompactLinearModel.LogLikelihood


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 322
CompactLinearModel: property LogLikelihood

Log-likelihood of the fitted model

A scalar numeric value equal to the log-likelihood of the response
values, assuming each response is normally distributed with mean equal
to the fitted value and variance equal to SSE/n (the MLE
variance estimate). This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Log-likelihood of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CompactLinearModel.MSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 209
CompactLinearModel: property MSE

Mean squared error

A scalar numeric value equal to SSE / DFE , where SSE is
the sum of squared errors and DFE is the degrees of freedom for
error. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
Mean squared error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
CompactLinearModel.ModelCriterion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 498
CompactLinearModel: property ModelCriterion

Model comparison criteria

A structure with four fields:

AIC - Akaike information criterion:
-2 &times; logL + 2 &times; m
AICc - AIC corrected for sample size:
AIC + (2&times;m&times;(m+1))/(n-m-1)
BIC - Bayesian information criterion:
-2 &times; logL + m &times; log(n)
CAIC - Consistent AIC:
-2 &times; logL + m &times; (log(n) + 1)

Here logL is LogLikelihood , m is
NumEstimatedCoefficients , and n is
NumObservations . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Model comparison criteria



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
CompactLinearModel.NumCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 266
CompactLinearModel: property NumCoefficients

Number of model coefficients

A positive integer giving the total number of coefficients in the fitted
model, including any coefficients set to zero because the model terms are
rank deficient. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Number of model coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 43
CompactLinearModel.NumEstimatedCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 306
CompactLinearModel: property NumEstimatedCoefficients

Number of estimated coefficients

A positive integer giving the number of coefficients actually estimated,
i.e., not set to zero due to rank deficiency.
NumEstimatedCoefficients equals the degrees of freedom for
regression. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
Number of estimated coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
CompactLinearModel.NumObservations


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 309
CompactLinearModel: property NumObservations

Number of observations used in the fit

A positive integer giving the number of observations actually used in
fitting the original model. Rows with missing values and rows
excluded via the 'Exclude' name-value argument are not counted.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
Number of observations used in the fit



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
CompactLinearModel.NumPredictors


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 185
CompactLinearModel: property NumPredictors

Number of predictor variables

A positive integer giving the number of predictor variables used to
fit the model. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Number of predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
CompactLinearModel.NumVariables


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 274
CompactLinearModel: property NumVariables

Number of variables in the input data

A positive integer giving the total number of variables in the input
data used to fit the original model, counting predictors, the
response, and any unused columns. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
Number of variables in the input data



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
CompactLinearModel.PredictorNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 207
CompactLinearModel: property PredictorNames

Names of predictor variables

A cell array of character vectors containing the names of the
predictor variables used to fit the model. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Names of predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
CompactLinearModel.RMSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 131
CompactLinearModel: property RMSE

Root mean squared error

A scalar numeric value equal to sqrt(MSE) . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
Root mean squared error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
CompactLinearModel.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 159
CompactLinearModel: property ResponseName

Response variable name

A character vector containing the name of the response variable.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Response variable name



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
CompactLinearModel.Robust


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 445
CompactLinearModel: property Robust

Robust fit information

A structure with three fields:

WgtFun - robust weighting function name, e.g.
'bisquare'
Tune - tuning constant; empty if WgtFun is
'ols' or a function handle with the default tuning constant
Weights - vector of final iteration weights; always
empty for a CompactLinearModel object

This structure is empty unless the model was fit using robust
regression. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Robust fit information



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
CompactLinearModel.Rsquared


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 274
CompactLinearModel: property Rsquared

R-squared goodness-of-fit statistics

A structure with two fields:

Ordinary - coefficient of determination:
R^2 = SSR / SST
Adjusted - adjusted R^2 that accounts for the
number of coefficients in the model

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
R-squared goodness-of-fit statistics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CompactLinearModel.SSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 251
CompactLinearModel: property SSE

Sum of squared errors

A scalar numeric value equal to the sum of squared residuals. For a
model with an intercept, SST = SSE + SSR . For weighted fits,
this is the weighted sum of squares. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
Sum of squared errors



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CompactLinearModel.SSR


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 307
CompactLinearModel: property SSR

Regression sum of squares

A scalar numeric value equal to the sum of squared deviations of the
fitted values from the mean of the response. For a model with an
intercept, SST = SSE + SSR . For weighted fits, this is the
weighted sum of squares. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Regression sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CompactLinearModel.SST


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 356
CompactLinearModel: property SST

Total sum of squares

A scalar numeric value equal to the sum of squared deviations of the
response from its mean. For a model with an intercept,
SST = SSE + SSR . For a robust fit, SST = SSE + SSR
rather than the deviation from the mean. For weighted fits, this is
the weighted sum of squares. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Total sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
CompactLinearModel.VariableInfo


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 519
CompactLinearModel: property VariableInfo

Information about input variables

A table with one row per variable including any unused variables, and
four columns:

Class - variable class as a character vector, e.g.
'double' or 'categorical'
Range - for continuous variables, a two-element vector
[min, max] ; for categorical variables, a vector of the
distinct values
InModel - logical; true if the variable is in the
fitted model
IsCategorical - logical; true if the variable is
categorical

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Information about input variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
CompactLinearModel.VariableNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 275
CompactLinearModel: property VariableNames

Names of all variables in the input data

A cell array of character vectors containing the names of all
variables used to fit the original model, including predictors, the
response, and unused variables. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
Names of all variables in the input data



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
CompactLinearModel.anova


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2725
CompactLinearModel: tbl = anova ( mdl )
CompactLinearModel: tbl = anova ( mdl , anovatype )
CompactLinearModel: tbl = anova ( mdl , "components" , sstype )

Analysis of variance for a compact linear regression model.

anova ( mdl ) returns a table tbl with component
ANOVA statistics for every term in mdl except the constant
term, computed with hierarchical ( "h" ) sums of squares. Each
row gives SumSq , DF , MeanSq , F , and
pValue for the corresponding term; the trailing Error
row gives SumSq = mdl .SSE , DF = mdl .DFE ,
MeanSq = mdl .MSE , and NaN for F and
pValue .

MATLAB reports F = 1 and pValue = 0.5 on that
Error row instead. Those are not results: the row&rsquo;s F
is its own MeanSq divided by itself, so it is 1 for every
data set, and the pValue follows. MATLAB does not use them
consistently either, reporting NaN for the same quantity on the
Residual row of its summary table. This implementation reports
NaN in both places.

Every statistic is computed from
mdl .Coefficients and
mdl .CoefficientCovariance alone; a CompactLinearModel
never refits, because it does not retain the training data.

anova ( mdl , anovatype ) selects
"components" (default) or "summary" . For
"summary" , tbl always contains rows Total ,
Model , and Residual , and additionally . Linear
and . Nonlinear whenever mdl contains an interaction
term or a continuous term of degree greater than 1. Total
reports mdl .SST with DF = NumObservations - 1 ;
Model reports mdl .SSR with DF =
NumCoefficients - HasIntercept ; Residual reports
mdl .SSE with DF = mdl .DFE . Unlike
anova on a LinearModel , tbl never contains
. Lack of fit or . Pure error rows, since identifying
observations with identical predictor values requires the training
data that a CompactLinearModel does not retain.

anova ( mdl , "components" , sstype ) selects
the sum of squares used for the component table: 1 (sequential,
reduction from adding each term in formula order), 2 (reduction
from adding the term to a model containing every term that does not
contain it), "h" (default; as Type 2, but a higher-degree
term in the same continuous variable, such as a squared term, is also
treated as containing the lower-degree term), or 3 (reduction
from adding the term to a model containing every other term, with
categorical predictors recoded using sum-to-zero deviation contrasts
instead of mdl &rsquo;s reference-level coding). sstype is
ignored when anovatype is "summary" . If mdl is
missing a lower-order relative of one of its terms (e.g. an
interaction without one of its main effects, or a categorical
predictor fit without an intercept), type 3 raises an error,
since a CompactLinearModel has no data to refit with.

See also:
LinearModel,
coefTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
Analysis of variance for a compact linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
CompactLinearModel.coefCI


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1330
CompactLinearModel: ci = coefCI ( mdl )
CompactLinearModel: ci = coefCI ( mdl , alpha )

Confidence intervals for the coefficient estimates of a fitted linear
regression model.

ci = coefCI ( mdl ) returns 95% confidence intervals
for every coefficient in mdl using a default significance level of
0.05 .

ci = coefCI ( mdl , alpha ) uses the significance
level alpha , a scalar in [0, 1] . The resulting intervals
have coverage 100(1-\alpha)\% . Setting alpha to 0
produces intervals of infinite width; setting it to 1 collapses
each interval to the corresponding point estimate.

The output ci is a k -by-2 numeric matrix where
k = mdl .NumCoefficients . Row j contains
the interval for the j -th coefficient, whose name is stored in
mdl .CoefficientNames{j} . Column 1 is the lower bound and
column 2 is the upper bound. The midpoint of each interval equals the
corresponding point estimate in mdl .Coefficients.Estimate .

Intervals use the Wald method:
b_j \pm t_{(1-\alpha/2,\,\mathrm{DFE})}\,\mathrm{SE}(b_j) ,
where b_j is the coefficient estimate, \mathrm{SE}(b_j) is
its standard error from mdl .Coefficients.SE , and the
critical value is the 1-\alpha/2 quantile of the
t -distribution with mdl .DFE degrees of freedom.
In rank-deficient models, aliased coefficients have
\mathrm{SE} = 0 and their row in ci is [0, 0] .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 87
Confidence intervals for the coefficient estimates of a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
CompactLinearModel.coefTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2057
CompactLinearModel: p = coefTest ( mdl )
CompactLinearModel: p = coefTest ( mdl , H )
CompactLinearModel: p = coefTest ( mdl , H , C )
CompactLinearModel: [ p , F ] = coefTest (&hellip;)
CompactLinearModel: [ p , F , r ] = coefTest (&hellip;)

Linear hypothesis test on the coefficients of a fitted linear regression
model.

coefTest tests whether one or more linear combinations of the
fitted coefficients equal specified constants. Each linear combination
is encoded as a row of the contrast matrix H , and the right-hand
side is given by C .

p = coefTest ( mdl ) performs the overall model F-test:
it tests the joint null hypothesis that every coefficient except the
intercept is zero. The returned p-value matches the F-statistic line
printed at the bottom of the model display.

p = coefTest ( mdl , H ) tests the null hypothesis
H \beta = 0 , where \beta is the full coefficient vector
of length k = mdl .NumCoefficients . H must be
a full-rank numeric matrix with k columns; each row specifies one
linear constraint. To test a single coefficient, use a row vector with a
1 in that coefficient&rsquo;s position and zeros elsewhere; the
resulting F-statistic equals the square of the corresponding t-statistic
in mdl .Coefficients . To test a categorical predictor that
expands to multiple indicator columns, include one row per indicator in
H .

p = coefTest ( mdl , H , C ) tests
H \beta = C instead of zero. C must be a numeric vector
with the same number of elements as rows of H ; both row and column
vectors are accepted.

The second output F is the value of the F-statistic:
F = (H\hat{\beta} - C)^\prime (H V H^\prime)^{-1}
(H\hat{\beta} - C) / r , where V is
mdl .CoefficientCovariance and r is the number of
rows of H . The third output r is that numerator degrees of
freedom; the denominator degrees of freedom is mdl .DFE .
Under the null hypothesis F follows an F(r, \mathrm{DFE})
distribution and the p-value is the upper-tail probability. When
H is rank-deficient but contains no NaN , both p and
F are returned as NaN without an error.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 79
Linear hypothesis test on the coefficients of a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
CompactLinearModel.feval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1373
CompactLinearModel: ypred = feval ( mdl , X )
CompactLinearModel: ypred = feval ( mdl , x1 , x2 , &hellip;, xp )

Predict responses of a fitted linear regression model using separate
predictor inputs.

ypred = feval ( mdl , X ) accepts a single
numeric matrix X with one column per predictor in the same order
as the training data, or a table whose column names match
mdl .PredictorNames . The output is an n -by-1 column
vector. Rows that contain NaN in any predictor column are
returned as NaN .

ypred = feval ( mdl , x1 , x2 , &hellip;,
xp ) accepts exactly mdl .NumPredictors separate
arguments, one per predictor variable. All non-scalar arguments must
have the same size; a scalar argument is broadcast to that size
automatically. The output shape follows the shape of the non-scalar
inputs: column vector inputs give a column vector output, row vector
inputs give a row vector output, and all-scalar inputs give a scalar.
This form is convenient when predictor data is already stored in separate
vectors rather than a combined matrix.

feval gives the same numerical predictions as predict but
does not support confidence intervals. Use predict when you also
need bounds on the response. Because a CompactLinearModel object
behaves like a function through feval , it can be passed directly
to routines that accept a function handle, such as fminsearch or
integral .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 86
Predict responses of a fitted linear regression model using separate predictor inputs.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
CompactLinearModel.plotEffects


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1789
CompactLinearModel: plotEffects ( mdl )
CompactLinearModel: plotEffects ( ax , mdl )
CompactLinearModel: h = plotEffects (&hellip;)

Plot the main effects of each predictor in a compact linear regression
model.

plotEffects ( mdl ) creates a horizontal dot-and-line plot
with one row per predictor. Each dot shows the estimated main effect on
the response from changing that predictor from its minimum observed value
to its maximum observed value, while holding all other predictors fixed
at their observed means. A horizontal line through each dot shows the
95% confidence interval for that effect.

The main effect for predictor xs is defined as
g(x_{s,\max}) - g(x_{s,\min}) , where the adjusted response
function g evaluates the model at the specified value of
xs with all other predictors set to their observed means.
For numeric predictors the sign of the effect can be positive or
negative depending on the direction of the relationship. Because a
CompactLinearModel does not retain the training data, these
values come from a summary computed once when the model was fitted,
rather than recomputed from the original observations.

plotEffects ( ax , mdl ) creates the plot in the axes
object ax instead of the current axes returned by gca .

h = plotEffects (&hellip;) returns a vector of
p+1 graphics handles where p is the number of predictors.
h(1) is the line object containing the effect estimate markers
(one circle per predictor, plotted as a single line object with
XData of length p and YData = 1:p ).
h(j+1) is the confidence interval line for predictor j ,
with XData = [ci_lo, ci_hi] and YData = [j, j] .

The y-axis tick labels follow the format
'varname: min to max' , showing the predictor name and the
minimum and maximum observed values used to compute the effect.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 77
Plot the main effects of each predictor in a compact linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
CompactLinearModel.plotInteraction


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3026
CompactLinearModel: plotInteraction ( mdl , var1 , var2 )
CompactLinearModel: plotInteraction ( mdl , var1 , var2 , ptype )
CompactLinearModel: plotInteraction ( ax , &hellip;)
CompactLinearModel: h = plotInteraction (&hellip;)

Plot the interaction effects of two predictors in a compact linear
regression model.

plotInteraction ( mdl , var1 , var2 ) creates a
plot of the main effects of var1 and var2 together with
their conditional effects, with horizontal lines through each effect
value indicating its 95% confidence interval. var1 and
var2 are each a character vector or string naming a variable in
mdl.VariableNames , or a positive integer indexing into
mdl.VariableNames ; neither may name the response variable, and
they must be different variables.

The main effect of a predictor is the change in the adjusted response
between the two predictor values that produce the minimum and maximum
adjusted response, with the other predictor averaged over its own
observed values row by row. For a numeric predictor these two values
are its observed minimum and maximum; for a categorical predictor
every level is evaluated and the levels producing the minimum and
maximum adjusted response are used, so the effect is always
nonnegative.

The conditional effect of var1 is its effect recomputed with
var2 additionally held fixed at each of a small set of
conditioning values, and likewise the conditional effect of
var2 holds var1 fixed. The conditioning values are the
observed minimum, mean of the minimum and maximum, and maximum for a
numeric predictor, or every level for a categorical predictor. When
the main effect and conditional effect points for a predictor do not
align vertically, the model exhibits an interaction between
var1 and var2 . Because a CompactLinearModel does
not retain the training data, these values come from a summary
computed once when the model was fitted, rather than recomputed from
the original observations.

plotInteraction ( mdl , var1 , var2 , ptype )
selects the plot type. ptype is 'effects' (default), as
described above, or 'predictions' , which instead plots the
adjusted response as a function of var2 for each conditioning
value of var1 held fixed, evaluated over 101 equally spaced
points spanning the observed range of var2 when var2 is
numeric, or at each level of var2 when it is categorical.

plotInteraction ( ax , &hellip;) plots into the axes object
ax instead of the current axes returned by gca .

h = plotInteraction (&hellip;) returns a vector of line
handles. When ptype is 'effects' , h(1) is the
marker line through the two main effect points, h(2) and
h(3) are the confidence interval lines for the main effects of
var1 and var2 , and the remaining entries are the
conditional effect points and their confidence intervals, tagged
'conditional1' for var1 and 'conditional2' for
var2 . The main effect line objects are tagged 'main' .
When ptype is 'predictions' , each entry in h
corresponds to one adjusted response curve, one per conditioning
value of var1 .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 84
Plot the interaction effects of two predictors in a compact linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
CompactLinearModel.predict


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1826
CompactLinearModel: ypred = predict ( mdl , Xnew )
CompactLinearModel: [ ypred , yci ] = predict ( mdl , Xnew )
CompactLinearModel: [ ypred , yci ] = predict ( mdl , Xnew , Name , Value )

Predict responses from a fitted linear regression model.

ypred = predict ( mdl , Xnew ) returns the fitted
response values at the new predictor locations in Xnew . Xnew
can be a numeric matrix with one column per predictor in the same order
as the training data, or a table whose column names match
mdl .PredictorNames . Rows containing NaN are returned
as NaN without error. Unlike LinearModel , Xnew is
required: a CompactLinearModel object does not store the
training data, so there is no default to fall back on when it is
omitted.

[ ypred , yci ] = predict (&hellip;) also returns
yci , an n -by-2 matrix of confidence bounds where column 1 is
the lower bound and column 2 is the upper bound. By default these are
95% pointwise confidence intervals on the mean response.

Name-Value pair arguments:

Name Value
'Alpha' Significance level for the confidence
interval, specified as a scalar in [0,1] . The interval has
coverage 100(1-\alpha)\% . Default is 0.05 , giving a 95%
interval.
'Prediction' Type of interval to compute.
"curve" (default) gives a confidence interval on the mean response
f(x) . "observation" gives a wider prediction interval for
a single future observation y = f(x) + \varepsilon , which accounts
for both estimation uncertainty and irreducible noise; it adds
mdl .MSE to the variance before computing the half-width.
'Simultaneous' Logical flag controlling whether
the bounds are simultaneous or pointwise. When true ,
Scheff'{e}&rsquo;s method is used so the entire predicted curve lies within
the band with 100(1-\alpha)\% confidence; these bands are always
wider than pointwise ones. Default is false .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 56
Predict responses from a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
CompactLinearModel.random


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1022
CompactLinearModel: ysim = random ( mdl , Xnew )

Simulate responses with random noise from a fitted linear regression
model.

ysim = random ( mdl , Xnew ) computes the fitted
response at each row of Xnew and then adds independent Gaussian
noise to each value. The noise is drawn from N(0, \sigma^2) where
\sigma^2 is the estimated error variance mdl .MSE
(mean squared error of the fit). The result is a column vector of the
same length as the number of rows in Xnew .

Xnew is required and must be non-empty. It can be a numeric
matrix with one column per predictor in the same order as the training
data, or a table whose column names match
mdl .PredictorNames .

Because the added noise is drawn freshly on every call, two calls with
the same Xnew will generally produce different output. To get
reproducible results, set the random seed with rand ('state', s)
before calling random .

For deterministic predictions without noise, use predict or
feval . predict also provides confidence intervals on the
mean response.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 75
Simulate responses with random noise from a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
CoxModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2288
statistics: CoxModel

Cox proportional hazards regression model class.

A CoxModel object encapsulates a Cox proportional hazards model of a
survival time on one or more predictors, fitted by maximizing the Cox partial
likelihood. It is the object counterpart of coxphfit and is normally
created with the fitcox function.

The model states that an observation with predictor values x has hazard

$$ h(x, t) = h_0(t)\exp\left(\sum_{j=1}^{p} x_{j} b_j\right) $$

where h_0(t) is an unspecified baseline hazard. The model carries no
constant term: any constant is absorbed into that baseline.

The most useful properties are Coefficients (a table of estimates,
standard errors, z -statistics and p-values), Hazard (the
estimated baseline cumulative hazard), LogLikelihood ,
Residuals , and the three p-values LikelihoodRatioTestPValue ,
ProportionalHazardsPValue and
ProportionalHazardsPValueGlobal . Fitted models support the
survival , hazardratio , coefci , linhyptest ,
plotSurvival and discardResiduals methods.

A categorical predictor expands to indicator columns, one per level bar the
first, which the baseline hazard carries; the indicator columns are named
name _ level and enter the default baseline as zero, while
a numeric predictor enters it as its mean.

ProportionalHazardsPValue is a Grambsch-Therneau test of each
coefficient against the mid-ranks of the event times, and
ProportionalHazardsPValueGlobal the same test taken over the whole
model. A small p-value is evidence that the hazard ratio moves with time,
which is what proportionality denies.

Deviations from MATLAB, all in naming. MATLAB derives the names
reported by a fitted model from three different places and they need not
agree with one another: with default predictor names its Formula
reads 'y ~ x1 + x2' in lower case while PredictorNames holds
'X1' and 'X2' , and supplying 'PredictorNames'
changes ResponseName from 'y' to the name of the variable
passed as the response. Here the names are consistent by construction:
ResponseName is 'y' unless the data came from a table, the
Formula is built from PredictorNames and
ResponseName , and neither depends on which optional arguments were
given. Every fitted quantity agrees with MATLAB.

See also:
fitcox,
coxphfit,
GeneralizedLinearModel,
LinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
Cox proportional hazards regression model class.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
CoxModel.Baseline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 296
CoxModel: property Baseline

Predictor values the baseline hazard is evaluated at

The baseline the fit used, one row per stratum. It is reported as it
was given when fitcox was given one, a scalar staying a scalar,
and otherwise holds the rows the fit was centred on. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 52
Predictor values the baseline hazard is evaluated at



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
CoxModel.CoefficientCovariance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 253
CoxModel: property CoefficientCovariance

Estimated covariance of the coefficients

A square numeric matrix, one row and column per encoded predictor
column, holding the estimated covariance of the estimates in
Coefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
Estimated covariance of the coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
CoxModel.Coefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 244
CoxModel: property Coefficients

Coefficient estimates and their statistics

A table with one row per encoded predictor column, its row names the
encoded column names, and the variables Beta , SE ,
zStat and pValue . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Coefficient estimates and their statistics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
CoxModel.CoxModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2226
CoxModel: mdl = CoxModel ( X , T )
CoxModel: mdl = CoxModel ( tbl , respvar )
CoxModel: mdl = CoxModel (&hellip;, Name , Value )

Fit a Cox proportional hazards regression model.

mdl = CoxModel ( X , T ) fits the model to the
n -by- p numeric predictor matrix X and the
n -by-1 vector of event times T . T may instead be an
n -by-2 matrix giving a (start, stop] interval of exposure,
the counting process form.

mdl = CoxModel ( tbl , respvar ) takes the data
from the table tbl , using the variable named respvar as the
response and every other variable as a predictor. A categorical
variable is encoded as indicator columns.

X must not contain a constant column: the model has no constant
term, since any constant is absorbed into the baseline hazard.

The following Name / Value pairs are accepted:

Name Value
"Baseline" The X values at which the baseline
hazard is computed, either a scalar or a 1-by- p vector. The
default is the mean of each numeric predictor and zero for each indicator
column of a categorical predictor, taken within each stratum.
"Beta" The starting value of the iteration, a vector
of length p . The default is 0.01 ./ std ( X ) .
"CategoricalPredictors" The predictors to treat as
categorical, given as column indices, a logical vector, or a cell array
of predictor names. Table variables of class categorical are
detected without this argument.
"Censoring" A logical or 0/1 vector of length
n , where 1 marks an observation right-censored at its recorded
time. The default is a vector of zeros.
"Frequency" A vector of length n of
non-negative values giving the number of observations each row
represents, or a weight. The default is a vector of ones.
"OptimizationOptions" A structure of iteration
settings, as built by statset ("fitcox") . The fields used are
"MaxIter" , "TolX" and "Display" .
"PredictorNames" A cell array of p predictor
names. The default is "X1" , "X2" , and so on, or the
table variable names.
"Stratification" A vector of length n of
stratum labels. Each stratum carries its own baseline hazard and its own
risk sets, while the coefficients are shared across all of them.
"TieBreakMethod" The method of handling tied event
times, either "breslow" (default) or "efron" .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
Fit a Cox proportional hazards regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
CoxModel.Formula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 128
CoxModel: property Formula

Model formula

A LinearFormula object describing the terms of the model. This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
Model formula



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
CoxModel.Hazard


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 273
CoxModel: property Hazard

Estimated baseline cumulative hazard

A numeric matrix of event times in its first column and the cumulative
hazard at them in its second. A stratified model adds a third column
holding the stratum each row belongs to. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
Estimated baseline cumulative hazard



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
CoxModel.LikelihoodRatioTestPValue


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 206
CoxModel: property LikelihoodRatioTestPValue

Likelihood ratio test against the null model

A scalar p value comparing the fitted model with the model that
carries no predictors. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 44
Likelihood ratio test against the null model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CoxModel.LogLikelihood


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 149
CoxModel: property LogLikelihood

Log-likelihood of the fitted model

A scalar, the maximised Cox partial log-likelihood. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Log-likelihood of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CoxModel.NumPredictors


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 194
CoxModel: property NumPredictors

Number of predictors

A positive integer counting the predictor variables of the model,
before any categorical predictor is encoded. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Number of predictors



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
CoxModel.PredictorNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 159
CoxModel: property PredictorNames

Names of the predictor variables

A cell array of character vectors with one name per predictor. This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
Names of the predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
CoxModel.ProportionalHazardsPValue


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 314
CoxModel: property ProportionalHazardsPValue

Proportional hazards test, one predictor at a time

A numeric vector with one p value per predictor, testing whether
that predictor&rsquo;s effect is constant over time. A small value is
evidence against the proportional hazards assumption. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 50
Proportional hazards test, one predictor at a time



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
CoxModel.ProportionalHazardsPValueGlobal


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 216
CoxModel: property ProportionalHazardsPValueGlobal

Proportional hazards test over the whole model

A scalar p value testing the proportional hazards assumption for
all predictors at once. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
Proportional hazards test over the whole model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
CoxModel.Residuals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 234
CoxModel: property Residuals

Residuals of the fitted model

A table with one row per observation and the variables
CoxSnell , Deviance , Martingale ,
Schoenfeld , ScaledSchoenfeld , Score and
ScaledScore . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Residuals of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
CoxModel.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 159
CoxModel: property ResponseName

Name of the response variable

A character vector naming the response, which is the survival time.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Name of the response variable



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
CoxModel.StandardError


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 220
CoxModel: property StandardError

Standard errors of the coefficients

A numeric column vector, the square roots of the diagonal of
CoefficientCovariance , which is column SE of
Coefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
Standard errors of the coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
CoxModel.Stratification


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 199
CoxModel: property Stratification

Stratification levels used in the fit

The distinct levels of the stratification variable. It is empty when
the model is not stratified. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
Stratification levels used in the fit



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
CoxModel.VariableInfo


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 224
CoxModel: property VariableInfo

Information about the variables

A table with one row per variable, its row names the variable names,
and the variables Class , Range , InModel and
IsCategorical . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
Information about the variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
CoxModel.coefci


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 407
CoxModel: ci = coefci ( obj )
CoxModel: ci = coefci ( obj , level )

Confidence intervals for the coefficients of a Cox model.

ci = coefci ( obj ) returns a two-column matrix with one
row per coefficient, holding the 95% confidence interval of each.

ci = coefci ( obj , level ) uses a
100 (1 - level ) % interval. level must be a positive
scalar smaller than 1; it is a significance level, not a coverage.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 57
Confidence intervals for the coefficients of a Cox model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
CoxModel.discardResiduals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 401
CoxModel: obj = discardResiduals ( obj )

Drop the stored residuals of a Cox model.

obj = discardResiduals ( obj ) returns the model with an
empty Residuals property. The residual table holds one row per
observation and is the largest thing a fitted model carries, so
discarding it makes a model that is only going to be used for prediction
considerably smaller. Nothing else about the model changes.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
Drop the stored residuals of a Cox model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
CoxModel.hazardratio


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 773
CoxModel: hr = hazardratio ( obj , X )
CoxModel: hr = hazardratio ( obj , X , S )
CoxModel: hr = hazardratio (&hellip;, "Baseline" , B )

Hazard of a Cox model relative to its baseline.

hr = hazardratio ( obj , X ) returns the hazard at
the predictor values X relative to the baseline the model was
fitted with, exp (( X - B ) * b ) . X has one
row per evaluation point and is a numeric matrix, or a table when the
model was fitted from one.

hr = hazardratio ( obj , X , S ) gives the
stratum of each row of X , and is required when the model is
stratified, each stratum having its own baseline.

hr = hazardratio (&hellip;, "Baseline", B ) evaluates
the ratio against the baseline B instead, either a scalar or a row
vector with one element per encoded predictor column.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 47
Hazard of a Cox model relative to its baseline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
CoxModel.linhyptest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 587
CoxModel: tbl = linhyptest ( obj )

Sequential tests on the coefficients of a Cox model.

tbl = linhyptest ( obj ) returns a table with one row
per predictor, whose k -th row tests the hypothesis that the
coefficients of the k -th and every later predictor are jointly
zero. The Predictor column names the predictors the hypothesis
leaves in the model, so its first row reads "Empty Model" and
tests every coefficient at once, and its last row tests the last
coefficient alone, reproducing that coefficient&rsquo;s own p-value.

Each test is a Wald test on the fitted model, not a refit.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 52
Sequential tests on the coefficients of a Cox model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
CoxModel.plotSurvival


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 565
CoxModel: plotSurvival ( obj )
CoxModel: plotSurvival ( obj , X )
CoxModel: plotSurvival ( obj , X , S )
CoxModel: h = plotSurvival (&hellip;)

Plot the survival function of a Cox model.

plotSurvival ( obj ) draws the survival function at the
model&rsquo;s baseline as a stairstep plot. plotSurvival ( obj ,
X ) draws it at the predictor values X , one curve per row,
and S gives the stratum of each row when the model is stratified.
A stratified model with no X draws one curve per stratum.

h = plotSurvival (&hellip;) returns the handles of the
stairstep lines.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Plot the survival function of a Cox model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
CoxModel.survival


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1160
CoxModel: s = survival ( obj )
CoxModel: s = survival ( obj , X )
CoxModel: s = survival ( obj , X , S )
CoxModel: s = survival (&hellip;, Name , Value )
CoxModel: [ s , T ] = survival (&hellip;)

Survival function of a Cox model.

s = survival ( obj ) returns the survival probability at
the model&rsquo;s baseline, evaluated at each row of the Hazard
property. s = survival ( obj , X ) evaluates it at
the predictor values X , and S gives the stratum of each row
when the model is stratified. For a stratified model s is a cell
array holding one column vector per curve.

[ s , T ] = survival (&hellip;) also returns the times the
probabilities refer to.

The following Name / Value pairs are accepted:

Name Value
"Time" The times at which to evaluate the survival
function. The default is the model&rsquo;s own event times. The baseline
survival is interpolated linearly between them and raised to the hazard
ratio of X .
"ExtrapolationMethod" How to evaluate a time outside
the model&rsquo;s event times: "nearest" (default), "linear" ,
"next" , "previous" , or "none" . "none"
returns NaN outside the range, as do "next" above it and
"previous" below it.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Survival function of a Cox model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
GeneralizedLinearMixedModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 729
statistics: GeneralizedLinearMixedModel

Generalized linear mixed-effects model fitted to data.

A GeneralizedLinearMixedModel object represents a fitted generalized
linear mixed-effects model: a generalized linear model whose linear predictor
X*beta + Z*b includes normally distributed random effects
b ~ N(0, Psi) . Objects are created with fitglme .

The model is fitted by penalized quasi-likelihood. The fixed-effects
estimates and their statistics are available through the Coefficients
table, the covariance parameters through covarianceParameters , and
predictions, residuals, and hypothesis tests through the predict ,
residuals , anova , coefTest , and coefCI methods.

See also:
fitglme,
fitlme,
GeneralizedLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 54
Generalized linear mixed-effects model fitted to data.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 49
GeneralizedLinearMixedModel.CoefficientCovariance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 274
GeneralizedLinearMixedModel: property CoefficientCovariance

Covariance of the fixed-effects estimates

A square numeric matrix, one row and column per fixed-effects
coefficient, holding the estimated covariance of the estimates in
Coefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
Covariance of the fixed-effects estimates



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 44
GeneralizedLinearMixedModel.CoefficientNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 203
GeneralizedLinearMixedModel: property CoefficientNames

Names of the fixed-effects coefficients

A cell array of character vectors with one name per fixed-effects
coefficient. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
Names of the fixed-effects coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
GeneralizedLinearMixedModel.Coefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 344
GeneralizedLinearMixedModel: property Coefficients

Fixed-effects estimates and their statistics

A table with one row per fixed-effects coefficient, its row names taken
from CoefficientNames , and the variables Estimate ,
SE , tStat , DF , pValue , Lower
and Upper . Lower and Upper bound a 95%
confidence interval. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 44
Fixed-effects estimates and their statistics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
GeneralizedLinearMixedModel.DFE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 161
GeneralizedLinearMixedModel: property DFE

Residual degrees of freedom

A nonnegative integer, NumObservations less
NumCoefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
Residual degrees of freedom



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
GeneralizedLinearMixedModel.Dispersion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 202
GeneralizedLinearMixedModel: property Dispersion

Dispersion parameter

A positive scalar. It is estimated for a normal response and fixed at
1 for a binomial or Poisson one. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Dispersion parameter



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
GeneralizedLinearMixedModel.Distribution


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 207
GeneralizedLinearMixedModel: property Distribution

Response distribution

A character vector naming the distribution of the response, one of
'binomial' , 'poisson' and 'normal' . This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
Response distribution



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
GeneralizedLinearMixedModel.FitMethod


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 217
GeneralizedLinearMixedModel: property FitMethod

Estimation method

A character vector naming the method that fitted the model, one of
'MPL' , 'REMPL' , 'Laplace' and
'ApproximateLaplace' . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
Estimation method



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearMixedModel.Formula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 206
GeneralizedLinearMixedModel: property Formula

Model formula

A character vector describing the model. It is empty for a fit built
from design matrices, which carries no formula. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
Model formula



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 55
GeneralizedLinearMixedModel.GeneralizedLinearMixedModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 202
GeneralizedLinearMixedModel: glme = GeneralizedLinearMixedModel ( info )

Construct from a fitted-model info struct. Used internally by
fitglme ; call that function rather than the constructor directly.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Construct from a fitted-model info struct.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
GeneralizedLinearMixedModel.Link


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 162
GeneralizedLinearMixedModel: property Link

Link function

A character vector naming the link, one of 'logit' ,
'log' and 'identity' . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
Link function



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
GeneralizedLinearMixedModel.LogLikelihood


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 254
GeneralizedLinearMixedModel: property LogLikelihood

Log-likelihood of the fitted model

A scalar. It is a pseudo log-likelihood when FitMethod is
'MPL' or 'REMPL' , and a Laplace approximation to the
log-likelihood otherwise. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Log-likelihood of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
GeneralizedLinearMixedModel.ModelCriterion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 302
GeneralizedLinearMixedModel: property ModelCriterion

Information criteria

A scalar structure with the fields AIC , BIC ,
LogLikelihood and Deviance . The parameter count behind
AIC and BIC holds the fixed-effects coefficients, the
covariance parameters and the dispersion. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Information criteria



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 43
GeneralizedLinearMixedModel.NumCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 193
GeneralizedLinearMixedModel: property NumCoefficients

Number of fixed-effects coefficients

A positive integer counting the fixed-effects coefficients of the
model. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
Number of fixed-effects coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 43
GeneralizedLinearMixedModel.NumObservations


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 169
GeneralizedLinearMixedModel: property NumObservations

Number of observations

A positive integer counting the observations used for the fit. This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Number of observations



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
GeneralizedLinearMixedModel.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 200
GeneralizedLinearMixedModel: property ResponseName

Name of the response variable

A character vector naming the response. It is empty for a fit built
from design matrices. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Name of the response variable



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
GeneralizedLinearMixedModel.anova


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 164
GeneralizedLinearMixedModel: tbl = anova ( glme )

Analysis-of-deviance table of F-tests for the fixed-effects terms, using
residual denominator degrees of freedom.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 113
Analysis-of-deviance table of F-tests for the fixed-effects terms, using residual denominator degrees of freedom.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
GeneralizedLinearMixedModel.coefCI


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 115
GeneralizedLinearMixedModel: ci = coefCI ( glme , alpha )

Confidence intervals for the fixed-effects coefficients.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 56
Confidence intervals for the fixed-effects coefficients.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
GeneralizedLinearMixedModel.coefTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 120
GeneralizedLinearMixedModel: [ p , F , df1 , df2 ] = coefTest ( glme , H )

F-test of the linear hypothesis H*beta = 0 .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 43
F-test of the linear hypothesis H*beta = 0.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
GeneralizedLinearMixedModel.covarianceParameters


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 142
GeneralizedLinearMixedModel: [ psi , disp ] = covarianceParameters ( glme )

Return the random-effects covariance matrices and the dispersion.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 65
Return the random-effects covariance matrices and the dispersion.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
GeneralizedLinearMixedModel.designMatrix


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 138
GeneralizedLinearMixedModel: D = designMatrix ( glme , type )

Return the fixed ( "Fixed" , default) or random ( "Random" )
design matrix.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 71
Return the fixed ("Fixed", default) or random ("Random") design matrix.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
GeneralizedLinearMixedModel.fitted


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 119
GeneralizedLinearMixedModel: yf = fitted ( glme )

Return the fitted mean response (conditional on the random effects).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
Return the fitted mean response (conditional on the random effects).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
GeneralizedLinearMixedModel.fixedEffects


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 138
GeneralizedLinearMixedModel: [ beta , names ] = fixedEffects ( glme )

Return the fixed-effects coefficients and, optionally, their names.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 67
Return the fixed-effects coefficients and, optionally, their names.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearMixedModel.predict


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 272
GeneralizedLinearMixedModel: ypred = predict ( glme , Xnew , Znew , Gnew )

Predict the mean response at new data. With "Conditional" true
(default) the random effects of known grouping levels are added;
unknown levels fall back to the marginal (fixed-effects) prediction.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
Predict the mean response at new data.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
GeneralizedLinearMixedModel.randomEffects


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 117
GeneralizedLinearMixedModel: b = randomEffects ( glme )

Return the estimated random-effects (the conditional modes).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 60
Return the estimated random-effects (the conditional modes).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
GeneralizedLinearMixedModel.residuals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 175
GeneralizedLinearMixedModel: r = residuals ( glme )
GeneralizedLinearMixedModel: r = residuals ( glme , "ResidualType" , type )

Return "Raw" (default) or "Pearson" residuals.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
Return "Raw" (default) or "Pearson" residuals.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
GeneralizedLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2772
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 g relating the mean
mu to the linear predictor eta = g (mu) .

The most useful properties are Coefficients (a table of estimates,
standard errors, t -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
n -by- 2 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 N &ndash; given
either by the 'BinomialSize' pair or as the second column of a
two-column response &ndash; the response is the number of successes , as
fitglm documents. Fitted.Response is then the fitted count
N p and Residuals.Raw is on that same count scale, while
Fitted.Probability carries p 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 &ndash; 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 R^2 . This
implementation returns three coefficients, one per group.

See also:
fitglm,
LinearModel,
glmfit,
glmval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Generalized linear regression model class.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 44
GeneralizedLinearModel.CoefficientCovariance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 351
GeneralizedLinearModel: property CoefficientCovariance

Covariance matrix of the coefficient estimates

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
Covariance matrix of the coefficient estimates



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
GeneralizedLinearModel.CoefficientNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 400
GeneralizedLinearModel: property CoefficientNames

Names of the coefficients

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Names of the coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearModel.Coefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 653
GeneralizedLinearModel: property Coefficients

Coefficient values

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 statistic is referred to the normal distribution where the dispersion
is fixed, as it is for the binomial and Poisson families, and to a
t -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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
Coefficient values



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
GeneralizedLinearModel.DFE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 163
GeneralizedLinearModel: property DFE

Error degrees of freedom

A nonnegative integer, NumObservations less
NumEstimatedCoefficients .

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
Error degrees of freedom



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
GeneralizedLinearModel.Deviance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 348
GeneralizedLinearModel: property Deviance

Deviance of the fitted model

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&rsquo;s counterpart of the residual sum of squares, and it is what a
nested-model test compares.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Deviance of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
GeneralizedLinearModel.Diagnostics


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 400
GeneralizedLinearModel: property Diagnostics

Per-observation diagnostics

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&rsquo;s row of the hat
matrix. Rows not used in the fit contain NaN .

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
Per-observation diagnostics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
GeneralizedLinearModel.Dispersion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 369
GeneralizedLinearModel: property Dispersion

Dispersion parameter

A positive scalar. It is estimated from the Pearson statistic for the
normal, gamma, and inverse Gaussian families, and fixed at 1 for
the binomial and Poisson families unless 'DispersionFlag' asked
otherwise. CoefficientCovariance and the standard errors are
scaled by it.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Dispersion parameter



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
GeneralizedLinearModel.DispersionEstimated


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 323
GeneralizedLinearModel: property DispersionEstimated

Whether the dispersion was estimated

A logical scalar, true where Dispersion was estimated from the
data and false where it was held at 1 . It decides whether a
coefficient&rsquo;s statistic is referred to the normal or the t
distribution.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
Whether the dispersion was estimated



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearModel.Distribution


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 393
GeneralizedLinearModel: property Distribution

The response distribution

A structure with three fields: Name , the distribution&rsquo;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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
The response distribution



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
GeneralizedLinearModel.Fitted


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 454
GeneralizedLinearModel: property Fitted

Fitted values

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
Fitted values



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
GeneralizedLinearModel.Formula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 408
GeneralizedLinearModel: property Formula

The model formula

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&rsquo;s variables, so a categorical
predictor contributes one term however many indicators it expands to.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
The model formula



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 45
GeneralizedLinearModel.GeneralizedLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 280
GeneralizedLinearModel: mdl = GeneralizedLinearModel ( data , resp , modelspec )
GeneralizedLinearModel: mdl = GeneralizedLinearModel (&hellip;, Name , Value )

Fit a generalized linear model. Prefer the fitglm function, which
documents the accepted inputs and Name / Value pairs.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
Fit a generalized linear model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
GeneralizedLinearModel.LikelihoodPenalty


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 261
GeneralizedLinearModel: property LikelihoodPenalty

Penalty applied to the likelihood

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Penalty applied to the likelihood



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
GeneralizedLinearModel.Link


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 341
GeneralizedLinearModel: property Link

The link function

A structure with four fields: Name , the link&rsquo;s name; Link ,
a function handle mapping the mean to the linear predictor;
Derivative , a handle giving that map&rsquo;s derivative; and
Inverse , a handle mapping the linear predictor back to the mean.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
The link function



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
GeneralizedLinearModel.LogLikelihood


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 311
GeneralizedLinearModel: property LogLikelihood

Log-likelihood of the fitted model

A scalar, the log-likelihood of the observations under the fitted
coefficients and the family&rsquo;s own density. It is what the information
criteria and the likelihood-ratio R^2 are computed from.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Log-likelihood of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
GeneralizedLinearModel.ModelCriterion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 329
GeneralizedLinearModel: property ModelCriterion

Information criteria

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&rsquo;s denominator is not positive.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Information criteria



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
GeneralizedLinearModel.NumCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 274
GeneralizedLinearModel: property NumCoefficients

Number of coefficients

A positive integer counting every coefficient the model carries, those
dropped as rank deficient included. A categorical predictor with
L levels contributes L - 1 of them.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Number of coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 47
GeneralizedLinearModel.NumEstimatedCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 370
GeneralizedLinearModel: property NumEstimatedCoefficients

Number of coefficients actually estimated

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
Number of coefficients actually estimated



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
GeneralizedLinearModel.NumObservations


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 292
GeneralizedLinearModel: property NumObservations

Number of observations used in the fit

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
Number of observations used in the fit



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
GeneralizedLinearModel.NumPredictors


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 312
GeneralizedLinearModel: property NumPredictors

Number of predictor variables

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Number of predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearModel.NumVariables


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 239
GeneralizedLinearModel: property NumVariables

Number of variables

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
Number of variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
GeneralizedLinearModel.ObservationInfo


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 373
GeneralizedLinearModel: property ObservationInfo

Per-observation status

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Per-observation status



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
GeneralizedLinearModel.ObservationNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 213
GeneralizedLinearModel: property ObservationNames

Names of the observations

A cell array of character vectors, one per input observation, and empty
unless the data carried row names.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Names of the observations



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
GeneralizedLinearModel.Offset


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 322
GeneralizedLinearModel: property Offset

Offset added to the linear predictor

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
Offset added to the linear predictor



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
GeneralizedLinearModel.PredictorNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 266
GeneralizedLinearModel: property PredictorNames

Names of the predictor variables

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
Names of the predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
GeneralizedLinearModel.Residuals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 577
GeneralizedLinearModel: property Residuals

Residuals for the fitted model

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&rsquo;s
contribution to Deviance

Rows not used in the fit contain NaN .

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
Residuals for the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearModel.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 263
GeneralizedLinearModel: property ResponseName

Name of the response variable

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Name of the response variable



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
GeneralizedLinearModel.Rsquared


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 471
GeneralizedLinearModel: property Rsquared

Measures of fit

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&rsquo;s deviance to the null model&rsquo;s;
LLR , the same ratio taken over log-likelihoods; and
AdjGeneralized , the Nagelkerke measure, which rescales the
generalized R^2 by its own attainable maximum so that it can reach
one.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
Measures of fit



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
GeneralizedLinearModel.SSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 291
GeneralizedLinearModel: property SSE

Error sum of squares

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Error sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
GeneralizedLinearModel.SSR


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 243
GeneralizedLinearModel: property SSR

Regression sum of squares

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Regression sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
GeneralizedLinearModel.SST


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 290
GeneralizedLinearModel: property SST

Total sum of squares

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Total sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
GeneralizedLinearModel.Steps


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1266
GeneralizedLinearModel: property Steps

Stepwise fitting information

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&rsquo;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&rsquo;s value after the step
otherwise. The first row is the starting model, named by its right-hand
side.

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Stepwise fitting information



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearModel.VariableInfo


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 394
GeneralizedLinearModel: property VariableInfo

Per-variable information

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
Per-variable information



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
GeneralizedLinearModel.VariableNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 238
GeneralizedLinearModel: property VariableNames

Names of all the variables

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
Names of all the variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
GeneralizedLinearModel.Variables


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 309
GeneralizedLinearModel: property Variables

The data the model was built from

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.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
The data the model was built from



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
GeneralizedLinearModel.coefCI


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 323
GeneralizedLinearModel: ci = coefCI ( mdl )
GeneralizedLinearModel: ci = coefCI ( mdl , alpha )

Confidence intervals for the coefficient estimates. ci is a
k -by-2 matrix of 100 (1 - alpha )% intervals (default
alpha = 0.05). The t distribution is used when the
dispersion was estimated, the normal distribution otherwise.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 51
Confidence intervals for the coefficient estimates.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
GeneralizedLinearModel.coefTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 426
GeneralizedLinearModel: p = coefTest ( mdl )
GeneralizedLinearModel: [ p , stat , df ] = coefTest ( mdl , H )

Wald test of the linear hypothesis H b = 0 on the coefficients.
H is an m -by- k contrast matrix; when omitted it tests
that all coefficients except the intercept are zero (the model versus the
constant model). Returns the p-value p , and optionally the test
statistic stat and its numerator degrees of freedom df .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
Wald test of the linear hypothesis H b = 0 on the coefficients.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35
GeneralizedLinearModel.devianceTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 365
GeneralizedLinearModel: tbl = devianceTest ( mdl )

Likelihood-ratio (deviance) test of the fitted model against the
intercept-only model. Returns a table with the deviance, degrees of
freedom, and p-value of each model, the last row giving the chi-square
statistic (the drop in deviance) and its p-value. Each row is named by
the formula of the model it describes.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 86
Likelihood-ratio (deviance) test of the fitted model against the intercept-only model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
GeneralizedLinearModel.feval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 266
GeneralizedLinearModel: yhat = feval ( mdl , x1 , x2 , &hellip;)

Predict the response by passing each predictor as a separate argument (a
scalar or column vector), returning point predictions on the mean scale.
Equivalent to predict ( mdl , [ x1 , x2 , &hellip;]) .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 145
Predict the response by passing each predictor as a separate argument (a scalar or column vector), returning point predictions on the mean scale.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
GeneralizedLinearModel.plotAdded


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 281
GeneralizedLinearModel: h = plotAdded ( mdl , var )

Added-variable (partial-regression) plot for the predictor var (a
name or index): the response residuals from the model without var
against the residuals of var regressed on the remaining predictors.
Returns the graphics handle.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 199
Added-variable (partial-regression) plot for the predictor var (a name or index): the response residuals from the model without var against the residuals of var regressed on the remaining predictors.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 43
GeneralizedLinearModel.plotAdjustedResponse


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 292
GeneralizedLinearModel: h = plotAdjustedResponse ( mdl , var )

Adjusted-response plot for the predictor var (a name or index): the
fitted mean response as var sweeps its observed range with other
predictors held at their means, overlaid on the partial residuals.
Returns the graphics handle.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 199
Adjusted-response plot for the predictor var (a name or index): the fitted mean response as var sweeps its observed range with other predictors held at their means, overlaid on the partial residuals.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
GeneralizedLinearModel.plotDiagnostics


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 287
GeneralizedLinearModel: h = plotDiagnostics ( mdl )
GeneralizedLinearModel: h = plotDiagnostics ( mdl , plottype )

Plot observation diagnostics. plottype is 'leverage'
(default) or 'cookd' (Cook&rsquo;s distance). A reference line marks
the usual threshold. Returns the graphics handle.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Plot observation diagnostics.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
GeneralizedLinearModel.plotEffects


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 241
GeneralizedLinearModel: h = plotEffects ( mdl )

Main-effects plot: for each predictor, the change in the fitted mean
response as that predictor sweeps its observed range while the others are
held at their means. Returns the graphics handle.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 163
Main-effects plot: for each predictor, the change in the fitted mean response as that predictor sweeps its observed range while the others are held at their means.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
GeneralizedLinearModel.plotResiduals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 435
GeneralizedLinearModel: h = plotResiduals ( mdl )
GeneralizedLinearModel: h = plotResiduals ( mdl , plottype )
GeneralizedLinearModel: h = plotResiduals (&hellip;, 'ResidualType' , rt )

Plot the model residuals. plottype is one of 'histogram'
(default), 'caseorder' , 'fitted' , 'lagged' , or
'probability' . 'ResidualType' picks the residual column
( 'Raw' default, 'Pearson' , 'Deviance' ,
'Anscombe' ). Returns the graphics handle.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Plot the model residuals.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
GeneralizedLinearModel.predict


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 483
GeneralizedLinearModel: yhat = predict ( mdl , Xnew )
GeneralizedLinearModel: [ yhat , yci ] = predict ( mdl , Xnew )
GeneralizedLinearModel: [&hellip;] = predict (&hellip;, Name , Value )

Predict the response of the model mdl at the new predictor data
Xnew (a numeric matrix or a table). Predictions are on the mean
(response) scale. With two outputs, yci is an m -by-2 matrix
of confidence intervals. The 'Alpha' pair sets the confidence
level to 100 (1 - Alpha )% (default 0.05).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 99
Predict the response of the model mdl at the new predictor data Xnew (a numeric matrix or a table).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
GeneralizedLinearModel.random


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 326
GeneralizedLinearModel: ysim = random ( mdl )
GeneralizedLinearModel: ysim = random ( mdl , Xnew )

Simulate responses from the fitted model. With one argument the fitted
values are used; otherwise the mean is predicted at the new predictor
data Xnew . A random draw from the response distribution about that
mean is returned.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
Simulate responses from the fitted model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
LinearFormula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1093
statistics: LinearFormula

Model formula of a linear or generalized linear regression.

A LinearFormula object describes the terms of a fitted model: which
variables the model draws on, how they combine into terms, and how the whole
thing reads back as a formula. It is the class of the Formula
property of a LinearModel and of a GeneralizedLinearModel , and
is normally obtained from a fitted model rather than built directly.

The object is defined by its terms matrix and the names of the variables that
matrix is written over; every other property is derived from those two. Each
row of Terms is one term of the model and each column is one variable,
the entry giving the power that variable carries in that term. An all-zero
row is the intercept. The response variable occupies a column of its own,
which is always zero.

Converting the object with char renders the whole formula, response
included, as "y ~ 1 + x1 + x2" ; the LinearPredictor property
holds the right-hand side on its own. For a generalized linear model the
response carries its link function, as in "logit(y) ~ 1 + x1" .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
Model formula of a linear or generalized linear regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearFormula.FunctionCalls


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 202
LinearFormula: property FunctionCalls

Functions called from within the formula

A cell array of character vectors, empty unless the formula applies a
function to a variable. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
Functions called from within the formula



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
LinearFormula.HasIntercept


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 162
LinearFormula: property HasIntercept

Whether the model carries an intercept

A logical scalar, true when Terms holds an all-zero row. This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
Whether the model carries an intercept



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
LinearFormula.InModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 248
LinearFormula: property InModel

Which variables take part in the model

A logical row vector with one element per variable of
VariableNames , true where that variable appears in at least one
term. The response is false. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
Which variables take part in the model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearFormula.LinearFormula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1170
LinearFormula: obj = LinearFormula ()
LinearFormula: obj = LinearFormula ( terms , varnames )
LinearFormula: obj = LinearFormula ( terms , varnames , name , value , &hellip;)

Create a model formula from a terms matrix.

obj = LinearFormula () returns an empty formula.

obj = LinearFormula ( terms , varnames ) builds a
formula whose terms matrix is terms and whose variables are named
by the cell array of character vectors varnames . terms must
have one column per element of varnames ; each row is one term and
each entry the power its variable carries in that term. An all-zero row
is the intercept.

The remaining properties are derived from these two arguments, except
those given as name - value pairs:

name value
"ResponseName" A character vector naming the response
variable. It must be one of varnames .
"Link" The link function applied to the response, as a
name, a numeric exponent, or a structure of function handles. It
defaults to "identity" .
"ModelFun" A function handle computing the linear
predictor from the coefficients and the design matrix.
"FunctionCalls" A cell array of character vectors
naming functions the formula applies to its variables.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 43
Create a model formula from a terms matrix.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
LinearFormula.LinearPredictor


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 315
LinearFormula: property LinearPredictor

Right-hand side of the formula

A character vector rendering the model&rsquo;s terms, such as
"1 + x1 + x2" . A pair of variables appearing both on their own
and as an interaction is written as a product, so that
"x1 + x2 + x1:x2" reads "x1*x2" . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
Right-hand side of the formula



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
LinearFormula.Link


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 250
LinearFormula: property Link

Link function applied to the response

The link of a generalized linear model, given as its name, its numeric
exponent, or a structure of function handles. It is "identity"
for a linear model. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
Link function applied to the response



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
LinearFormula.ModelFun


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 173
LinearFormula: property ModelFun

Function computing the linear predictor

A function handle taking the coefficient vector and the design matrix.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
Function computing the linear predictor



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
LinearFormula.NPredictors


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 165
LinearFormula: property NPredictors

Number of variables the model uses

A non-negative integer, the number of true elements of InModel .
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Number of variables the model uses



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearFormula.NTerms


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 143
LinearFormula: property NTerms

Number of terms in the model

A non-negative integer, the number of rows of Terms . This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Number of terms in the model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
LinearFormula.NVars


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 168
LinearFormula: property NVars

Number of variables available to the model

A non-negative integer, the number of elements of
VariableNames . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Number of variables available to the model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
LinearFormula.PredictorNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 223
LinearFormula: property PredictorNames

Names of the variables the model actually uses

A cell array of character vectors holding those elements of
VariableNames that appear in at least one term. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
Names of the variables the model actually uses



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
LinearFormula.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 173
LinearFormula: property ResponseName

Name of the response variable

A character vector naming the variable on the left-hand side of the
formula. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Name of the response variable



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
LinearFormula.TermNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 476
LinearFormula: property TermNames

Name of each term of the model

A column cell array of character vectors, one per row of Terms ,
naming the term over the model&rsquo;s variables : the intercept is
"(Intercept)" , an interaction joins its factors with a colon, and
a power is written with a caret. A categorical variable contributes one
term under its own name however many indicator columns it expands to, so
these are not the coefficient names. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
Name of each term of the model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
LinearFormula.Terms


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 269
LinearFormula: property Terms

Terms matrix of the model

A numeric matrix with one row per term and one column per variable of
VariableNames , each entry giving the power that variable carries
in that term. An all-zero row is the intercept. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Terms matrix of the model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearFormula.VariableNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 277
LinearFormula: property VariableNames

Names of all variables available to the model

A cell array of character vectors naming every variable the model was
given, whether or not it is used, in the order the data lists them. The
response is included. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 45
Names of all variables available to the model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
LinearFormula.char


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 270
LinearFormula: str = char ( obj )

Render a model formula as a character vector.

str = char ( obj ) returns the whole formula, response
included, as in "y ~ 1 + x1 + x2" . The response carries the
link function of a generalized linear model, as in
"logit(y) ~ 1 + x1" .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 45
Render a model formula as a character vector.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearFormula.string


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 137
LinearFormula: str = string ( obj )

Render a model formula as a string scalar.

str = string ( obj ) is the string counterpart of
char .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Render a model formula as a string scalar.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
LinearMixedModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 707
statistics: LinearMixedModel

Linear mixed-effects model fitted to data.

A LinearMixedModel object represents a fitted linear mixed-effects
model
$$ y = X\beta + Zb + \varepsilon, $$
with fixed effects beta , random effects b distributed as
N(0, Psi) , and independent errors N(0, sigma2) . Objects are
created with fitlmematrix (from design matrices).

The estimated fixed effects and their statistics are available through the
Coefficients table; the covariance parameters through
covarianceParameters ; the random-effect BLUPs through
randomEffects ; and predictions, residuals, and hypothesis tests
through the predict , residuals , anova , coefTest ,
and coefCI methods.

See also:
fitlmematrix,
fitlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Linear mixed-effects model fitted to data.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
LinearMixedModel.CoefficientCovariance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 263
LinearMixedModel: property CoefficientCovariance

Covariance of the fixed-effects estimates

A square numeric matrix, one row and column per fixed-effects
coefficient, holding the estimated covariance of the estimates in
Coefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
Covariance of the fixed-effects estimates



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
LinearMixedModel.CoefficientNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 192
LinearMixedModel: property CoefficientNames

Names of the fixed-effects coefficients

A cell array of character vectors with one name per fixed-effects
coefficient. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
Names of the fixed-effects coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
LinearMixedModel.Coefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 333
LinearMixedModel: property Coefficients

Fixed-effects estimates and their statistics

A table with one row per fixed-effects coefficient, its row names
taken from CoefficientNames , and the variables
Estimate , SE , tStat , DF ,
pValue , Lower and Upper . Lower and
Upper bound a 95% confidence interval. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 44
Fixed-effects estimates and their statistics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearMixedModel.DFE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 150
LinearMixedModel: property DFE

Residual degrees of freedom

A nonnegative integer, NumObservations less
NumCoefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
Residual degrees of freedom



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
LinearMixedModel.FitMethod


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 225
LinearMixedModel: property FitMethod

Estimation method

A character vector, either 'ML' for maximum likelihood or
'REML' for restricted maximum likelihood, naming the method
that fitted the model. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
Estimation method



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
LinearMixedModel.Formula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 195
LinearMixedModel: property Formula

Model formula

A character vector describing the model. It is empty for a fit built
from design matrices, which carries no formula. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
Model formula



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
LinearMixedModel.LinearMixedModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 223
LinearMixedModel: lme = LinearMixedModel ( info )

Construct a LinearMixedModel from a fitted-model info struct.
This constructor is used internally by fitlmematrix ; call that
function rather than the constructor directly.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 61
Construct a LinearMixedModel from a fitted-model info struct.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
LinearMixedModel.LogLikelihood


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 215
LinearMixedModel: property LogLikelihood

Log-likelihood of the fitted model

A scalar, the maximised log-likelihood, or the maximised restricted
log-likelihood when FitMethod is 'REML' . This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Log-likelihood of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearMixedModel.MSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 142
LinearMixedModel: property MSE

Residual variance estimate

A positive scalar, the estimate of the error variance. This property
is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
Residual variance estimate



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
LinearMixedModel.ModelCriterion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 298
LinearMixedModel: property ModelCriterion

Information criteria

A scalar structure with the fields AIC , BIC ,
LogLikelihood and Deviance . The parameter count
behind AIC and BIC holds the fixed-effects
coefficients, the covariance parameters and the residual variance.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Information criteria



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
LinearMixedModel.NumCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 182
LinearMixedModel: property NumCoefficients

Number of fixed-effects coefficients

A positive integer counting the fixed-effects coefficients of the
model. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
Number of fixed-effects coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
LinearMixedModel.NumEstimatedCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 295
LinearMixedModel: property NumEstimatedCoefficients

Number of estimated fixed-effects coefficients

A positive integer counting the fixed-effects coefficients estimated
from the data. Every coefficient the model carries is estimated, so
this equals NumCoefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
Number of estimated fixed-effects coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
LinearMixedModel.NumObservations


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 158
LinearMixedModel: property NumObservations

Number of observations

A positive integer counting the observations used for the fit. This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Number of observations



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
LinearMixedModel.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 189
LinearMixedModel: property ResponseName

Name of the response variable

A character vector naming the response. It is empty for a fit built
from design matrices. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Name of the response variable



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
LinearMixedModel.Rsquared


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 267
LinearMixedModel: property Rsquared

Coefficient of determination

A scalar structure with the fields Ordinary and
Adjusted . Ordinary is one less the ratio of
SSE to SST , and Adjusted corrects that ratio
for the error degrees of freedom. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Coefficient of determination



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearMixedModel.SSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 184
LinearMixedModel: property SSE

Error sum of squares

A nonnegative scalar, the sum of the squared differences between the
response and the conditional fit. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Error sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearMixedModel.SSR


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 197
LinearMixedModel: property SSR

Regression sum of squares

A nonnegative scalar, the sum of the squared deviations of the
conditional fit about the mean of the response. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Regression sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearMixedModel.SST


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 118
LinearMixedModel: property SST

Total sum of squares

A nonnegative scalar, SSE plus SSR . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Total sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
LinearMixedModel.anova


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 298
LinearMixedModel: tbl = anova ( lme )
LinearMixedModel: tbl = anova ( lme , "DFMethod" , method )

Analysis-of-variance table of F-tests for the fixed-effects terms. Each
row tests one coefficient. method selects the denominator degrees
of freedom: "Residual" (default, n - p ) or
"Satterthwaite" .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 66
Analysis-of-variance table of F-tests for the fixed-effects terms.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
LinearMixedModel.coefCI


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 242
LinearMixedModel: ci = coefCI ( lme )
LinearMixedModel: ci = coefCI ( lme , alpha )

Confidence intervals for the fixed-effects coefficients at level
1 - alpha (default alpha = 0.05). Row j holds
the lower and upper bounds for coefficient j .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 98
Confidence intervals for the fixed-effects coefficients at level 1 - alpha (default alpha = 0.05).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
LinearMixedModel.coefTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 441
LinearMixedModel: p = coefTest ( lme )
LinearMixedModel: p = coefTest ( lme , H )
LinearMixedModel: [ p , F , df1 , df2 ] = coefTest (&hellip;)

Test the linear hypothesis H*beta = 0 with an F-test. With no
H , tests that all non-intercept coefficients are zero (intercept
is taken to be the first coefficient). Returns the p-value and,
optionally, the F-statistic and its numerator and denominator degrees of
freedom (denominator = n - p ).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 53
Test the linear hypothesis H*beta = 0 with an F-test.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
LinearMixedModel.covarianceParameters


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 193
LinearMixedModel: [ psi , mse ] = covarianceParameters ( lme )

Return the estimated random-effects covariance matrices psi (a cell
array, one per grouping term) and the residual variance mse .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 128
Return the estimated random-effects covariance matrices psi (a cell array, one per grouping term) and the residual variance mse.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
LinearMixedModel.designMatrix


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 183
LinearMixedModel: D = designMatrix ( lme , type )

Return the fixed-effects design matrix ( type = "Fixed" ,
default) or the expanded random-effects design matrix
( type = "Random" ).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 128
Return the fixed-effects design matrix (type = "Fixed", default) or the expanded random-effects design matrix (type = "Random").



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
LinearMixedModel.fitted


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 261
LinearMixedModel: yf = fitted ( lme )
LinearMixedModel: yf = fitted ( lme , "Conditional" , tf )

Return the fitted values. With "Conditional" true (the default)
the fit includes the random effects ( X*beta + Z*b ); with false it
is the marginal fit ( X*beta ).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Return the fitted values.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
LinearMixedModel.fixedEffects


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 187
LinearMixedModel: beta = fixedEffects ( lme )
LinearMixedModel: [ beta , names ] = fixedEffects ( lme )

Return the estimated fixed-effects coefficients beta and,
optionally, their names.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 82
Return the estimated fixed-effects coefficients beta and, optionally, their names.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
LinearMixedModel.predict


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 598
LinearMixedModel: ypred = predict ( lme , Xnew , Znew , Gnew )
LinearMixedModel: [ ypred , yci ] = predict (&hellip;)
LinearMixedModel: [&hellip;] = predict (&hellip;, name , value )

Predict the response at new fixed-effects design Xnew ,
random-effects design Znew , and grouping Gnew . By default
the prediction is conditional on the estimated random effects (levels of
Gnew not seen in the fit fall back to the marginal prediction).
With
"Conditional" false the marginal prediction Xnew*beta is
returned. The second output yci gives 95% (or "Alpha" )
confidence intervals for the marginal mean.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 101
Predict the response at new fixed-effects design Xnew, random-effects design Znew, and grouping Gnew.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
LinearMixedModel.randomEffects


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 238
LinearMixedModel: b = randomEffects ( lme )
LinearMixedModel: [ b , names ] = randomEffects ( lme )

Return the best linear unbiased predictors (BLUPs) of the random effects
b and, optionally, a cell array of group:level:predictor
labels.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 137
Return the best linear unbiased predictors (BLUPs) of the random effects b and, optionally, a cell array of group:level:predictor labels.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
LinearMixedModel.residuals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 304
LinearMixedModel: r = residuals ( lme )
LinearMixedModel: r = residuals ( lme , "ResidualType" , type )

Return the conditional residuals y - (X*beta + Z*b) . type
is "Raw" (default), "Pearson" (raw divided by
sqrt (sigma2) ), or "Standardized" (raw divided by the
square root of its estimated variance).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 52
Return the conditional residuals y - (X*beta + Z*b).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
LinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6990
statistics: LinearModel

Linear regression model

The LinearModel class represents a least-squares (or, optionally,
robust) linear regression fit of a response variable to one or more
predictor variables. A LinearModel object is returned by the
fitlm function and holds everything about the fit in one place:
the fitted coefficients, the data and specification used to produce
them, and the diagnostics needed to assess the quality of the fit.

The properties of a LinearModel object fall into four groups:

Group Properties
Coefficient estimates Coefficients (a table of
estimates, standard errors, t-statistics, and p-values for each term),
CoefficientCovariance , CoefficientNames , and the
coefficient counts NumCoefficients and
NumEstimatedCoefficients .
Summary statistics of the fit DFE ,
Fitted , Residuals (raw, Pearson, Studentized, and
standardized), Diagnostics (leverage, Cook&rsquo;s distance, and other
per-observation influence measures), MSE , RMSE ,
Rsquared (ordinary and adjusted), SSE , SSR ,
SST , LogLikelihood , ModelCriterion (AIC, BIC, etc.),
and ModelFitVsNullModel (the F-test of the fitted model against an
intercept-only model).
Fitting method information Robust , which records
the weighting function and tuning constant used when the model is fit by
robust regression, and is empty for an ordinary least squares fit, and
Steps , which records the stepwise fitting information whenever
the model was fit using stepwise regression, and is currently always
empty.
Input data properties Formula ,
NumObservations , NumPredictors , NumVariables ,
ObservationInfo (which observations were used, excluded, missing,
or weighted), ObservationNames , PredictorNames ,
ResponseName , VariableInfo , VariableNames , and
Variables .

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 &ndash; 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 R^2 . This implementation returns three coefficients, one
per group.

A LinearModel object supports categorical predictors, which are
automatically encoded internally as indicator (dummy) variables,
observation weights for a weighted least squares fit, excluding specific
observations from the fit, and robust regression using iteratively
reweighted least squares. Once fitted, the following methods are
available on a LinearModel object:

Method Description
predict Predict responses at new predictor values
given in a matrix or table, or reproduce the training fitted values when
called with no new data. Can also return pointwise or simultaneous
confidence or prediction intervals alongside the point predictions.
feval Predict responses given predictors as
separate scalar or vector arguments (one per predictor variable) instead
of a single matrix, so a LinearModel object can be evaluated the
same way as a plain function handle. Returns point predictions only.
random Simulate new response values at new
predictor locations by adding independent Gaussian noise, drawn from the
estimated error variance MSE , to the fitted response.
coefCI Return Wald confidence intervals for every
fitted coefficient at a chosen significance level (default 0.05 ).
coefTest Test a linear hypothesis on the fitted
coefficients. With no arguments, tests the overall model F-test that
all non-intercept coefficients are zero; a custom hypothesis can be
given as a contrast matrix and, if needed, right-hand-side values.
Returns the p-value, and optionally the F-statistic and its numerator
degrees of freedom.
dwtest Durbin-Watson test for first-order
autocorrelation among the model residuals, with a choice of exact or
approximate p-value computation and a one- or two-sided alternative.
addTerms Return a new, refitted LinearModel
with terms added to the current model specification, given as a
Wilkinson formula fragment or a terms matrix. Weights, excluded rows,
and categorical encodings carry over automatically; the original model
object is left unmodified.
removeTerms Return a new, refitted
LinearModel with terms removed from the current model
specification, given as a Wilkinson formula fragment or a terms matrix.
Weights, excluded rows, and categorical encodings carry over
automatically; the original model object is left unmodified.
plotResiduals Plot the model residuals. Default
is a probability density histogram; other supported plot types are
'fitted' , 'caseorder' , 'lagged' ,
'probability' , and 'observed' .
plotDiagnostics Plot per-observation influence
diagnostics. Default is leverage by observation row number; other
supported plot types are 'cookd' , 'covratio' ,
'dfbetas' , 'dffits' , 's2_i' , and
'contour' (standardized residuals against leverage with Cook&rsquo;s
distance contours).
plotEffects Plot the estimated main effect and
95% confidence interval of each predictor, evaluated between its
observed minimum and maximum with all other predictors held at their
observed means.
plotAdjustedResponse Plot the fitted response
against a single predictor, with the other predictors averaged out by
averaging the fitted values over the observations used in the fit.
plotAdded Plot the incremental effect of one or
more terms on the response, after removing the effects of all other
terms, along with the fitted line and its 95% confidence bounds.
plot Plot a default view of the model. Creates an
added variable plot for the whole model when more than one predictor
is included, a scatter plot of the data with a fitted curve and 95%
confidence bounds when exactly one predictor is included, or a
histogram of the residuals when no predictors are included.
plotInteraction Plot the main and conditional effects
of two predictors, or the adjusted response as a function of one
predictor for several fixed values of the other, to visualize whether
the two predictors interact.
compact Return a CompactLinearModel that
discards the training data and per-observation diagnostics while
retaining the coefficient estimates and fit statistics needed for
prediction and inference.
anova Analysis of variance for the fitted model,
reporting either the per-term breakdown of sums of squares or a
summary table of the model against the total and residual variation.
step Improve the fitted model by one or more
steps of stepwise term selection, returning a new, refitted
LinearModel without modifying the original.

Create a LinearModel object by using the fitlm function or
the class constructor directly.

See also:
fitlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
Linear regression model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
LinearModel.CoefficientCovariance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 282
LinearModel: property CoefficientCovariance

Covariance matrix of coefficient estimates

A p -by- p numeric matrix of covariance values for the
coefficient estimates, where p is the number of coefficients in
the fitted model as given by NumCoefficients . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Covariance matrix of coefficient estimates



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
LinearModel.CoefficientNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 219
LinearModel: property CoefficientNames

Coefficient names

A cell array of character vectors, each containing the name of the
corresponding model term (e.g., '(Intercept)' , 'x1' ,
'x1:x2' ). This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
Coefficient names



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
LinearModel.Coefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 409
LinearModel: property Coefficients

Coefficient values

A table with one row for each coefficient and four columns:

Estimate - estimated coefficient value
SE - standard error of the estimate
tStat - t-statistic for a two-sided test
pValue - p-value for the t-statistic

Coefficients that are dropped due to rank deficiency have
Estimate = 0 , SE = 0 , tStat = NaN ,
pValue = NaN . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
Coefficient values



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
LinearModel.DFE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 234
LinearModel: property DFE

Degrees of freedom for error

A positive integer equal to the number of observations minus the number
of estimated coefficients: DFE = NumObservations -
NumEstimatedCoefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Degrees of freedom for error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
LinearModel.Diagnostics


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 788
LinearModel: property Diagnostics

Observation diagnostics

A table with one row per observation and seven columns:

Leverage - diagonal of the hat matrix H
CooksDistance - Cook&rsquo;s distance, a measure of scaled
change in fitted values
Dffits - delete-1 scaled differences in fitted values
S2_i - delete-1 residual variance estimate
CovRatio - ratio of the determinant of the coefficient
covariance matrix with and without each observation
Dfbetas - n -by- p matrix of scaled changes
in coefficient estimates when each observation is deleted in turn
HatMatrix - n -by- n projection matrix such
that Fitted = HatMatrix * y

Rows not used in fitting have NaN in CooksDistance ,
Dffits , S2_i , and CovRatio , and zeros in
Leverage , Dfbetas , and HatMatrix . This property
is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
Observation diagnostics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
LinearModel.Fitted


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 694
LinearModel: property Fitted

Fitted response values

An n -by-1 numeric vector of predicted response values based on
the training data, where n is the total number of observations,
excluded and missing rows included. Every observation whose predictors
are available carries a fitted value, whether or not it was used in the
fit, so an excluded row and a row missing only its response are both
fitted; only a row whose predictors are missing is NaN . The
corresponding Residuals are NaN for any row not used in
the fit, so Fitted and Residuals.Raw do not add back to
the response there. Use predict to obtain predictions for new
data or to compute confidence bounds. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Fitted response values



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
LinearModel.Formula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 334
LinearModel: property Formula

Model formula information

A LinearFormula object representing the model formula, with
properties including ResponseName , LinearPredictor ,
PredictorNames , TermNames , HasIntercept ,
Terms (the terms matrix), and InModel . Converting it with
char renders the whole formula. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Model formula information



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
LinearModel.LinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5394
LinearModel: mdl = LinearModel ( X , y )
LinearModel: mdl = LinearModel ( tbl , resp_input )
LinearModel: mdl = LinearModel (&hellip;, modelspec )
LinearModel: mdl = LinearModel (&hellip;, Name , Value , &hellip;)

Create a LinearModel class object representing a linear
regression model.

mdl = LinearModel ( X , y ) returns a
LinearModel object fit to the response y and the
predictor data X . Unless removed via the 'Intercept'
option, the fitted model contains a constant (intercept) term and one
linear term for every column of X .

X is an N&times;P numeric or logical matrix of predictor data,
where rows correspond to observations and columns correspond to
variables. By default, the predictors are named 'x1' ,
'x2' , &hellip;, 'xP' .

y is an N&times;1 numeric or logical vector of response values,
and must have the same number of observations (rows) as X . By
default, the response is named 'y' .

mdl = LinearModel ( tbl , resp_input ) fits a
model using the variables in the table (or dataset) tbl as
predictors. resp_input selects the response and can be a
character vector naming a variable in tbl , or a numeric vector
the same height as tbl to use as an external response. If
resp_input is left empty, the last variable in tbl is used
as the response. Variables that are categorical arrays, cell
arrays of character vectors, or logical arrays are automatically
treated as categorical predictors.

mdl = LinearModel (&hellip;, modelspec ) additionally
specifies the terms of the model to fit. modelspec can be any of
the following.

Value Description
'constant' Model contains only an intercept
term.
'linear' Model contains an intercept and one
term for each predictor variable. This is the default when
modelspec is not specified.
'interactions' Model contains an intercept, all
linear terms, and all pairwise products of distinct predictor
variables (no squared terms).
'purequadratic' Model contains an intercept,
all linear terms, and all squared terms.
'quadratic' Model contains an intercept, all
linear terms, all pairwise products of distinct predictor variables,
and all squared terms.
'full' Model contains an intercept and all
terms up to and including the full P -way interaction of the
predictor variables.
terms matrix A T&times;P or T&times;(P+1) numeric
matrix, where T is the number of terms and P is the
number of predictor variables. Each row represents one term, and the
value in column j is the exponent to which predictor j
is raised in that term; a row of all zeros represents the intercept.
If a T&times;(P+1) matrix is supplied, its last column (representing
the response variable) must be all zeros.
Wilkinson formula A character vector of the form
'y ~ terms' describing the response and predictor terms using
Wilkinson notation. For table input, the variable to the left of
'~' is used as the response, overriding resp_input .

mdl = LinearModel (&hellip;, Name , Value ,
&hellip;) specifies additional options using one or more
Name-Value pair arguments as described below.

Name Value
'Intercept' A logical scalar indicating
whether to include a constant (intercept) term in the model. Default
is true . Ignored when modelspec is a Wilkinson formula.
'Weights' A numeric vector of nonnegative
observation weights, with one element per observation, used to fit a
weighted least squares model. Default is a vector of ones.
'Exclude' A numeric or logical vector
specifying observations to exclude from the fit, given as row indices
or a logical mask. Excluded observations, together with any
observation containing a missing value, are recorded in
ObservationInfo but do not contribute to the fit.
'CategoricalVars' Specifies which predictor
variables are treated as categorical, given as a vector of column
indices, a logical vector, or a cell array of variable names. Each
categorical predictor with L categories is expanded into
L-1 indicator (dummy) variables, using the first category as
the reference level.
'VarNames' A cell array of character vectors
naming the predictor and response variables, in order, with the
response variable name last. Only applies to matrix input, since
table variables already carry their own names.
'ResponseVar' A character vector naming the
response variable, used to override the response variable name that
would otherwise be used.
'PredictorVars' A cell array of character
vectors naming which variables in tbl to use as predictors. By
default, all variables other than the response variable are used.
'RobustOpts' Selects ordinary least squares or
robust regression fitting. This value can be 'off' (default,
ordinary least squares), 'on' (robust fitting using the
'bisquare' weighting function), the name of one of the
weighting functions below, a function handle for a custom weighting
function, or a scalar structure with fields RobustWgtFun and
Tune specifying the weighting function and its tuning
constant. Robust fitting uses Iteratively Reweighted Least Squares
(IRLS), refitting the model with updated observation weights until the
coefficients converge. Supported weighting function names:
'andrews' , 'bisquare' , 'cauchy' ,
'fair' , 'huber' , 'logistic' , 'ols' ,
'talwar' , 'welsch' , each with its own default tuning
constant.

mdl is returned as a LinearModel object. If
'RobustOpts' is anything other than 'off' , the returned
model is a robust fit rather than an ordinary least squares fit.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73
Create a LinearModel class object representing a linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
LinearModel.LogLikelihood


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1613
LinearModel: property LogLikelihood

Log-likelihood of the fitted model

A scalar numeric value equal to the log-likelihood of the response
values, assuming each response is normally distributed with mean equal
to the fitted value and variance equal to SSE/n (the MLE
variance estimate). This property is read-only.

For a weighted fit, observation i is taken to have variance
s^2/w_i , so the log-likelihood carries the term
0.5 &times; sum (log (w)) and n counts only the observations
with nonzero weight:

logL = -n/2 &times; (1 + log (2&times;pi&times;SSE/n)) + 0.5 &times; sum (log (w))

This makes the value invariant to the scale of the weights, as it must
be: multiplying every weight by a constant rescales the estimated
variance by the same constant and leaves the fit unchanged.

MATLAB omits the 0.5 &times; sum (log (w)) term and counts every
observation in n , so its LogLikelihood moves by
n/2 &times; log (c) when the weights are multiplied by c , and
the ModelCriterion values built on it move with it. This
implementation follows R&rsquo;s logLik.lm instead. Unweighted fits
are unaffected, and agree with MATLAB.

A robust fit carries no weight term. Its SSE is a robust scale
estimate rather than a weighted residual sum, so the two enter
separately and the general form is used:

logL = -n/2 &times; log (2&times;pi&times;SSE/n) - sum (w .&times; r.^2) / (2&times;SSE/n)

which is what MATLAB computes, and which reduces to the expression
above whenever sum (w .&times; r.^2) equals SSE , as it does for
any least-squares fit. Robust fits therefore agree with MATLAB
exactly, weighted or not.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Log-likelihood of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
LinearModel.MSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 202
LinearModel: property MSE

Mean squared error

A scalar numeric value equal to SSE / DFE , where SSE is
the sum of squared errors and DFE is the degrees of freedom for
error. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
Mean squared error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
LinearModel.ModelCriterion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 715
LinearModel: property ModelCriterion

Model comparison criteria

A structure with four fields:

AIC - Akaike information criterion:
-2 &times; logL + 2 &times; m
AICc - AIC corrected for sample size:
AIC + (2&times;m&times;(m+1))/(n-m-1)
BIC - Bayesian information criterion:
-2 &times; logL + m &times; log(n)
CAIC - Consistent AIC:
-2 &times; logL + m &times; (log(n) + 1)

Here logL is LogLikelihood , m is
NumEstimatedCoefficients , and n is the number of
observations with nonzero weight, which is NumObservations
unless some weight is zero. This property is read-only.

Because these are built on LogLikelihood , they inherit its
treatment of weights; see that property for how it differs from
MATLAB&rsquo;s.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Model comparison criteria



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
LinearModel.ModelFitVsNullModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 337
LinearModel: property ModelFitVsNullModel

F-test of the fitted model versus the null model

A structure with three fields:

Fstat - F-statistic of the fitted model versus a null
model containing only a constant term
Pvalue - p-value for the F-statistic
NullModel - character vector describing the null model

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
F-test of the fitted model versus the null model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearModel.NumCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 259
LinearModel: property NumCoefficients

Number of model coefficients

A positive integer giving the total number of coefficients in the fitted
model, including any coefficients set to zero because the model terms are
rank deficient. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Number of model coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
LinearModel.NumEstimatedCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 299
LinearModel: property NumEstimatedCoefficients

Number of estimated coefficients

A positive integer giving the number of coefficients actually estimated,
i.e., not set to zero due to rank deficiency.
NumEstimatedCoefficients equals the degrees of freedom for
regression. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
Number of estimated coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearModel.NumObservations


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 283
LinearModel: property NumObservations

Number of observations used in the fit

A positive integer giving the number of observations actually used in
fitting. Rows with missing values and rows excluded via the
'Exclude' name-value argument are not counted. This property
is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 38
Number of observations used in the fit



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
LinearModel.NumPredictors


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 178
LinearModel: property NumPredictors

Number of predictor variables

A positive integer giving the number of predictor variables used to
fit the model. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Number of predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
LinearModel.NumVariables


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 236
LinearModel: property NumVariables

Number of variables in the input data

A positive integer giving the total number of variables in the input
data, counting predictors, the response, and any unused columns.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
Number of variables in the input data



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearModel.ObservationInfo


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 450
LinearModel: property ObservationInfo

Per-observation metadata

An n -by-4 table where n is the total number of rows in
the input data. The four columns are:

Weights - observation weight, default is 1
Excluded - logical; true if excluded via the
'Exclude' argument
Missing - logical; true if the row contains any
NaN value
Subset - logical; true if the observation was used in
the fit, i.e. not excluded and not missing

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
Per-observation metadata



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
LinearModel.ObservationNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 284
LinearModel: property ObservationNames

Observation names

A cell array of character vectors containing the names of the
observations. If the fit was based on a table that has row names,
this property holds those names. Otherwise it is an empty cell array.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
Observation names



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 26
LinearModel.PredictorNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 200
LinearModel: property PredictorNames

Names of predictor variables

A cell array of character vectors containing the names of the
predictor variables used to fit the model. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Names of predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
LinearModel.RMSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 124
LinearModel: property RMSE

Root mean squared error

A scalar numeric value equal to sqrt(MSE) . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
Root mean squared error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
LinearModel.Residuals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 579
LinearModel: property Residuals

Residuals for the fitted model

A table with one row per observation and four columns:

Raw - observed minus fitted values
Pearson - raw residuals divided by RMSE
Standardized - internally studentized residuals; raw
residuals divided by their estimated standard deviation using the
full-model MSE
Studentized - externally studentized residuals; each raw
residual divided by an estimate of the standard deviation based on
all observations except that one, using the delete-1 S2_i

Rows not used in the fit contain NaN . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
Residuals for the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
LinearModel.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 152
LinearModel: property ResponseName

Response variable name

A character vector containing the name of the response variable.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Response variable name



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
LinearModel.Robust


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 431
LinearModel: property Robust

Robust fit information

A structure with three fields:

WgtFun - robust weighting function name, e.g.
'bisquare'
Tune - tuning constant; empty if WgtFun is
'ols' or a function handle with the default tuning constant
Weights - vector of final iteration weights; empty for
a CompactLinearModel object

This structure is empty unless the model was fit using robust
regression. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Robust fit information



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearModel.Rsquared


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 267
LinearModel: property Rsquared

R-squared goodness-of-fit statistics

A structure with two fields:

Ordinary - coefficient of determination:
R^2 = SSR / SST
Adjusted - adjusted R^2 that accounts for the
number of coefficients in the model

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
R-squared goodness-of-fit statistics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
LinearModel.SSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 244
LinearModel: property SSE

Sum of squared errors

A scalar numeric value equal to the sum of squared residuals. For a
model with an intercept, SST = SSE + SSR . For weighted fits,
this is the weighted sum of squares. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
Sum of squared errors



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
LinearModel.SSR


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 300
LinearModel: property SSR

Regression sum of squares

A scalar numeric value equal to the sum of squared deviations of the
fitted values from the mean of the response. For a model with an
intercept, SST = SSE + SSR . For weighted fits, this is the
weighted sum of squares. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Regression sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
LinearModel.SST


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 349
LinearModel: property SST

Total sum of squares

A scalar numeric value equal to the sum of squared deviations of the
response from its mean. For a model with an intercept,
SST = SSE + SSR . For a robust fit, SST = SSE + SSR
rather than the deviation from the mean. For weighted fits, this is
the weighted sum of squares. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Total sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
LinearModel.Steps


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1255
LinearModel: property Steps

Stepwise fitting information

A structure recording the term-selection trace, populated whenever the
model was fit by stepwiselm or improved by step , 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
'SSE' .
PEnter the threshold a term must beat to enter.
PRemove the threshold above which a term leaves.
History a table with one row per step.

History carries the columns Action ( 'Start' ,
'Add' , or 'Remove' ), TermName , Terms (the
terms matrix after the step, over the model&rsquo;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:
FStat and pValue under 'SSE' , and otherwise a
single column named for the criterion ( AIC , BIC ,
Rsquared , or AdjRsquared ) holding its value after the
step.

The first row is the starting model, named by its right-hand side, and
step appends to the history it inherits rather than starting a
new one. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Stepwise fitting information



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
LinearModel.VariableInfo


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 512
LinearModel: property VariableInfo

Information about input variables

A table with one row per variable including any unused variables, and
four columns:

Class - variable class as a character vector, e.g.
'double' or 'categorical'
Range - for continuous variables, a two-element vector
[min, max] ; for categorical variables, a vector of the
distinct values
InModel - logical; true if the variable is in the
fitted model
IsCategorical - logical; true if the variable is
categorical

This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Information about input variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
LinearModel.VariableNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 388
LinearModel: property VariableNames

Names of all variables in the input data

A cell array of character vectors containing the names of all
variables, including predictors, the response, and unused variables.
For table input these are the table column names. For matrix input
these are the values given by 'VarNames' , defaulting to
{'x1','x2',...,'xp','y'} . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
Names of all variables in the input data



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
LinearModel.Variables


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 320
LinearModel: property Variables

Input data as a table

A table containing predictor and response values for all observations,
including unused variables. For table input this is the full input
table. For matrix input this is a table constructed from the
predictor matrix and response vector. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
Input data as a table



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearModel.addTerms


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1858
LinearModel: NewMdl = addTerms ( mdl , terms )

Add terms to a fitted linear regression model.

addTerms returns a new LinearModel refitted on the same
data and settings as mdl with the specified terms appended
to the model formula. The original model mdl is never modified;
all settings including observation weights, excluded rows, and
categorical variable encodings are carried over automatically. To
update a model in place, reassign the result:
mdl = addTerms ( mdl , terms ) .

terms may be a character vector in Wilkinson notation. Use
'x1' for a main effect, 'x1:x2' for a two-way
interaction, 'x1*x2' to add both main effects and their
interaction in one step, 'x1 + x2^2' to add several terms at
once, or '1' to add an intercept to a no-intercept model. A
bare power term 'x1^2' adds x1 together with
x1^2 (and any intermediate powers), matching the Wilkinson
hierarchy convention; power notation used inside an interaction, e.g.
'x1:x2^2' , adds only that exact interaction term. All
variable names must match entries in mdl .PredictorNames .

terms may also be a numeric matrix of size t -by- v ,
where t is the number of terms to add and v equals
mdl .NumVariables . Entry T(i,j) is the exponent of
variable j in term i . For example, in a model with
variables x1 , x2 , y : [0 0 0] is the
intercept, [0 1 0] is x2 , [1 1 0] is
x1:x2 , and [2 0 0] is x1^2 . The last column
(response) is always zero. A matrix with mdl .NumPredictors
columns is also accepted and is automatically padded with a trailing
zero column for the response.

Terms that are already present in mdl are silently skipped. If
every specified term already exists, a warning is issued and mdl
is returned unchanged. For a categorical predictor, addTerms
adds the full group of indicator variables for that predictor in one
step rather than adding individual indicator columns.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
Add terms to a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
LinearModel.anova


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2529
LinearModel: tbl = anova ( mdl )
LinearModel: tbl = anova ( mdl , anovatype )
LinearModel: tbl = anova ( mdl , "components" , sstype )

Analysis of variance for a linear regression model.

anova ( mdl ) returns a table tbl with component
ANOVA statistics for every term in mdl except the constant
term, computed with hierarchical ( "h" ) sums of squares. Each
row gives SumSq , DF , MeanSq , F , and
pValue for the corresponding term; the trailing Error
row gives SumSq = mdl .SSE , DF = mdl .DFE ,
MeanSq = mdl .MSE , and NaN for F and
pValue .

MATLAB reports F = 1 and pValue = 0.5 on that
Error row instead. Those are not results: the row&rsquo;s F
is its own MeanSq divided by itself, so it is 1 for every
data set, and the pValue follows. MATLAB does not use them
consistently either, reporting NaN for the same quantity on the
Residual row of its summary table. This implementation reports
NaN in both places. Every other value in both tables agrees
with MATLAB.

anova ( mdl , anovatype ) selects
"components" (default) or "summary" . For
"summary" , tbl always contains rows Total ,
Model , and Residual , and additionally . Linear
and . Nonlinear whenever mdl contains an interaction
term or a continuous term of degree greater than 1. Total
reports mdl .SST with DF = NumObservations - 1 ;
Model reports mdl .SSR with DF =
NumCoefficients - HasIntercept ; Residual reports
mdl .SSE with DF = mdl .DFE . Whenever the
data contains two or more observations sharing identical predictor
values, tbl additionally contains . Lack of fit and
. Pure error , splitting Residual into the part
explained by replicated observations and the remainder.

anova ( mdl , "components" , sstype ) selects
the sum of squares used for the component table: 1 (sequential,
reduction from adding each term in formula order), 2 (reduction
from adding the term to a model containing every term that does not
contain it), "h" (default; as Type 2, but a higher-degree
term in the same continuous variable, such as a squared term, is also
treated as containing the lower-degree term), or 3 (reduction
from adding the term to a model containing every other term, with
categorical predictors recoded using sum-to-zero deviation contrasts
instead of mdl &rsquo;s reference-level coding). Because Type 3 uses a
different coding, its Error row can differ from mdl .SSE
and mdl .DFE when mdl is missing a lower-order relative of
one of its terms (e.g. an interaction without one of its main
effects, or a categorical predictor fit without an intercept).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 51
Analysis of variance for a linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
LinearModel.coefCI


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1316
LinearModel: ci = coefCI ( mdl )
LinearModel: ci = coefCI ( mdl , alpha )

Confidence intervals for the coefficient estimates of a fitted linear
regression model.

ci = coefCI ( mdl ) returns 95% confidence intervals
for every coefficient in mdl using a default significance level of
0.05 .

ci = coefCI ( mdl , alpha ) uses the significance
level alpha , a scalar in [0, 1] . The resulting intervals
have coverage 100(1-\alpha)\% . Setting alpha to 0
produces intervals of infinite width; setting it to 1 collapses
each interval to the corresponding point estimate.

The output ci is a k -by-2 numeric matrix where
k = mdl .NumCoefficients . Row j contains
the interval for the j -th coefficient, whose name is stored in
mdl .CoefficientNames{j} . Column 1 is the lower bound and
column 2 is the upper bound. The midpoint of each interval equals the
corresponding point estimate in mdl .Coefficients.Estimate .

Intervals use the Wald method:
b_j \pm t_{(1-\alpha/2,\,\mathrm{DFE})}\,\mathrm{SE}(b_j) ,
where b_j is the coefficient estimate, \mathrm{SE}(b_j) is
its standard error from mdl .Coefficients.SE , and the
critical value is the 1-\alpha/2 quantile of the
t -distribution with mdl .DFE degrees of freedom.
In rank-deficient models, aliased coefficients have
\mathrm{SE} = 0 and their row in ci is [0, 0] .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 87
Confidence intervals for the coefficient estimates of a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
LinearModel.coefTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2022
LinearModel: p = coefTest ( mdl )
LinearModel: p = coefTest ( mdl , H )
LinearModel: p = coefTest ( mdl , H , C )
LinearModel: [ p , F ] = coefTest (&hellip;)
LinearModel: [ p , F , r ] = coefTest (&hellip;)

Linear hypothesis test on the coefficients of a fitted linear regression
model.

coefTest tests whether one or more linear combinations of the
fitted coefficients equal specified constants. Each linear combination
is encoded as a row of the contrast matrix H , and the right-hand
side is given by C .

p = coefTest ( mdl ) performs the overall model F-test:
it tests the joint null hypothesis that every coefficient except the
intercept is zero. The returned p-value matches the F-statistic line
printed at the bottom of the model display.

p = coefTest ( mdl , H ) tests the null hypothesis
H \beta = 0 , where \beta is the full coefficient vector
of length k = mdl .NumCoefficients . H must be
a full-rank numeric matrix with k columns; each row specifies one
linear constraint. To test a single coefficient, use a row vector with a
1 in that coefficient&rsquo;s position and zeros elsewhere; the
resulting F-statistic equals the square of the corresponding t-statistic
in mdl .Coefficients . To test a categorical predictor that
expands to multiple indicator columns, include one row per indicator in
H .

p = coefTest ( mdl , H , C ) tests
H \beta = C instead of zero. C must be a numeric vector
with the same number of elements as rows of H ; both row and column
vectors are accepted.

The second output F is the value of the F-statistic:
F = (H\hat{\beta} - C)^\prime (H V H^\prime)^{-1}
(H\hat{\beta} - C) / r , where V is
mdl .CoefficientCovariance and r is the number of
rows of H . The third output r is that numerator degrees of
freedom; the denominator degrees of freedom is mdl .DFE .
Under the null hypothesis F follows an F(r, \mathrm{DFE})
distribution and the p-value is the upper-tail probability. When
H is rank-deficient but contains no NaN , both p and
F are returned as NaN without an error.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 79
Linear hypothesis test on the coefficients of a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
LinearModel.compact


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1088
LinearModel: cmdl = compact ( mdl )

Create a compact version of a fitted linear regression model.

cmdl = compact ( mdl ) returns a
CompactLinearModel object that retains the coefficient
estimates, coefficient covariance, fit statistics, model formula, and
fitting method information of mdl , but discards the training
data and everything derived from it. Specifically, the following
properties of mdl are not carried over and are unavailable on
cmdl : Fitted , Residuals , Diagnostics ,
ObservationInfo , ObservationNames , Variables ,
Steps , and ModelFitVsNullModel .

If mdl was fit using robust regression, the Robust
structure is retained on cmdl except for its Weights
field, which is always emptied; RobustWgtFun and Tune
are preserved unchanged.

A CompactLinearModel object consumes less memory than a
LinearModel object and can still be used with predict ,
feval , random , coefCI , and coefTest , but
does not support methods that require the original training data or
refitting, such as addTerms , removeTerms , step ,
and dwtest .

See also:
LinearModel,
CompactLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 61
Create a compact version of a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
LinearModel.dwtest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2164
LinearModel: p = dwtest ( mdl )
LinearModel: p = dwtest ( mdl , method )
LinearModel: p = dwtest ( mdl , method , tail )
LinearModel: [ p , DW ] = dwtest (&hellip;)

Durbin-Watson test for serial autocorrelation of linear regression
residuals.

dwtest checks whether the raw residuals of mdl are
correlated with their immediate neighbours in observation order, which
would violate the independence assumption of ordinary least squares.
The null hypothesis is that there is no autocorrelation. A small
p-value gives evidence against this and suggests that the residuals are
not independent. This test is most meaningful when the observations
have a natural ordering, such as a time series.

The test is based on the Durbin-Watson statistic
DW = \sum_{i=1}^{n-1}(e_{i+1}-e_i)^2 / \sum_{i=1}^{n}e_i^2 ,
where e_i are the raw residuals of the active (non-excluded)
observations. The statistic always lies in [0, 4] : values near
2 indicate no autocorrelation, values well below 2
indicate positive autocorrelation (adjacent residuals tend to have the
same sign), and values well above 2 indicate negative
autocorrelation (adjacent residuals tend to alternate in sign).

method controls how the p-value is computed and defaults to
'exact' . 'exact' uses the eigenvalues of the
projected differencing matrix together with Imhof&rsquo;s numerical
integration to obtain a precise p-value; this is slower but accurate
for any sample size. 'approximate' uses a normal approximation
based on the first two moments of the DW distribution under the null;
this is faster and adequate for large samples but less reliable for
small ones. The argument is case-insensitive.

tail selects the alternative hypothesis and defaults to
'both' . 'right' tests for positive autocorrelation
( DW < 2 ), 'left' tests for negative autocorrelation
( DW > 2 ), and 'both' tests for autocorrelation in
either direction. The one-sided p-values always satisfy
p_{\mathrm{right}} + p_{\mathrm{left}} = 1 , and the two-sided
p-value equals 2\min(p_{\mathrm{right}}, p_{\mathrm{left}}) .

The second output DW is the value of the Durbin-Watson statistic
itself; it does not depend on method or tail .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 77
Durbin-Watson test for serial autocorrelation of linear regression residuals.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
LinearModel.feval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1352
LinearModel: ypred = feval ( mdl , X )
LinearModel: ypred = feval ( mdl , x1 , x2 , &hellip;, xp )

Predict responses of a fitted linear regression model using separate
predictor inputs.

ypred = feval ( mdl , X ) accepts a single
numeric matrix X with one column per predictor in the same order
as the training data, or a table whose column names match
mdl .PredictorNames . The output is an n -by-1 column
vector. Rows that contain NaN in any predictor column are
returned as NaN .

ypred = feval ( mdl , x1 , x2 , &hellip;,
xp ) accepts exactly mdl .NumPredictors separate
arguments, one per predictor variable. All non-scalar arguments must
have the same size; a scalar argument is broadcast to that size
automatically. The output shape follows the shape of the non-scalar
inputs: column vector inputs give a column vector output, row vector
inputs give a row vector output, and all-scalar inputs give a scalar.
This form is convenient when predictor data is already stored in separate
vectors rather than a combined matrix.

feval gives the same numerical predictions as predict but
does not support confidence intervals. Use predict when you also
need bounds on the response. Because a LinearModel object behaves
like a function through feval , it can be passed directly to
routines that accept a function handle, such as fminsearch or
integral .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 86
Predict responses of a fitted linear regression model using separate predictor inputs.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
LinearModel.plot


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1478
LinearModel: plot ( mdl )
LinearModel: plot ( ax , mdl )
LinearModel: h = plot (&hellip;)

Create a default diagnostic plot for a fitted linear regression model.

plot ( mdl ) creates a plot whose type depends on the
number of predictors in mdl . If mdl has two or more
predictors, plot creates an added variable plot for the whole
model except the constant (intercept) term, equivalent to
plotAdded ( mdl ) . If mdl has exactly one
predictor, plot creates a scatter plot of the data together
with the fitted curve and its 95% confidence bounds. If mdl
has no predictors, plot creates a histogram of the residuals,
equivalent to plotResiduals ( mdl ) .

For the single-predictor case, the fitted curve and confidence
bounds are computed with predict , evaluated at 100 equally
spaced points spanning the observed range of the predictor when the
predictor is numeric, or at each level of the predictor when it is
categorical. Excluded or missing observations appear as NaN
in the data and produce gaps in the plotted points.

plot ( ax , mdl ) plots into the axes object
ax instead of the current axes returned by gca .

h = plot (&hellip;) returns a vector of graphics object
handles. For the two-or-more-predictor and no-predictor cases, see
plotAdded and plotResiduals , respectively, for the
meaning of h . For the single-predictor case, h (1),
h (2), and h (3) correspond to the data points, the fitted
curve, and the 95% confidence bounds of the fitted curve,
respectively.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
Create a default diagnostic plot for a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
LinearModel.plotAdded


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2477
LinearModel: plotAdded ( mdl )
LinearModel: plotAdded ( mdl , coef )
LinearModel: plotAdded ( mdl , coef , Name , Value )
LinearModel: plotAdded ( ax , &hellip;)
LinearModel: h = plotAdded (&hellip;)

Create an added variable plot for a fitted linear regression model.

plotAdded ( mdl ) creates an added variable plot for the
whole model mdl except the constant (intercept) term.

plotAdded ( mdl , coef ) creates an added variable
plot for the coefficients specified by coef . coef is a
character vector or string naming a single coefficient in
mdl.CoefficientNames , the name of a categorical predictor in
mdl.PredictorNames (which selects that predictor&rsquo;s whole group
of indicator coefficients), or a vector of positive integers indexing
into mdl.CoefficientNames .

An added variable plot, also known as a partial regression leverage
plot, illustrates the incremental effect on the response of the
selected terms after removing the effects of all other terms. For a
single selected predictor x_1 , the response y and
x_1 are each fit to all other terms:
y_i = g_y (x_{2i}, &hellip;, x_{pi}) + r_{yi} ,
x_{1i} = g_x (x_{2i}, &hellip;, x_{pi}) + r_{xi} . The adjusted
values are \tilde y_i = \bar y + r_{yi} and
\tilde x_{1i} = \bar x_1 + r_{xi} . When coef selects
more than one coefficient, the selected columns of the design matrix
are combined into a single direction using the unit vector
u = \beta / \lVert \beta \rVert , and the added variable plot is
created for that combined direction.

Excluded or missing observations appear as NaN in the adjusted
data and produce gaps in the plotted data points.

plotAdded ( mdl , coef , Name , Value )
specifies additional Name-Value arguments applied to the adjusted data
points ( h(1) ). The following are accepted:

Name Description and default
'Color' Marker color. Default: [0.1490 0.5490 0.8660] .
'Marker' Marker symbol. Default: 'x' .
'MarkerSize' Marker size in points. Default: 6 .
'MarkerEdgeColor' Marker edge color. Default: 'auto' .
'MarkerFaceColor' Marker fill color. Default: 'none' .
'LineWidth' Width of the marker edge in points. Default: 0.5 .

plotAdded ( ax , &hellip;) plots into the axes object
ax instead of the current axes returned by gca .

h = plotAdded (&hellip;) returns a 3-by-1 vector of line
handles. h(1) , h(2) , and h(3) correspond to the
adjusted data points, the fitted line, and the 95% confidence bounds
of the fitted line, respectively. Name-Value arguments only affect
h(1) .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 67
Create an added variable plot for a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
LinearModel.plotAdjustedResponse


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2335
LinearModel: plotAdjustedResponse ( mdl , var )
LinearModel: plotAdjustedResponse ( mdl , var , Name , Value )
LinearModel: plotAdjustedResponse ( ax , &hellip;)
LinearModel: h = plotAdjustedResponse (&hellip;)

Plot the adjusted response of a fitted linear regression model against
a single predictor.

plotAdjustedResponse ( mdl , var ) creates an adjusted
response plot for the predictor var in the linear regression
model mdl . var is a character vector or string naming a
predictor in mdl.PredictorNames , or a positive integer indexing
into mdl.VariableNames .

An adjusted response function describes the fitted response as a
function of a single predictor, with the other predictors averaged out
by averaging the fitted values over the observations used in the fit.
For a model y_i = f (x_{1i}, x_{2i}, &hellip;, x_{pi}) + r_i , the
adjusted response function for x_1 is
g (x_1) = (1/n) \sum_{i=1}^n f (x_1, x_{2i}, x_{3i}, &hellip;,
x_{pi}) , where n is the number of observations used to fit the
model. The adjusted response data value for observation i is
\tilde y_i = g (x_{1i}) + r_i .

For a numeric predictor, the adjusted response function is evaluated
on an evenly spaced grid of 100 points spanning the minimum to the
maximum observed value of var . For a categorical predictor, the
adjusted response function is evaluated at each category level.

Excluded or missing observations appear as NaN in the adjusted
data and produce gaps in the plotted data points.

plotAdjustedResponse ( mdl , var , Name ,
Value ) specifies additional Name-Value arguments applied to the
adjusted data points ( h(1) ). The following are accepted:

Name Description and default
'Color' Marker color. Default: [0.1490 0.5490 0.8660] .
'Marker' Marker symbol. Default: 'x' .
'MarkerSize' Marker size in points. Default: 6 .
'MarkerEdgeColor' Marker edge color. Default: 'auto' .
'MarkerFaceColor' Marker fill color. Default: 'none' .
'LineWidth' Width of the marker edge in points. Default: 0.5 .

plotAdjustedResponse ( ax , &hellip;) plots into the axes
object ax instead of the current axes returned by gca .

h = plotAdjustedResponse (&hellip;) returns a 2-by-1
vector of line handles. h(1) corresponds to the adjusted
response data points and h(2) corresponds to the adjusted
response function. Name-Value arguments only affect h(1) .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 90
Plot the adjusted response of a fitted linear regression model against a single predictor.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearModel.plotDiagnostics


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3831
LinearModel: plotDiagnostics ( mdl )
LinearModel: plotDiagnostics ( mdl , plottype )
LinearModel: plotDiagnostics ( mdl , plottype , Name , Value )
LinearModel: plotDiagnostics ( ax , &hellip;)
LinearModel: h = plotDiagnostics (&hellip;)

Plot observation diagnostics of a fitted linear regression model.

plotDiagnostics ( mdl ) creates a case-order plot of the
leverage of each observation. The x-axis is the observation row number
running from 1 to the total number of rows including any excluded rows.
A dotted horizontal reference line marks the recommended threshold
2p/n , where p is mdl.NumCoefficients and n
is mdl.NumObservations .

plotDiagnostics ( mdl , plottype ) creates the diagnostic
plot specified by plottype . For all types except "contour" ,
the x-axis is the row number and covers all rows including excluded ones.
Excluded rows produce NaN values in the diagnostic vectors, which
appear as natural gaps in the plot with no special handling required.
plottype must be one of:

'leverage' (default)
Leverage of each observation ( mdl.Diagnostics.Leverage ).
One dotted horizontal reference line at 2p/n .
Returns two handles: h(1) is the data scatter and h(2)
is the reference line.
'cookd'
Cook&rsquo;s distance for each observation
( mdl.Diagnostics.CooksDistance ). One dotted reference line at
3 \times \mathrm{mean(CooksDistance)} , where the mean ignores
NaN values. Returns two handles: h(1) data, h(2)
reference.
'covratio'
Delete-1 ratio of the determinant of the coefficient covariance matrix
( mdl.Diagnostics.CovRatio ). Two dotted reference lines at
1 - 3p/n (lower bound) and 1 + 3p/n (upper bound).
Both bounds are stored as a single NaN -separated line object.
Returns two handles: h(1) data, h(2) combined reference.
'dfbetas'
Delete-1 scaled change in each coefficient estimate
( mdl.Diagnostics.Dfbetas , one column per coefficient).
One line object is drawn per coefficient. Two dotted reference lines
at \pm 3/\sqrt{n} are stored as a single NaN -separated
line object. Returns p+1 handles: h(1) through
h(p) are the per-coefficient data lines and h(p+1) is
the combined reference. Name-Value arguments are applied to all
p data handles.
'dffits'
Delete-1 scaled change in the fitted value
( mdl.Diagnostics.Dffits ). Two dotted reference lines at
\pm 2\sqrt{p/n} stored as a single NaN -separated line.
Returns two handles: h(1) data, h(2) combined reference.
's2_i'
Delete-1 variance estimate ( mdl.Diagnostics.S2_i ). One dotted
reference line at mdl.MSE . Returns two handles: h(1)
data, h(2) reference.
'contour'
Standardized residuals on the y-axis against leverage on the x-axis,
with Cook&rsquo;s distance contours overlaid at levels
[0.05, 0.10, 0.15, 0.20, 0.25] . The contour surface is
computed on a 31-by-30 grid over the range of the active leverage and
residual values. Returns two handles: h(1) is the data scatter
(a line object) and h(2) is the contour object.

plotDiagnostics ( ax , &hellip;) targets the axes object
ax instead of the current axes returned by gca .

h = plotDiagnostics (&hellip;) returns a vector of graphics
handles. The number of handles depends on plottype as described
above. Name-Value arguments are applied to the data handle h(1) ,
except for "dfbetas" where they are applied to all p
coefficient handles. Reference line handles are never affected by
Name-Value arguments.

Name Description and default
'Color' Marker color for data points. For "dfbetas" this color is
applied to all p coefficient line objects.
Default: [0.1490 0.5490 0.8660] .
'Marker' Marker symbol. Any symbol accepted by plot is valid.
Default: 'x' .
'MarkerSize' Marker size in points. Default: 6 .
'MarkerEdgeColor' Marker edge color. Default: 'auto' .
'MarkerFaceColor' Marker fill color. Default: 'none' .
'LineWidth' Width of the marker edge in points. Default: 0.5 .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 65
Plot observation diagnostics of a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
LinearModel.plotEffects


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1574
LinearModel: plotEffects ( mdl )
LinearModel: plotEffects ( ax , mdl )
LinearModel: h = plotEffects (&hellip;)

Plot the main effects of each predictor in a fitted linear regression
model.

plotEffects ( mdl ) creates a horizontal dot-and-line plot
with one row per predictor. Each dot shows the estimated main effect on
the response from changing that predictor from its minimum observed value
to its maximum observed value, while holding all other predictors fixed
at their observed means. A horizontal line through each dot shows the
95% confidence interval for that effect.

The main effect for predictor xs is defined as
g(x_{s,\max}) - g(x_{s,\min}) , where the adjusted response
function g evaluates the model at the specified value of
xs with all other predictors set to their observed means.
For numeric predictors the sign of the effect can be positive or
negative depending on the direction of the relationship.

plotEffects ( ax , mdl ) creates the plot in the axes
object ax instead of the current axes returned by gca .

h = plotEffects (&hellip;) returns a vector of
p+1 graphics handles where p is the number of predictors.
h(1) is the line object containing the effect estimate markers
(one circle per predictor, plotted as a single line object with
XData of length p and YData = 1:p ).
h(j+1) is the confidence interval line for predictor j ,
with XData = [ci_lo, ci_hi] and YData = [j, j] .

The y-axis tick labels follow the format
'varname: min to max' , showing the predictor name and the
minimum and maximum observed values used to compute the effect.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 76
Plot the main effects of each predictor in a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
LinearModel.plotInteraction


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2804
LinearModel: plotInteraction ( mdl , var1 , var2 )
LinearModel: plotInteraction ( mdl , var1 , var2 , ptype )
LinearModel: plotInteraction ( ax , &hellip;)
LinearModel: h = plotInteraction (&hellip;)

Plot the interaction effects of two predictors in a fitted linear
regression model.

plotInteraction ( mdl , var1 , var2 ) creates a
plot of the main effects of var1 and var2 together with
their conditional effects, with horizontal lines through each effect
value indicating its 95% confidence interval. var1 and
var2 are each a character vector or string naming a variable in
mdl.VariableNames , or a positive integer indexing into
mdl.VariableNames ; neither may name the response variable, and
they must be different variables.

The main effect of a predictor is the change in the adjusted response
between the two predictor values that produce the minimum and maximum
adjusted response, with the other predictor averaged over its own
observed values row by row. For a numeric predictor these two values
are its observed minimum and maximum; for a categorical predictor
every level is evaluated and the levels producing the minimum and
maximum adjusted response are used, so the effect is always
nonnegative.

The conditional effect of var1 is its effect recomputed with
var2 additionally held fixed at each of a small set of
conditioning values, and likewise the conditional effect of
var2 holds var1 fixed. The conditioning values are the
observed minimum, mean of the minimum and maximum, and maximum for a
numeric predictor, or every level for a categorical predictor. When
the main effect and conditional effect points for a predictor do not
align vertically, the model exhibits an interaction between
var1 and var2 .

plotInteraction ( mdl , var1 , var2 , ptype )
selects the plot type. ptype is 'effects' (default), as
described above, or 'predictions' , which instead plots the
adjusted response as a function of var2 for each conditioning
value of var1 held fixed, evaluated over 101 equally spaced
points spanning the observed range of var2 when var2 is
numeric, or at each level of var2 when it is categorical.

plotInteraction ( ax , &hellip;) plots into the axes object
ax instead of the current axes returned by gca .

h = plotInteraction (&hellip;) returns a vector of line
handles. When ptype is 'effects' , h(1) is the
marker line through the two main effect points, h(2) and
h(3) are the confidence interval lines for the main effects of
var1 and var2 , and the remaining entries are the
conditional effect points and their confidence intervals, tagged
'conditional1' for var1 and 'conditional2' for
var2 . The main effect line objects are tagged 'main' .
When ptype is 'predictions' , each entry in h
corresponds to one adjusted response curve, one per conditioning
value of var1 .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 83
Plot the interaction effects of two predictors in a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
LinearModel.plotResiduals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4379
LinearModel: plotResiduals ( mdl )
LinearModel: plotResiduals ( mdl , plottype )
LinearModel: plotResiduals ( mdl , plottype , Name , Value )
LinearModel: plotResiduals ( ax , &hellip;)
LinearModel: h = plotResiduals (&hellip;)

Plot residuals of a fitted linear regression model.

plotResiduals ( mdl ) creates a probability density histogram
of the raw residuals. Bin width follows Scott&rsquo;s rule
h = 3.5 \hat\sigma n^{-1/3} and is rounded to a visually clean
value. The bar areas sum to 1.

plotResiduals ( mdl , plottype ) creates the type of
residual plot given by plottype . For all types except
"histogram" and "probability" , the full observation vector
including excluded rows is passed to the plot. Excluded or missing rows
appear as NaN in the plotted data and produce visible gaps.
plottype must be one of:

'histogram' (default)
Probability density histogram. Only active observations are used.
Returns one patch handle. Accepts FaceColor ,
EdgeColor , FaceAlpha , and LineWidth Name-Value
arguments.
'fitted'
Residuals on the y-axis against fitted values on the x-axis. A dotted
horizontal reference line marks y = 0 . Returns two line handles:
h(1) is the data scatter and h(2) is the reference line.
'caseorder'
Residuals on the y-axis against observation row number on the x-axis,
covering all rows from 1 to n_total . A dotted horizontal
reference line marks y = 0 . Returns two line handles:
h(1) is the data and h(2) is the reference line.
'lagged'
Each residual r(t) on the y-axis against the preceding residual
r(t-1) on the x-axis. Two dotted reference lines mark
y = 0 and x = 0 . Returns three line handles: h(1)
is the scatter, h(2) is the horizontal reference, and h(3)
is the vertical reference.
'probability'
Normal probability plot of the sorted active residuals produced by
normplot . Returns two handles: h(1) is the data line and
h(2) is the fitted reference line produced by normplot .
Name-Value arguments are not applied for this plot type.
'observed'
Observed response values on the y-axis against fitted values on the
x-axis. A dotted y = x reference line is drawn through the
origin. Vertical segments connect each observed point down to the
reference line.
Returns three handles: h(1) is the scatter, h(2) is the
y = x reference, and h(3) is the vertical segment line
(stored as a single NaN -separated line object).
'symmetry'
Upper-tail distances from the median plotted against lower-tail distances
from the median. Each point (x, y) satisfies
x = \mathrm{med} - r_{(i)} and
y = r_{(n+1-i)} - \mathrm{med} , using the
\lfloor n/2 \rfloor most extreme observations on each side. A
perfectly symmetric distribution falls on the dotted y = x
reference line. Returns two handles: h(1) is the scatter and
h(2) is the reference line.

plotResiduals ( ax , &hellip;) targets the axes object ax
instead of the current axes returned by gca .

h = plotResiduals (&hellip;) returns a vector of graphics
handles. The number of handles depends on plottype as described
above. Name-Value arguments are applied to the data handle h(1)
only. Reference lines are always drawn with the default style and are
not affected by Name-Value arguments.

The following Name-Value arguments are accepted. Arguments marked
histogram only are passed directly to the patch object and
have no effect on other plot types. Arguments marked
non-histogram are applied to the scatter marker and have no
effect on the histogram.

Name Description and default
'ResidualType' Type of residual to plot. One of 'raw' (default),
'pearson' , 'standardized' , or 'studentized' .
Case-insensitive. Selects the corresponding column of
mdl.Residuals .
'Color' ( non-histogram ) Marker color.
Default: [0.1490 0.5490 0.8660] .
'Marker' ( non-histogram ) Marker symbol. Any symbol accepted by
plot is valid. Default: 'x' .
'MarkerSize' ( non-histogram ) Marker size in points. Default: 6 .
'MarkerEdgeColor' ( non-histogram ) Marker edge color. Default: 'auto' .
'MarkerFaceColor' ( non-histogram ) Marker fill color. Default: 'none' .
'LineWidth' ( non-histogram ) Width of the marker edge in points.
Default: 0.5 .
'FaceColor' ( histogram only ) Fill color of the histogram bars.
Default: [0.1490 0.5490 0.8660] .
'EdgeColor' ( histogram only ) Edge color of the histogram bars.
'FaceAlpha' ( histogram only ) Transparency of the histogram bars,
specified as a scalar in [0, 1] .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 51
Plot residuals of a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
LinearModel.predict


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1927
LinearModel: ypred = predict ( mdl , Xnew )
LinearModel: ypred = predict ( mdl )
LinearModel: [ ypred , yci ] = predict ( mdl , Xnew )
LinearModel: [ ypred , yci ] = predict ( mdl , Xnew , Name , Value )

Predict responses from a fitted linear regression model.

ypred = predict ( mdl , Xnew ) returns the fitted
response values at the new predictor locations in Xnew . Xnew
can be a numeric matrix with one column per predictor in the same order
as the training data, or a table whose column names match
mdl .PredictorNames . Rows containing NaN are returned
as NaN without error.

ypred = predict ( mdl ) omits Xnew and returns
fitted values for the original training observations in their original
row order. Rows that were excluded or contained missing values are
returned as NaN . The result is identical to
mdl .Fitted .

[ ypred , yci ] = predict (&hellip;) also returns
yci , an n -by-2 matrix of confidence bounds where column 1 is
the lower bound and column 2 is the upper bound. By default these are
95% pointwise confidence intervals on the mean response.

Name-Value pair arguments:

Name Value
'Alpha' Significance level for the confidence
interval, specified as a scalar in [0,1] . The interval has
coverage 100(1-\alpha)\% . Default is 0.05 , giving a 95%
interval.
'Prediction' Type of interval to compute.
"curve" (default) gives a confidence interval on the mean response
f(x) . "observation" gives a wider prediction interval for
a single future observation y = f(x) + \varepsilon , which accounts
for both estimation uncertainty and irreducible noise; it adds
mdl .MSE to the variance before computing the half-width.
'Simultaneous' Logical flag controlling whether
the bounds are simultaneous or pointwise. When true ,
Scheff'{e}&rsquo;s method is used so the entire predicted curve lies within
the band with 100(1-\alpha)\% confidence; these bands are always
wider than pointwise ones. Default is false .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 56
Predict responses from a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
LinearModel.random


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1122
LinearModel: ysim = random ( mdl , Xnew )

Simulate responses with random noise from a fitted linear regression
model.

ysim = random ( mdl , Xnew ) computes the fitted
response at each row of Xnew and then adds independent Gaussian
noise to each value. The noise is drawn from N(0, \sigma^2) where
\sigma^2 is the estimated error variance mdl .MSE
(mean squared error of the fit). The result is a column vector of the
same length as the number of rows in Xnew .

Xnew is required and must be non-empty. It can be a numeric
matrix with one column per predictor in the same order as the training
data, or a table whose column names match
mdl .PredictorNames . Unlike predict , there is no
no-argument form; the predictor locations must always be supplied
explicitly.

Because the added noise is drawn freshly on every call, two calls with
the same Xnew will generally produce different output. To get
reproducible results, set the random seed with rand ('state', s)
before calling random .

For deterministic predictions without noise, use predict or
feval . predict also provides confidence intervals on the
mean response.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 75
Simulate responses with random noise from a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
LinearModel.removeTerms


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1909
LinearModel: NewMdl = removeTerms ( mdl , terms )

Remove terms from a fitted linear regression model.

removeTerms returns a new LinearModel refitted on the same
data and settings as mdl , but with the specified terms
dropped from the model formula. The original model mdl is never
modified; all settings including observation weights, excluded rows, and
categorical variable encodings are carried over automatically. To
update a model in place, reassign the result:
mdl = removeTerms ( mdl , terms ) .

terms may be a character vector in Wilkinson notation. Use
'x2' to remove a main effect, 'x1:x2' to remove an
interaction, '1' to remove the intercept, or 'x1 + x2^2'
to remove several terms at once. A bare power term 'x1^2'
removes x1 together with x1^2 (and any intermediate
powers), matching the Wilkinson hierarchy convention; power notation
used inside an interaction, e.g. 'x1:x2^2' , removes only that
exact interaction term. The star operator 'x1*x2' removes the
main effects x1 and x2 together with their interaction
x1:x2 in a single call, following the same expansion rule as
addTerms . All variable names must match entries in
mdl .PredictorNames .

terms may also be a numeric matrix of size t -by- v ,
where t is the number of terms to remove and v equals
mdl .NumVariables . Entry T(i,j) is the exponent of
variable j in term i . For example, in a model with
variables x1 , x2 , y : [0 0 0] is the
intercept, [0 1 0] is x2 , [1 1 0] is
x1:x2 , and [2 0 0] is x1^2 . A matrix with
mdl .NumPredictors columns is also accepted and is
automatically padded with a trailing zero column for the response.

Terms specified but absent from mdl are silently skipped. A
warning is issued and mdl is returned unchanged only when every
single specified term is absent from the model. For a categorical
predictor, removeTerms removes the full group of indicator
variables for that predictor in one step.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 51
Remove terms from a fitted linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
LinearModel.step


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 942
LinearModel: NewMdl = step ( mdl )
LinearModel: NewMdl = step ( mdl , Name , Value )

Improve a fitted linear regression model by one or more steps of
stepwise term selection.

step examines whether adding or removing a single term from
mdl improves the fit, and returns the resulting model as
NewMdl . The original model mdl is never modified. Unlike
stepwiselm , step performs only one such improvement step
by default; pass 'NSteps' to allow more.

step accepts the same 'Criterion' , 'PEnter' ,
'PRemove' , 'NSteps' , 'Verbose' , 'Lower' ,
and 'Upper' Name-Value options as stepwiselm , with the
same defaults, except 'NSteps' defaults to 1 rather than
unlimited. mdl &rsquo;s own predictors, weights, excluded observations,
and categorical variable settings are carried over automatically as
the starting point for the search.

step is not available for a model fitted with robust
regression.

See also:
stepwiselm,
addTerms,
removeTerms


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 89
Improve a fitted linear regression model by one or more steps of stepwise term selection.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
NonLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1837
statistics: mdl = NonLinearModel (&hellip;)

Nonlinear regression model class.

A NonLinearModel object holds a nonlinear regression fitted by
fitnlm , together with its coefficients, fit statistics, and methods
for inference, prediction, and diagnostics. Construct one with
fitnlm , which documents the accepted inputs and
Name / Value pairs.

The estimated coefficients and their statistics are in the
Coefficients table; Rsquared , ModelCriterion ,
LogLikelihood , RMSE , SSE , SST , and SSR
summarize the fit. The methods predict , feval , random ,
coefCI , coefTest , plotResiduals , plotDiagnostics ,
and plotSlice operate on the fitted model.

Fit statistics

The fit statistics follow MATLAB&rsquo;s conventions. SSE is the residual
sum of squares, SST the total sum of squares of the response about its
(weighted) mean, and SSR the regression sum of squares of the fitted
values about that mean; because the model is nonlinear, SST does
not in general equal SSR + SSE . Rsquared.Ordinary is
1 - SSE / SST and Rsquared.Adjusted corrects for
the error degrees of freedom. RMSE is sqrt ( MSE ) , and
the Gaussian LogLikelihood uses the maximum-likelihood error variance
SSE / n . The information criteria in ModelCriterion
( AIC , AICc , BIC , CAIC ) count the p
coefficients as the only parameters &ndash; the error variance is not
counted. coefTest is a Wald test: for a contrast matrix H it
forms ( H *b)' * inv ( H * V * H ') * ( H *b) / r
with V the coefficient covariance and r the number of rows of
H , referred to an F distribution on r and DFE
degrees of freedom. The summary printed by disp instead reports an
F statistic versus the zero model, formed from the uncorrected
regression sum of squares (the sum of the squared fitted values).

See also:
fitnlm,
nlinfit,
nlparci,
nlpredci,
LinearModel,
GeneralizedLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Nonlinear regression model class.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
NonLinearModel.CoefficientCovariance


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 340
NonLinearModel: property CoefficientCovariance

Estimated covariance of the coefficients

A square numeric matrix, one row and column per coefficient, holding
the estimated covariance of the estimates in Coefficients .
The square roots of its diagonal are the standard errors reported in
column SE of that table. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 40
Estimated covariance of the coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 31
NonLinearModel.CoefficientNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 295
NonLinearModel: property CoefficientNames

Names of the coefficients

A cell array of character vectors with one name per coefficient, in
the order the model function expects them. The names default to
'b1' , 'b2' and so on, unless fitnlm was given a
list of its own. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Names of the coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
NonLinearModel.Coefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 381
NonLinearModel: property Coefficients

Coefficient estimates and their statistics

A table with one row per coefficient, its row names taken from
CoefficientNames , and the variables Estimate ,
SE , tStat and pValue . tStat is the
estimate divided by its standard error and pValue is the
two-sided t test of a zero coefficient on DFE degrees
of freedom. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Coefficient estimates and their statistics



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
NonLinearModel.DFE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 145
NonLinearModel: property DFE

Error degrees of freedom

A nonnegative integer, NumObservations less
NumCoefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
Error degrees of freedom



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
NonLinearModel.Fitted


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 164
NonLinearModel: property Fitted

Fitted response values

A numeric column vector with one fitted value per observation used for
the fit. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Fitted response values



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
NonLinearModel.Formula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 210
NonLinearModel: property Formula

Model formula

A character vector showing the fitted model, built from the model
function together with the coefficient names and the response name.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
Model formula



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
NonLinearModel.LogLikelihood


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 242
NonLinearModel: property LogLikelihood

Log-likelihood of the fitted model

A scalar, the Gaussian log-likelihood at the estimates, formed with
the maximum-likelihood error variance SSE divided by
NumObservations . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 34
Log-likelihood of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
NonLinearModel.MSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 145
NonLinearModel: property MSE

Mean squared error

A positive scalar holding the estimated variance of the error term.
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
Mean squared error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
NonLinearModel.ModelCriterion


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 244
NonLinearModel: property ModelCriterion

Information criteria

A scalar structure with the fields AIC , AICc ,
BIC and CAIC . All four count the coefficients as the
only parameters; the error variance is not counted. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Information criteria



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
NonLinearModel.NonLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 257
NonLinearModel: mdl = NonLinearModel ( data , resp , modelfun , beta0 )
NonLinearModel: mdl = NonLinearModel (&hellip;, Name , Value )

Fit a nonlinear regression model. Prefer the fitnlm function,
which documents the accepted inputs and Name / Value pairs.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Fit a nonlinear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
NonLinearModel.NumCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 226
NonLinearModel: property NumCoefficients

Number of coefficients

A positive integer counting the coefficients of the model, which is
the number of elements of the starting vector handed to
fitnlm . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Number of coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
NonLinearModel.NumEstimatedCoefficients


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 271
NonLinearModel: property NumEstimatedCoefficients

Number of estimated coefficients

A positive integer counting the coefficients estimated from the data.
A nonlinear fit estimates every coefficient it carries, so this equals
NumCoefficients . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
Number of estimated coefficients



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
NonLinearModel.NumObservations


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 246
NonLinearModel: property NumObservations

Number of observations

A positive integer counting the observations used for the fit, after
the rows named by 'Exclude' and the rows carrying missing
values have been dropped. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Number of observations



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
NonLinearModel.NumPredictors


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 204
NonLinearModel: property NumPredictors

Number of predictors

A positive integer counting the predictor variables, that is the
columns of the predictor matrix used for the fit. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Number of predictors



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
NonLinearModel.PredictorNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 282
NonLinearModel: property PredictorNames

Names of the predictor variables

A cell array of character vectors with one name per predictor. The
names default to 'x1' , 'x2' and so on for a fit from
matrices, and are the column names for a fit from a table. This
property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32
Names of the predictor variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
NonLinearModel.RMSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 127
NonLinearModel: property RMSE

Root mean squared error

A positive scalar, the square root of MSE . This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
Root mean squared error



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
NonLinearModel.Residuals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 213
NonLinearModel: property Residuals

Residuals of the fitted model

A table with one row per observation used for the fit and the
variables Raw , Pearson , Standardized and
Studentized . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Residuals of the fitted model



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 27
NonLinearModel.ResponseName


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 243
NonLinearModel: property ResponseName

Name of the response variable

A character vector naming the response. It defaults to 'y'
for a fit from matrices and is the name of the response column for a
fit from a table. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 29
Name of the response variable



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
NonLinearModel.Robust


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 245
NonLinearModel: property Robust

Robust fitting options

Empty when the model was fitted by ordinary least squares. When
fitnlm was given a robust weight function, a scalar structure
whose field RobustWgtFun names it. This property is
read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Robust fitting options



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
NonLinearModel.Rsquared


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 265
NonLinearModel: property Rsquared

Coefficient of determination

A scalar structure with the fields Ordinary and
Adjusted . Ordinary is one less the ratio of
SSE to SST , and Adjusted corrects that ratio
for the error degrees of freedom. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
Coefficient of determination



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
NonLinearModel.SSE


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 171
NonLinearModel: property SSE

Error sum of squares

A nonnegative scalar, the sum of the squared residuals weighted by the
observation weights. This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Error sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
NonLinearModel.SSR


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 207
NonLinearModel: property SSR

Regression sum of squares

A nonnegative scalar, the weighted sum of squared deviations of the
fitted values about the weighted mean of the response. This property
is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Regression sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
NonLinearModel.SST


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 258
NonLinearModel: property SST

Total sum of squares

A nonnegative scalar, the weighted sum of squared deviations of the
response about its weighted mean. Because the model is nonlinear,
SST does not in general equal SSR plus SSE .
This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
Total sum of squares



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
NonLinearModel.VariableNames


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 175
NonLinearModel: property VariableNames

Names of all variables

A cell array of character vectors holding PredictorNames
followed by ResponseName . This property is read-only.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
Names of all variables



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
NonLinearModel.coefCI


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 173
NonLinearModel: ci = coefCI ( mdl )
NonLinearModel: ci = coefCI ( mdl , alpha )

Confidence intervals for the coefficients at level
100 (1 - alpha )% (default alpha = 0.05).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 91
Confidence intervals for the coefficients at level 100 (1 - alpha)% (default alpha = 0.05).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
NonLinearModel.coefTest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 385
NonLinearModel: [ p , F , df ] = coefTest ( mdl )
NonLinearModel: [&hellip;] = coefTest ( mdl , H )

Wald test of a linear hypothesis on the coefficients. With no H it
tests that all coefficients are zero (the model versus the zero model)
and returns the p -value p , the F statistic F ,
and its numerator degrees of freedom df . H is an
r -by- p contrast matrix testing H * beta
= 0 .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 53
Wald test of a linear hypothesis on the coefficients.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
NonLinearModel.feval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 186
NonLinearModel: yhat = feval ( mdl , X )

Evaluate the fitted model at the predictor values X , given either
as a single matrix/table or as separate column arguments (one per
predictor).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 143
Evaluate the fitted model at the predictor values X, given either as a single matrix/table or as separate column arguments (one per predictor).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 30
NonLinearModel.plotDiagnostics


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 190
NonLinearModel: h = plotDiagnostics ( mdl )
NonLinearModel: h = plotDiagnostics ( mdl , plottype )

Plot fit diagnostics. plottype is 'leverage' (default) or
'cookd' (Cook&rsquo;s distance).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
Plot fit diagnostics.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 28
NonLinearModel.plotResiduals


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 200
NonLinearModel: h = plotResiduals ( mdl )
NonLinearModel: h = plotResiduals ( mdl , plottype )

Plot the model residuals. plottype is 'histogram'
(default),
'fitted' , 'caseorder' , or 'probability' .


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Plot the model residuals.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
NonLinearModel.plotSlice


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 152
NonLinearModel: h = plotSlice ( mdl )

Plot the fitted response as each predictor is varied over its observed
range with the others held at their means.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 113
Plot the fitted response as each predictor is varied over its observed range with the others held at their means.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
NonLinearModel.predict


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 445
NonLinearModel: yhat = predict ( mdl , Xnew )
NonLinearModel: [ yhat , yci ] = predict ( mdl , Xnew )
NonLinearModel: [&hellip;] = predict (&hellip;, Name , Value )

Predict responses of the nonlinear model mdl at the new predictor
values Xnew (a numeric matrix or a table). With two outputs it
also returns the confidence intervals yci . Accepts 'Alpha'
(default 0.05), 'Prediction' ( 'curve' or
'observation' ), and 'Simultaneous' (a logical).


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 108
Predict responses of the nonlinear model mdl at the new predictor values Xnew (a numeric matrix or a table).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
NonLinearModel.random


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 201
NonLinearModel: ysim = random ( mdl , Xnew )

Simulate responses from the fitted model at Xnew (default: the
training predictors), adding Gaussian noise with the model&rsquo;s error
standard deviation.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 149
Simulate responses from the fitted model at Xnew (default: the training predictors), adding Gaussian noise with the model's error standard deviation.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
coxphfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5779
statistics: b = coxphfit ( X , T )
statistics: b = coxphfit ( X , T , name , value , &hellip;)
statistics: [ b , logl ] = coxphfit (&hellip;)
statistics: [ b , logl , H ] = coxphfit (&hellip;)
statistics: [ b , logl , H , stats ] = coxphfit (&hellip;)

Fit a Cox proportional hazards regression model.

b = coxphfit ( X , T ) returns the p -by-1 vector
of coefficients b of the Cox model

$$ h(x_i, t) = h_0(t)\exp\left(\sum_{j=1}^{p} x_{ij} b_j\right) $$

fitted to the n -by- p matrix of predictors X and the
n -by-1 vector of event times T . T may instead be an
n -by-2 matrix whose rows give a (start, stop] interval of
exposure, the counting process form, in which an observation joins the risk
set only after its start time. h_0(t) is the baseline
hazard, which is left unspecified: the coefficients are estimated by
maximizing the Cox partial likelihood, which does not involve it.

X must not contain a column of ones. The model has no
constant term, since any constant is absorbed into the baseline hazard. A
constant column is detected, reported by a warning, and given a zero
coefficient.

Rows of X , T or "Frequency" holding NaN are
removed before fitting.

[ b , logl , H , stats ] = coxphfit (&hellip;)
additionally returns the maximized partial log-likelihood logl , the
estimated baseline cumulative hazard H , and a structure stats of
coefficient statistics and residuals.

H is a two-column matrix whose first column holds the distinct event
times and whose second holds the estimated cumulative hazard at those times,
evaluated at the predictor values given by "Baseline" . Its first
row is the first event time with a cumulative hazard of zero; an observation
censored before any event contributes no row. In a stratified model
H gains a third column carrying the stratum, the blocks appear in
ascending stratum order, and each block leads with its own zero row at its
own first event time. A stratum holding no event contributes a single row
of NaN with its label.

The following name / value pairs are accepted:

Name Value
"Baseline" The X values at which the baseline
hazard is computed, either a scalar or a 1-by- p vector. The default
is the mean of X weighted by "Frequency" and taken within each
stratum, so the hazard is that of an average observation of its stratum;
pass 0 for a hazard relative to the origin. A value given
explicitly is used for every stratum. The coefficients do not depend on
this choice, only H does.
"Censoring" A logical or 0/1 vector of length n ,
where 1 marks an observation right-censored at its recorded time. The
default is a vector of zeros, so every observation is a recorded event.
"Frequency" A vector of length n of non-negative
values giving the number of observations each row represents, or a weight.
The default is a vector of ones.
"Ties" The method of handling tied event times, either
"breslow" (default) or "efron" .
"B0" The starting value of the iteration, a vector of
length p . The default is 0.01 ./ std ( X ) .
"Options" A structure of iteration settings, as built by
statset ("coxphfit") . The fields used are "MaxIter" ,
"TolX" and "Display" .
"Strata" A vector of length n of stratum labels.
Each stratum carries its own baseline hazard and its own risk sets, while
the coefficients are shared across all of them. A predictor that does not
vary within any stratum cannot be estimated from a stratified fit; it is
reported by a warning and held at zero.

The fields of stats are:

Field Contents
"covb" The estimated covariance matrix of b .
"beta" The coefficients, as returned in b .
"se" The standard errors of the coefficients.
"z" The z statistics, b over its standard
error.
"p" The two-sided p -values of the z
statistics.
"csres" The Cox-Snell residuals.
"devres" The deviance residuals.
"martres" The martingale residuals.
"schres" The Schoenfeld residuals, NaN for a
censored observation. The mean an event is measured against follows
"Ties" : under "efron" a tied death is measured against the
mean over the sub-risk sets that approximation splits the tie into, so that
every tied death at one time shares one mean and the residual does not
depend on the order the tie was recorded in. Without a tie the two methods
agree.
"sschres" The scaled Schoenfeld residuals.
"scores" The score residuals.
"sscores" The scaled score residuals.
"LikelihoodRatioTestP" The p -value of the
likelihood ratio test against the model with no predictors.

Two documented deviations, both where R2024a disagrees with
itself. The martingale residual is defined as the event indicator minus
the cumulative hazard the observation actually experienced, so
"csres" and "martres" must sum to that indicator. They do
here, always.

Under "efron" ties MATLAB&rsquo;s do not: its "martres" comes from
a cumulative hazard agreeing neither with its own "csres" nor with
the H it returns, and the two sum to 1.0437 and -0.0414 where
they must give 1 and 0.

In the counting process form MATLAB&rsquo;s "martres" correctly subtracts
the hazard accrued before the observation entered, but its "csres"
does not, so the two disagree by exactly that amount for any row whose start
time follows an event. Here both account for it, so "csres"
differs from MATLAB&rsquo;s by \Lambda(start) \exp (x'b) and the identity
is preserved.

The score residuals inherit the first of those two deviations, being an
integral against the martingale residual: under "efron" ties they
differ from MATLAB&rsquo;s, whose own do not sum to the score at the maximum,
while these sum to zero under both tie methods, weighted by
"Frequency" where one is given.

Every other output agrees with R2024a to machine precision, across
censoring, weights, both tie methods, stratification, and the counting
process form.

See also:
statset,
ecdf,
fitlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
Fit a Cox proportional hazards regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
fitcox


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3126
statistics: mdl = fitcox ( X , T )
statistics: mdl = fitcox ( tbl , respvar )
statistics: mdl = fitcox (&hellip;, Name , Value )

Fit a Cox proportional hazards regression model.

mdl = fitcox ( X , T ) fits the Cox proportional
hazards model

$$ h(x_i, t) = h_0(t)\exp\left(\sum_{j=1}^{p} x_{ij} b_j\right) $$

to the n -by- p numeric matrix of predictors X and the
n -by-1 vector of event times T , and returns a CoxModel
object. T may instead be an n -by-2 matrix whose rows give a
(start, stop] interval of exposure, the counting process form, in
which an observation joins the risk set only after its start time.

h_0(t) is the baseline hazard, which is left unspecified: the
coefficients are estimated by maximizing the Cox partial likelihood, which
does not involve it. X must not contain a column of ones ,
the model having no constant term, since any constant is absorbed into that
baseline.

mdl = fitcox ( tbl , respvar ) takes the data from the
table tbl , using the variable named respvar as the response and
every other variable as a predictor. A categorical variable is
encoded as indicator columns, one per level bar the first, which the baseline
hazard carries.

The following Name / Value pairs are accepted:

Name Value
"Baseline" The X values at which the baseline hazard
is computed, either a scalar or a 1-by- p vector. The default is the
mean of each numeric predictor and zero for each indicator column of a
categorical predictor, taken within each stratum. Pass 0 for a
hazard relative to the origin. The coefficients do not depend on this
choice.
"Beta" The starting value of the iteration, a vector of
length p . The default is 0.01 ./ std ( X ) .
"CategoricalPredictors" The predictors to treat as
categorical, given as column indices, a logical vector, or a cell array of
predictor names. Table variables of class categorical are detected
without this argument.
"Censoring" A logical or 0/1 vector of length n ,
where 1 marks an observation right-censored at its recorded time. The
default is a vector of zeros, so every observation is a recorded event.
"Frequency" A vector of length n of non-negative
values giving the number of observations each row represents, or a weight.
The default is a vector of ones.
"OptimizationOptions" A structure of iteration settings,
as built by statset ("fitcox") . The fields used are
"MaxIter" , "TolX" and "Display" .
"PredictorNames" A cell array of p predictor names.
The default is "X1" , "X2" , and so on, or the table variable
names.
"Stratification" A vector of length n of stratum
labels. Each stratum carries its own baseline hazard and its own risk sets,
while the coefficients are shared across all of them.
"TieBreakMethod" The method of handling tied event times,
either "breslow" (default) or "efron" .

fitcox is the object interface to coxphfit , which fits the same
model and returns the estimates as plain arrays. The two agree exactly; the
object additionally reports the proportional hazards assumption tests and
carries the survival , hazardratio , coefci ,
linhyptest and plotSurvival methods.

See also:
CoxModel,
coxphfit,
ecdf,
statset


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 48
Fit a Cox proportional hazards regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
fitglm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3540
statistics: mdl = fitglm ( X , y )
statistics: mdl = fitglm ( X , y , modelspec )
statistics: mdl = fitglm ( tbl )
statistics: mdl = fitglm ( tbl , modelspec )
statistics: mdl = fitglm (&hellip;, Name , Value )

Fit a generalized linear regression model.

mdl = fitglm ( X , y ) fits a generalized linear model
of the response vector y on the columns of the n -by- p
numeric predictor matrix X , and returns a GeneralizedLinearModel
object. mdl = fitglm ( tbl ) instead takes the predictors
and response from the table tbl (the last column is the response unless
overridden). By default the response is 'normal' with an identity
link, an intercept is included, and the model is additive in the predictors.

For the 'binomial' distribution y holds the number of
successes , and the number of trials is given either by the
'BinomialSize' pair or by passing y as an
n -by- 2 matrix whose first column holds the successes and
whose second holds the trials. The two forms describe the same model; when
both are given, the trials supplied with the response are used. A trial
count must be a positive integer, while a success count need not be whole.

modelspec selects the model terms. It is either a Wilkinson formula
string (e.g. 'y ~ x1 + x2*x3' ), a keyword ( 'constant' ,
'linear' , 'interactions' , 'purequadratic' ,
'quadratic' , or 'full' ), or a terms matrix.

The following Name / Value pairs are accepted:

Name Value
'Distribution' the response distribution:
'normal' (default), 'binomial' , 'poisson' ,
'gamma' , or 'inverse gaussian' .
'Link' the link function. Defaults to the canonical link
of the distribution; accepts any link name understood by glmfit or a
numeric exponent for a power link.
'Weights' a vector of nonnegative observation weights.
'Offset' a vector added as a fixed term to the linear
predictor.
'BinomialSize' for the 'binomial' distribution,
the number of trials (a scalar or a per-observation vector); y holds
the number of successes. Changed in 1.9.0 : y was previously
read as the proportion of successes. Multiply an existing proportion by
the trials to keep its meaning.
'Intercept' a logical value (default true ) whether
to include an intercept term.
'DispersionFlag' a logical value forcing the dispersion
parameter to be estimated ( true ) or held at 1 ( false ).
'CategoricalVars' predictors to treat as categorical (a
logical vector, numeric indices, or a cell array of names).
'Exclude' observations to exclude from the fit (a logical
vector or numeric indices).
'VarNames' a cell array of p + 1 variable names
(predictors followed by the response) for numeric X .
'PredictorVars' , 'ResponseVar' for table input,
the predictor and response variable names.

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 &ndash; 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 R^2 . This
implementation returns three coefficients, one per group.

See also:
GeneralizedLinearModel,
fitlm,
glmfit,
glmval,
lassoglm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
Fit a generalized linear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
fitglme


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1242
statistics: glme = fitglme ( tbl , formula )
statistics: glme = fitglme (&hellip;, 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"
The response distribution: "normal" (default), "binomial" , or
"poisson" .
"Link"
The link function: "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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
Fit a generalized linear mixed-effects model specified by a formula.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
fitlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9616
statistics: mdl = fitlm ( X , y )
statistics: mdl = fitlm ( tbl )
statistics: mdl = fitlm ( tbl , ResponseVarName )
statistics: mdl = fitlm ( tbl , y )
statistics: mdl = fitlm (&hellip;, modelspec )
statistics: mdl = fitlm (&hellip;, Name , Value , &hellip;)

Fit a linear regression model to data and return a LinearModel
object.

The returned object stores the fitted coefficients, their standard errors,
t-statistics, and p-values, summary statistics of the fit ( R^2 ,
RMSE, F-statistic, etc.), and the residuals and diagnostics of the fit, and
exposes methods such as predict , plotResiduals ,
coefTest , addTerms , and removeTerms for further
analysis of the fitted model.

Basic Syntax

mdl = fitlm ( X , y ) fits a linear regression model
of the response y to the predictor data X . Unless removed via
the 'Intercept' option, the fitted model contains a constant
(intercept) term and one linear term for every column of X .

X is an N&times;P numeric or logical matrix of predictor data, where
rows correspond to observations and columns correspond to variables. By
default, the predictors are named 'x1' , 'x2' , &hellip;,
'xP' .

X can also be a categorical vector of length N , representing a
single categorical predictor. In this case y must be supplied as the
next argument, and the predictor is named 'x1' by default.

y is an N&times;1 numeric or logical vector of response values, and
must have the same number of observations (rows) as X . By default,
the response is named 'y' .

mdl = fitlm ( tbl ) fits a linear regression model using
the variables contained in the table (or dataset) tbl . By default,
the last variable in tbl is used as the response and all other
variables are used as predictors. Variables that are categorical
arrays, cell arrays of character vectors, or logical arrays are
automatically treated as categorical predictors.

mdl = fitlm ( tbl , ResponseVarName ) fits a model
using the variable named ResponseVarName in tbl as the
response, and all remaining variables in tbl as predictors.

mdl = fitlm ( tbl , y ) fits a model using the
variables in tbl as predictors and the external numeric vector
y as the response. y must have height ( tbl )
elements.

Model Specification

mdl = fitlm (&hellip;, modelspec ) additionally specifies
the terms of the model to fit, using any of the input combinations shown
above. modelspec can be any of the following.

Value Description
'constant' Model contains only an intercept term.
'linear' Model contains an intercept and one term
for each predictor variable. This is the default when modelspec is
not specified.
'interactions' Model contains an intercept, all
linear terms, and all pairwise products of distinct predictor variables
(no squared terms).
'purequadratic' Model contains an intercept, all
linear terms, and all squared terms.
'quadratic' Model contains an intercept, all linear
terms, all pairwise products of distinct predictor variables, and all
squared terms.
'full' Model contains an intercept and all terms up
to and including the full P -way interaction of the predictor
variables, i.e. every combination of one or more distinct predictors.
terms matrix A T&times;P or T&times;(P+1) numeric matrix,
where T is the number of terms and P is the number of
predictor variables. Each row represents one term, and the value in
column j is the exponent to which predictor j is raised in
that term; a row of all zeros represents the intercept. If a
T&times;(P+1) matrix is supplied, its last column (representing the
response variable) must be all zeros.
Wilkinson formula A character vector of the form
'y ~ terms' describing the response and predictor terms using
Wilkinson notation. The variable name to the left of '~' is used
as the response, overriding any response implied elsewhere in the call.

When modelspec is given as a Wilkinson formula, the following
operators may be used on its right-hand side to build up terms :

Operator Meaning Example
+ add a term 'x1 + x2' adds x1 and
x2 as separate terms
- remove a term 'x1*x2 - x1:x2' removes the
interaction, leaving only x1 and x2
* cross two terms 'x1*x2' expands to
x1 , x2 , x1:x2
: interaction only 'x1:x2' adds only the
interaction term between x1 and x2
^ power / crossing limit 'x^2' adds
x and x^2 ; '(x1+x2)^2' expands to x1 ,
x2 , x1:x2
-1 remove intercept 'x1 + x2 - 1' fits the
model without a constant term

A formula includes an intercept term by default; append '- 1' to
the formula to omit it. For a categorical predictor, fitlm
generates the necessary indicator (dummy) variables automatically from the
formula, so a formula does not need to be changed when the underlying
design matrix changes.

Options

mdl = fitlm (&hellip;, Name , Value , &hellip;)
specifies additional options using one or more Name-Value pair
arguments, which may be combined with modelspec or used on their own.

Name Value
'Intercept' A logical scalar indicating whether to
include a constant (intercept) term in the model. Default is true .
This option only applies when modelspec is a character vector model
name (or omitted); it is ignored when modelspec is a terms matrix or
a Wilkinson formula, where the intercept is instead controlled by the
matrix/formula itself.
'Weights' A numeric vector of nonnegative
observation weights, with one element per observation, used to fit a
weighted least squares model. Default is a vector of ones, i.e. an
unweighted ordinary least squares fit.
'Exclude' A numeric or logical vector specifying
observations to exclude from the fit, given as row indices into the
original data or as a logical mask the same length as the number of
observations. Excluded observations, together with any observation that
contains a missing ( NaN ) value in a predictor or the response, are
recorded in the ObservationInfo property of the fitted model but do
not contribute to the fitted coefficients or summary statistics.
'CategoricalVars' Specifies which predictor
variables are treated as categorical, given as a vector of column indices,
a logical vector, or a cell array of variable names (only valid for table
input). Each categorical predictor with L distinct categories is
expanded into L-1 indicator (dummy) variables, using the first
category (in sorted or original order) as the reference level that is
omitted from the design matrix. Variables that are already
categorical arrays or cell arrays of character vectors are always
treated as categorical, regardless of this option.
'VarNames' A cell array of character vectors
naming the predictor and response variables, listed in order with the
response variable name last, e.g. {"x1", "x2", "y"} for two
predictors. Only applies when X and y (or a categorical
vector and y ) are supplied directly, since table variables already
carry their own names. By default, predictors are named 'x1' ,
'x2' , etc. and the response is named 'y' .
'ResponseVar' A character vector naming the
response variable, used to override the response variable name that would
otherwise be inferred (the last table variable, or 'y' for matrix
input).
'PredictorVars' A cell array of character vectors
naming which variables in tbl to use as predictors. By default, all
variables in tbl other than the response variable are used as
predictors.
'RobustOpts' Selects ordinary least squares or
robust regression fitting. This value can be 'off' (default,
ordinary least squares), 'on' (robust fitting using the
'bisquare' weighting function), the name of one of the weighting
functions below, a function handle for a custom weighting function, or a
scalar structure with fields RobustWgtFun and Tune
specifying the weighting function and its tuning constant. Robust fitting
uses Iteratively Reweighted Least Squares (IRLS), refitting the model with
updated observation weights until the coefficients converge. Supported
weighting function names: 'andrews' , 'bisquare' ,
'cauchy' , 'fair' , 'huber' , 'logistic' ,
'ols' , 'talwar' , 'welsch' , each with its own default
tuning constant.

Algorithm

fitlm solves the (weighted) least squares problem by applying a
pivoted QR decomposition to the design matrix, which remains numerically
stable even when predictors are collinear; coefficients corresponding to
columns beyond the numerically detected rank of the design matrix are set
to zero. Robust fits refine this ordinary least squares solution using
IRLS as described above. Observations with missing values in any variable
used by the model, or explicitly excluded via 'Exclude' , are
omitted from the fit entirely and flagged in ObservationInfo , but
are otherwise not counted as errors.

mdl is returned as a LinearModel object. If
'RobustOpts' is anything other than 'off' , the returned
model is a robust fit rather than an ordinary least squares fit, and its
Robust property is populated accordingly.

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 &ndash; 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 R^2 . This
implementation returns three coefficients, one per group.

See also:
LinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
Fit a linear regression model to data and return a LinearModel object.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
fitlme


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1148
statistics: lme = fitlme ( tbl , formula )
statistics: lme = fitlme (&hellip;, name , value )

Fit a linear mixed-effects model specified by a formula.

fitlme ( tbl , formula ) fits the linear mixed-effects model
described by formula to the variables in the table tbl , and
returns a LinearMixedModel object.

formula is a character vector in Wilkinson notation extended with
random-effects terms, for example "y ~ x1 + x2 + (1 | g)" . The part
to the left of ~ names the response; the fixed-effects part uses the
usual operators ( + , * , : , ^ , and -1 to
drop the intercept); and each random-effects term
( expr | group )
adds random intercepts and slopes expr grouped by the factor
group (or an interaction of factors, e.g. g1:g2 ). As with
fixed effects, a random intercept is implicit unless suppressed with
0 or -1 .

Rows of tbl with missing values in any model variable are removed
before fitting.

The following name / value pairs are accepted:

"FitMethod"
The estimation criterion, "ML" (maximum likelihood, the default) or
"REML" (restricted maximum likelihood).

See also:
LinearMixedModel,
fitlmematrix,
fitlm,
parseWilkinsonFormula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 56
Fit a linear mixed-effects model specified by a formula.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
fitlmematrix


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1877
statistics: lme = fitlmematrix ( X , y , Z , G )
statistics: lme = fitlmematrix (&hellip;, name , value )

Fit a linear mixed-effects model from design matrices.

fitlmematrix ( X , y , Z , G ) fits the linear
mixed-effects model
$$ y = X\beta + Zb + \varepsilon $$
with fixed-effects design X , response y , random-effects design
Z , and grouping variable G . The random effects b are
normally distributed with mean zero and an unstructured covariance Psi
(shared across the levels of the grouping variable), and the observation
errors are independent N(0, sigma2) .

X is an n -by- p numeric matrix and y an n -by-1
response vector. Z is an n -by- q random-effects design and
G an n -by-1 grouping variable (numeric, logical, char, cell array
of strings, or categorical). To specify several grouping terms, pass Z
and G as cell arrays of the same length, one design and one grouping
variable per term.

The following name / value pairs are accepted:

"FitMethod"
The estimation criterion, either "ML" (maximum likelihood, the
default) or "REML" (restricted maximum likelihood).
"FixedEffectPredictors"
A cell array of p names for the columns of X (default
{"x1", &hellip;, "xp"} ).
"RandomEffectPredictors"
A cell array (one entry per grouping term) of cell arrays naming the columns
of each Z (default z1, z2, &hellip; ).
"RandomEffectGroups"
A cell array of names for the grouping terms (default g1, g2 , etc.).

The returned lme is a LinearMixedModel object describing the
fitted model: the estimated fixed effects and their statistics
( lme.Coefficients ), the covariance parameters
( covarianceParameters ), the random-effects BLUPs ( randomEffects ),
the log-likelihood, and methods for prediction, residuals, and hypothesis
tests.

Only the full (unstructured) random-effects covariance is currently
supported.

See also:
LinearMixedModel,
fitlm,
parseWilkinsonFormula


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 54
Fit a linear mixed-effects model from design matrices.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
fitnlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1509
statistics: mdl = fitnlm ( X , y , modelfun , beta0 )
statistics: mdl = fitnlm ( tbl , modelfun , beta0 )
statistics: mdl = fitnlm (&hellip;, Name , Value )

Fit a nonlinear regression model.

mdl = fitnlm ( X , y , modelfun , beta0 )
fits the nonlinear regression model y = modelfun
( beta , X ) to the response vector y and the
n -by- p predictor matrix X , starting the iterative fit
from the coefficient vector
beta0 , and returns a NonLinearModel object. modelfun is a
function handle @( b , X ) returning the fitted responses.

mdl = fitnlm ( tbl , modelfun , beta0 ) takes the
predictors and response from the table tbl ; the last column is the
response unless overridden by 'ResponseVar' .

The following Name / Value pairs are accepted:

Name Value
'CoefficientNames' a cell array of names for the
coefficients (default 'b1' , 'b2' , &hellip;).
'Weights' a vector of nonnegative observation weights.
'ErrorModel' the error-variance model: 'constant'
(default), 'proportional' , or 'combined' .
'RobustWgtFun' the name of a robust weight function,
enabling robust fitting (see nlinfit ).
'Options' a statset-style options structure controlling
the iterative fit ( MaxIter , TolFun , TolX ).
'PredictorVars' , 'ResponseVar' for table input,
the predictor and response variable names.
'VarNames' a cell array of p + 1 variable names
(predictors followed by the response) for numeric X .
'Exclude' observations to exclude from the fit.

See also:
NonLinearModel,
nlinfit,
nlparci,
nlpredci,
fitlm,
fitglm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Fit a nonlinear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
glmfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4208
statistics: b = glmfit ( X , y , distribution )
statistics: b = glmfit ( X , y , distribution , Name , Value )
statistics: [ b , dev ] = glmfit (&hellip;)
statistics: [ b , dev , stats ] = glmfit (&hellip;)

Perform generalized linear model fitting.

b = glmfit ( X , y , distribution ) returns a
vector b of coefficient estimates for a generalized linear regression
model of the responses in y on the predictors in X , using the
distribution defined in distribution .

X is an n&times;p numeric matrix of predictor variables with
n observations and p predictors.
y is an n&times;1 numeric vector of responses for all supported
distributions, except for the &rsquo;binomial&rsquo; distribution in which case y
can be either a numeric or logical n&times;1 vector or an n&times;2
matrix, where the first column contains the number of successes and the
second column contains the number of trials.
distribution is a character vector specifying the distribution of
the response variable. Supported distributions are 'normal' ,
'binomial' , 'poisson' , 'gamma' , and 'inverse
gaussian' .

b = glmfit (&hellip;, Name , Value ) specifies
additional options using Name-Value pair arguments.

Name Value
'B0' A numeric vector specifying initial values for
the coefficient estimates. By default, the initial values are fitted values
fitted from the data.
'Constant' A character vector specifying whether to
include a constant term in the model. Valid options are "on" (default)
and "off" .
'EstDisp' A character vector specifying whether to
compute dispersion parameter. Valid options are "on" and "off" .
For 'binomial' and 'poisson' distributions the default is
"off" , whereas for the 'normal' , 'gamma' , and
'inverse gaussian' distributions the default is "on" .
'link' A character vector specifying the name of a
canonical link function or a numeric scalar for specifying a 'power'
link function. Supported canonical link functions include 'identity'
(default for 'normal' distribution), 'log' (default for
'poisson' distribution), 'logit' (default for
'binomial' distribution), 'probit' , 'loglog' ,
'comploglog' , and 'reciprocal' (default for the
'gamma' distribution). The 'power' link function is the
default for the 'inverse gaussian' distribution with p = -2 .
For custom link functions, the user can provide cell array with three
function handles: the link function, its derivative, and its inverse, or
alternatively a structure S with three fields: S.Link ,
S.Derivative , and S.Inverse . Each field can either contain a
function handle or a character vector with the name of an existing function.
All custom link functions must accept a vector of inputs and return a vector
of the same size.
'Offset' A numeric vector of the same length as the
response y specifying an offset variable in the fit. It is used as an
additional predictor with a coefficient value fixed at 1.
'Options' A scalar structure containing the fields
MaxIter and TolX . MaxIter must be a scalar positive
integer specifying the maximum number of iteration allowed for fitting the
model, and TolX must be a positive scalar value specifying the
termination tolerance.
'Weights' An n&times;1 numeric vector of nonnegative
values, where n is the number of observations in X . By default,
it is ones (n, 1) .

[ b , dev ] = glmfit (&hellip;) also returns the deviance of
the fit as a numeric value in dev . Deviance is a generalization of the
residual sum of squares. It measures the goodness of fit compared to a
saturated model.

[ b , dev , stats ] = glmfit (&hellip;) also returns the
structure stats , which contains the model statistics in the following
fields:

beta - Coefficient estimates b
dfe - Degrees of freedom for error
sfit - Estimated dispersion parameter
s - Theoretical or estimated dispersion parameter
estdisp - false when 'EstDisp' is 'off'
and true when 'EstDisp' is 'on'
covb - Estimated covariance matrix for b
se - Vector of standard errors of the coefficient estimates
b
coeffcorr - Correlation matrix for b
t - t statistics for b
p - p -values for b
resid - Vector of residuals
residp - Vector of Pearson residuals
residd - Vector of deviance residuals
resida - Vector of Anscombe residuals

See also:
glmval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
Perform generalized linear model fitting.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
glmval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1745
statistics: yhat = glmval ( b , X , link )
statistics: [ yhat , y_lo , y_hi ] = glmval ( b , X , link , stats )
statistics: [&hellip;] = glmval (&hellip;, Name , Value )

Predict values for a generalized linear model.

yhat = glmval ( b , X , link ) returns the
predicted values for the generalized linear model with a vector of
coefficient estimates b , a matrix of predictors X , in which each
column corresponds to a distinct predictor variable, and a link function
link , which can be any of the character vectors, numeric scalar, or
custom-defined link functions used as values for the 'link'
name-value pair argument in the glmfit function.

[ yhat , y_lo , y_hi ] = glmval ( b , X ,
link , stats ) also returns the 95% confidence intervals for the
predicted values according to the model&rsquo;s statistics contained in the
stats structure, which is the output of the glmfit function.
By default, the confidence intervals are nonsimultaneous, and apply to the
fitted curve instead of new observations.

[&hellip;] = glmval (&hellip;, Name , Value ) specifies
additional options using Name-Value pair arguments.

Name Value
'confidence' A scalar value between 0 and 1
specifying the confidence level for the confidence bounds.
'Constant' A character vector specifying whether to
include a constant term in the model. Valid options are "on" (default)
and "off" .
'simultaneous' A logical or numeric ( 0 or
1 ) scalar specifying whether the confidence bounds are simultaneous.
The default is false , which yields nonsimultaneous (pointwise) bounds.
'size' A numeric scalar or a vector with one value
for each row of X specifying the size parameter N for a binomial
model. 'BinomialSize' is accepted as an alias for 'size' .

See also:
glmfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
Predict values for a generalized linear model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
invpred


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1641
statistics: x0 = invpred ( x , y , y0 )
statistics: [ x0 , dxlo , dxup ] = invpred ( x , y , y0 )
statistics: [&hellip;] = invpred (&hellip;, name , value )

Inverse prediction from a simple linear regression.

x0 = invpred ( x , y , y0 ) fits the simple
linear regression of y on x and returns, for each element of
y0 , the value of the predictor at which the fitted line takes that
response. x and y must be vectors of real values of the same
length; y0 may be of any size and x0 is returned with the same
size. Observations where either x or y is NaN are
dropped in pairs before the fit.

[ x0 , dxlo , dxup ] = invpred (&hellip;) also returns
the width of a confidence interval on either side of x0 , so that the
interval is [ x0 - dxlo , x0 + dxup ] . The
bounds follow Fieller&rsquo;s theorem and are therefore not symmetric about
x0 . They are not simultaneous over the elements of y0 , and
they need not be finite: when the slope is not significantly different from
zero at the requested level the interval is unbounded, and dxlo and
dxup are both Inf .

[&hellip;] = invpred (&hellip;, name , value ) accepts the
following name-value pairs:

"alpha" is the significance level of the interval, a scalar
strictly between 0 and 1, so that the interval has confidence
100 &times; (1 - alpha )% . The default is 0.05 .

"predopt" selects what the interval covers. With
"observation" , the default, it covers a new observation whose
response is y0 . With "curve" , it covers the point at which
the true regression line takes the value y0 , and is narrower because
it carries no new-observation variance.

See also:
regress,
fitlm,
polyfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 51
Inverse prediction from a simple linear regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
lasso


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2546
statistics: B = lasso ( X , y )
statistics: [ B , FitInfo ] = lasso ( X , y )
statistics: [&hellip;] = lasso (&hellip;, Name , Value )

Lasso and elastic-net regularized least-squares regression.

B = lasso ( X , y ) fits a series of regularized linear
models of the response y on the predictor matrix X by lasso, over
a sequence of values of the regularization parameter Lambda . B
is a P&times;L matrix whose column k holds the coefficient estimates
for the k -th Lambda , in ascending order of Lambda .

[ B , FitInfo ] = lasso (&hellip;) additionally returns a
structure FitInfo with fields Intercept , Lambda ,
Alpha , DF (number of non-zero coefficients), and MSE
(mean squared error), one entry per value of Lambda .

The following Name-Value pairs are supported:

Name Value
'Alpha' The elastic-net mixing parameter in
(0, 1] . 1 (default) is the lasso penalty; smaller values add a
ridge penalty.
'Lambda' A vector of non-negative regularization
parameters. By default a geometric sequence of 'NumLambda' values is
used, from the smallest value that drives all coefficients to zero down to
'LambdaRatio' times that value.
'NumLambda' The number of Lambda values in the
default sequence (default 100 ).
'LambdaRatio' The ratio of the smallest to the largest
Lambda in the default sequence (default 1e-4 , or 1e-2
when the number of observations is below the number of predictors).
'Standardize' Whether to standardize X to zero mean
and unit variance before fitting (default true ). Coefficients are
always returned on the original scale.
'Weights' A vector of non-negative observation weights.
'RelTol' Convergence tolerance for the coordinate descent
(default 1e-4 ).
'MaxIter' Maximum number of coordinate-descent iterations
(default 1e5 ).
'DFmax' The maximum number of non-zero coefficients; the
default sequence stops once this is exceeded.
'Intercept' Whether to fit a constant term (default
true ).
'PredictorNames' A cell array of predictor names, kept in
FitInfo .
'CV' The number of folds K for K -fold
cross-validation of the mean squared error, or a cvpartition object.
'MCReps' The number of Monte-Carlo repetitions of the
cross-validation (default 1 ).

When 'CV' is used, FitInfo .MSE is the cross-validated
error, plus SE , LambdaMinMSE , IndexMinMSE ,
Lambda1SE , and Index1SE , which report the Lambda with the
lowest error and the largest Lambda within one standard error of it.
The fold assignment is random, so these selections are not reproducible
without fixing the random seed.

See also:
ridge,
regress,
lassoglm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
Lasso and elastic-net regularized least-squares regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
lassoglm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3315
statistics: B = lassoglm ( X , y )
statistics: B = lassoglm ( X , y , distr )
statistics: B = lassoglm ( X , y , distr , Name , Value )
statistics: [ B , FitInfo ] = lassoglm (&hellip;)

Lasso and elastic-net regularized generalized linear model regression.

B = lassoglm ( X , y , distr ) returns fitted
least-squares regression coefficients for a generalized linear model of the
response y on the predictor data X , penalized by the lasso (L1)
or elastic-net penalty. X is an n -by- p numeric matrix of
p predictors at each of n observations, and y is a
numeric vector of n responses. distr names the distribution of
the response: 'normal' (default), 'binomial' ,
'poisson' , 'gamma' , or 'inverse gaussian' . The
canonical link function of the chosen distribution is used unless overridden
by the 'Link' option.

B is a p -by- L matrix, where L is the number of
regularization ( 'Lambda' ) values used; column k holds the
coefficients for the k -th value of lambda , in order of
ascending lambda .

[ B , FitInfo ] = lassoglm (&hellip;) also returns a structure
FitInfo with information about the fitted models:

Intercept a 1 -by- L vector of intercept terms
Lambda the 1 -by- L vector of lambda
values, in ascending order
Alpha the elastic-net mixing value used
DF the number of nonzero coefficients in each column of
B
Deviance the deviance of the fitted model at each
lambda ; when cross-validation is requested this is instead the
cross-validated mean deviance

When cross-validation is requested (see 'CV' below), FitInfo
additionally contains SE (standard error of the cross-validated
deviance), LambdaMinDeviance and IndexMinDeviance (the
lambda with minimum cross-validated deviance and its index), and
Lambda1SE and Index1SE (the largest lambda within one
standard error of that minimum).

lassoglm accepts the following Name / Value pairs:

Name Value
'Alpha' the elastic-net mixing parameter, a scalar in
(0, 1] . 'Alpha' = 1 is the lasso penalty (default);
values towards 0 approach ridge regression.
'Lambda' a vector of non-negative lambda values.
'Standardize' a logical value (default true )
specifying whether the predictors are standardized before fitting.
'Weights' a vector of non-negative observation weights.
'Size' for the 'binomial' distribution, the number
of trials (a scalar or a per-observation vector); y holds the number of
successes. Default is 1 (Bernoulli responses).
'Link' the link function to use instead of the family&rsquo;s
canonical link. Accepts any link name understood by glmfit (e.g.
'log' , 'probit' ) or a numeric exponent for a power link.
'Offset' a numeric vector, one value per observation,
added as a fixed term to the linear predictor (not penalized or fitted).
'RelTol' convergence tolerance for the coordinate descent.
'MaxIter' maximum number of iterations.
'DFmax' maximum number of nonzero coefficients.
'Intercept' a logical value (default true ) whether
to fit an intercept term.
'PredictorNames' a cell array of predictor names.
'CV' the number of folds K for K -fold
cross-validation, or a cvpartition object. The fold assignment is
random, so the selected lambda values are not reproducible without a
fixed random seed.
'MCReps' the number of Monte-Carlo repetitions of the
cross-validation (default 1).

See also:
lasso,
glmfit,
glmval,
cvpartition


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
Lasso and elastic-net regularized generalized linear model regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
logistic_regression


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1982
statistics: [ intercept , slope , dev , dl , d2l , P , stats ] = logistic_regression ( y , x , print , intercept , slope )

Perform ordinal logistic regression.

Suppose y takes values in k ordered categories, and let
P_i ( x ) be the cumulative probability that y
falls in one of the first i categories given the covariate
x . Then

[ intercept , slope ] = logistic_regression ( y , x )

fits the model

logit (P_i ( x )) = x * slope + intercept _i,
i = 1 &hellip; k-1

The number of ordinal categories, k, is taken to be the number
of distinct values of round ( y ) . If k equals 2,
y is binary and the model is ordinary logistic regression. The
matrix x is assumed to have full column rank.

Given y only, intercept = logistic_regression ( y )
fits the model with baseline logit odds only.

The full form is

[ intercept , slope , dev , dl , d2l , P , ...
stats ] = logistic_regression ( y , x , print , ...
intercept , slope )

in which all output arguments and all input arguments except y
are optional.

Setting print to 1 requests summary information about the fitted
model to be displayed. Setting print to 2 requests information
about convergence at each iteration. Other values request no
information to be displayed. The input arguments intercept and
slope give initial estimates for intercept and slope .

The returned value dev holds minus twice the log-likelihood.

The returned values dl and d2l are the vector of first
and the matrix of second derivatives of the log-likelihood with
respect to intercept and slope .

P holds estimates for the conditional distribution of y
given x .

stats returns a structure that contains the following fields:

"intercept": intercept coefficients

"slope": slope coefficients

"coeff": regression coefficients (intercepts and slops)

"covb": estimated covariance matrix for coefficients (coeff)

"coeffcorr": correlation matrix for coeff

"se": standard errors of the coeff

"z": z statistics for coeff

"pval": p-values for coeff


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
Perform ordinal logistic regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
mnrfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2578
statistics: B = mnrfit ( X , Y )
statistics: B = mnrfit ( X , Y , name , value )
statistics: [ B , dev ] = mnrfit (&hellip;)
statistics: [ B , dev , stats ] = mnrfit (&hellip;)

Fit a multinomial logistic regression model.

Nominal models are fitted with a baseline-category multinomial logit, using
the last category of Y as the reference. Ordinal models are fitted
with a cumulative link model and hierarchical models with a sequential
(continuation-ratio) link model, both honouring the 'link' option
below. Nominal models always use the logit link.

B = mnrfit ( X , Y ) returns a matrix, B , of
coefficient estimates for a multinomial logistic regression of the nominal
responses in Y on the predictors in X . X is an N&times;P
numeric matrix the observations on predictor variables, where N
corresponds to the number of observations and P corresponds to
predictor variables. Y contains the response category labels and it
either be an N&times;P categorical or numerical matrix (containing only 1s
and 0s) or an N&times;1 numeric vector with positive integer values, a cell
array of character vectors and a logical vector. Y can also be defined
as a character matrix with each row corresponding to an observation of
X .

B = mnrfit ( X , Y , name , value ) returns a
matrix, B , of coefficient estimates for a multinomial model fit with
additional parameters specified Name-Value pair arguments.

Name Value
'model' The type of model to fit: 'nominal'
(default) for a baseline-category model, 'ordinal' for a cumulative
model, or 'hierarchical' for a sequential (continuation-ratio) model.
'link' The link function for ordinal and hierarchical
models: 'logit' (default), 'probit' , 'comploglog' , or
'loglog' . Nominal models always use the logit link.
'estdisp' 'on' to estimate a dispersion
parameter, scaling the coefficient standard errors by it and testing the
coefficients against the t distribution, or 'off' (default)
for the theoretical dispersion of 1 .
'display' A flag to enable/disable displaying
information about the fitted model. Default is 'off' .

[ B , dev , stats ] = mnrfit (&hellip;) also returns the
deviance of the fit, dev , and a structure stats with the fitted
coefficients 'beta' (same as B ), their standard errors
'se' , covariance matrix 'covb' , correlation matrix
'coeffcorr' , error degrees of freedom 'dfe' , the coefficient
t statistics 't' and p -values 'p' , the
dispersion parameters 's' , 'sfit' , and 'estdisp' , and
the raw, Pearson, and deviance residuals 'resid' , 'residp' ,
and 'residd' .

See also:
mnrval,
logistic_regression


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 44
Fit a multinomial logistic regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 6
mnrval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2736
statistics: pihat = mnrval ( B , X )
statistics: [ pihat , dlo , dhi ] = mnrval ( B , X , stats )
statistics: yhat = mnrval ( B , X , ssize )
statistics: [ yhat , dlo , dhi ] = mnrval ( B , X , ssize , stats )
statistics: [&hellip;] = mnrval (&hellip;, name , value )

Predict values for a multinomial logistic regression model.

pihat = mnrval ( B , X ) returns the predicted
category probabilities pihat of a multinomial logistic regression with
coefficients B , evaluated at the predictor values in X . X
is an N&times;P numeric matrix of N observations on P
predictors. pihat is an N&times;K matrix, where K is the number
of response categories and each row sums to one. B is the coefficient
matrix returned by mnrfit (see below for its shape under each model).

mnrval is the prediction companion of mnrfit . Unlike the
current mnrfit , which only fits ordinal and two-category nominal
models, mnrval evaluates all three model types, so a coefficient
matrix B obtained elsewhere (e.g. MATLAB) can be used for prediction.

yhat = mnrval ( B , X , ssize ) returns predicted
category counts instead of probabilities, for the sample sizes in ssize
(a scalar or an N&times;1 vector).

[ pihat , dlo , dhi ] = mnrval ( B , X ,
stats ) also returns 95% confidence bounds on the predictions.
stats is the structure returned by mnrfit ; its 'covb'
field (the coefficient covariance matrix) is required. The confidence
interval for each prediction is [ pihat - dlo , pihat +
dhi ] . The bounds are nonsimultaneous and apply to the fitted values,
not to new observations.

The following Name-Value pairs control the model:

Name Value
'model' The model type: 'nominal' (default),
'ordinal' , or 'hierarchical' .
'interactions' 'on' to include category-specific
coefficients, or 'off' for a common set of coefficients with
category-specific intercepts only. Default is 'on' for nominal and
hierarchical models and 'off' for ordinal models. With
'interactions','on' , B is a (P+1)&times;(K-1) matrix. With
'interactions','off' , B is a (K-1+P)&times;1 vector holding the
K-1 intercepts followed by the P common slopes.
'link' The link function for ordinal and hierarchical
models: 'logit' (default), 'probit' , 'comploglog' , or
'loglog' . Nominal models always use the multinomial logit link.
'type' The kind of probability returned:
'category' (default, N&times;K category probabilities),
'cumulative' ( N&times;(K-1) cumulative probabilities of the first
K-1 categories), or 'conditional' ( N&times;(K-1) conditional
probabilities of each category given membership in that or a later category).
'confidence' The confidence level for dlo and
dhi , a scalar in the range (0,1) . Default is 0.95 .

See also:
mnrfit,
glmval,
logistic_regression


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
Predict values for a multinomial logistic regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
monotone_smooth


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1467
statistics: yy = monotone_smooth ( x , y , h )

Produce a smooth monotone increasing approximation to a sampled functional
dependence.

A kernel method is used (an Epanechnikov smoothing kernel is applied to y(x);
this is integrated to yield the monotone increasing form. See Reference 1
for details.)

Arguments

x is a vector of values of the independent variable.

y is a vector of values of the dependent variable, of the same size as
x . For best performance, it is recommended that the y already be
fairly smooth, e.g. by applying a kernel smoothing to the original values if
they are noisy.

h is the kernel bandwidth to use. If h is not given,
a "reasonable" value is computed.

Return values

yy is the vector of smooth monotone increasing function values at
x .

Examples

x = 0:0.1:10;
y = (x .^ 2) + 3 * randn(size(x)); # typically non-monotonic from the added
noise
ys = ([y(1) y(1:(end-1))] + y + [y(2:end) y(end)])/3; # crudely smoothed via
moving average, but still typically non-monotonic
yy = monotone_smooth(x, ys); # yy is monotone increasing in x
plot(x, y, '+', x, ys, x, yy)

References

Holger Dette, Natalie Neumeyer and Kay F. Pilz (2006), A simple nonparametric
estimator of a strictly monotone regression function, Bernoulli ,
12:469-490

Regine Scheder (2007), R Package &rsquo;monoProc&rsquo;, Version 1.0-6,
http://cran.r-project.org/web/packages/monoProc/monoProc.pdf (The
implementation here is based on the monoProc function mono.1d)


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 86
Produce a smooth monotone increasing approximation to a sampled functional dependence.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
mvregress


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1790
statistics: beta = mvregress ( X , Y )
statistics: beta = mvregress (&hellip;, name , value )
statistics: [ beta , Sigma , E , CovB , logL ] = mvregress (&hellip;)

Multivariate (multiple-response) linear regression by maximum likelihood.

mvregress ( X , Y ) fits the multivariate normal regression
of the n -by- d response matrix Y on the design X and
returns the coefficient estimates beta .

X is either a numeric n -by- p matrix, in which case the same
p predictors apply to every response and beta is returned as a
p -by- d matrix; or a cell array of n design matrices, each
d -by- K , in which case beta is a K -by-1 vector.

Missing responses ( NaN entries of Y ) are handled according to
the estimation algorithm.

The following name / value pairs are accepted:

"algorithm"
"mvn" (multivariate normal; observations with any missing response
are discarded), "ecm" (expectation-conditional-maximization, using
every observed response), or "cwls" (covariance-weighted least
squares, with the weight given by "covar0" ). The default is
"mvn" when Y has no missing values and "ecm" otherwise.
"covar0"
The d -by- d covariance weight for "cwls" (default the
identity), or the initial covariance for "ecm" .
"maxiter"
Maximum number of iterations (default 100).
"tolbeta" , "tolobj"
Convergence tolerances on the coefficients and the objective (defaults
1e-8 and 1e-8 ).

The additional outputs are the estimated residual covariance Sigma
( d -by- d ), the residuals E ( n -by- d ), the
covariance CovB of the coefficient estimates, and the log-likelihood
logL . (With missing data and the "ecm" algorithm, CovB
is the standard observed-information covariance and can differ from
MATLAB &rsquo;s value at the 1e-3 level; all other outputs agree.)

See also:
mvregresslike,
regress,
fitlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73
Multivariate (multiple-response) linear regression by maximum likelihood.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
mvregresslike


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1384
statistics: nlogL = mvregresslike ( X , Y , beta , Sigma , alg )
statistics: [ nlogL , COVB ] = mvregresslike (&hellip;)

Negative log-likelihood for a multivariate regression model.

mvregresslike ( X , Y , beta , Sigma , alg )
returns the negative log-likelihood nlogL of the multivariate normal
regression model with responses Y (an n -by- d matrix, one
row per observation), coefficients beta , and residual covariance
Sigma ( d -by- d ).

X specifies the design. It is either a numeric n -by- p
matrix, in which case the same p predictors apply to every response and
beta is p -by- d ; or a cell array of n design matrices,
each d -by- K , in which case beta is K -by-1.

alg selects how missing responses ( NaN entries of Y ) are
handled: "ecm" (the default) and "cwls" use every observed
response through the marginal likelihood of the observed components, while
"mvn" discards any observation that has a missing response. With no
missing data all three agree.

The optional second output COVB is the covariance matrix of the
coefficient estimates, computed as the inverse of the observed Fisher
information at beta and Sigma . With missing data and the
"ecm" / "cwls" algorithms this is the standard observed-data
covariance and can differ from MATLAB &rsquo;s value (which uses a different
information convention) at the 1e-3 level; nlogL agrees exactly.

See also:
mvregress


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 60
Negative log-likelihood for a multivariate regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
nlinfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4273
statistics: beta = nlinfit ( X , y , modelfun , beta0 )
statistics: beta = nlinfit (&hellip;, options )
statistics: beta = nlinfit (&hellip;, Name , Value )
statistics: [ beta , R , J , CovB , MSE , ErrorModelInfo ] = nlinfit (&hellip;)

Fit a nonlinear regression model.

beta = nlinfit ( X , y , modelfun , beta0 )
estimates the coefficients of the nonlinear regression model
y = modelfun ( beta , X ) by iteratively
minimizing the (possibly weighted) sum of squared residuals, starting from
the initial coefficient vector beta0 . The fit uses the
Levenberg-Marquardt algorithm with a numerically computed Jacobian.

X is a matrix of predictor values. nlinfit does not
interpret the columns of X ; the array is passed unchanged as the second
argument of modelfun , so its shape is whatever modelfun expects.
y is a numeric vector of responses, one element per observation.
modelfun is a function handle @( b , X )
returning a vector of fitted responses the same size as y .
beta0 is a numeric vector of initial values for the coefficients.

Additional options are given either as a statset-style options
structure or as Name / Value pairs (or both). The supported
options are:

Name Value
'Weights' A vector of nonnegative observation weights, or
a function handle @( yhat ) returning such a vector. Weighted
least squares is used.
'ErrorModel' The form of the error variance:
'constant' (default), 'proportional' , or 'combined' .
'ErrorParameters' Initial values for the error-model
parameters.
'RobustWgtFun' The name of a robust weight function
( 'andrews' , 'bisquare' , 'cauchy' , 'fair' ,
'huber' , 'logistic' , 'talwar' , or 'welsch' ),
enabling robust iteratively reweighted least squares. MATLAB accepts this
name only inside an 'Options' structure; taking it as a
Name / Value pair as well is an Octave extension.
'Tune' The tuning constant for the robust weight function.
'Options' A statset-style structure whose MaxIter ,
TolFun , TolX , and DerivStep fields override the
corresponding defaults, and whose RobustWgtFun , Robust ,
WgtFun and Tune fields select a robust fit.
RobustWgtFun names the weight function on its own and takes
precedence over the other two; the older WgtFun is read only when
Robust is 'on' . The structure statset ('nlinfit')
returns carries WgtFun 'bisquare' beside Robust
'off' , and so leaves the fit unweighted.

The remaining outputs describe the converged fit: R is the vector of
raw residuals y - modelfun ( beta , X ) , J
is the Jacobian of modelfun with respect to beta at the solution,
CovB is the estimated covariance matrix of the coefficients, MSE
is the mean squared error, and ErrorModelInfo is a structure describing
the fitted error model.

Algorithm

The coefficients are estimated by the Levenberg-Marquardt algorithm using a
numerically computed (forward-difference) Jacobian. For an ordinary or
weighted fit the coefficient covariance is CovB = MSE *
inv ( J ' * W * J ) , where W is the diagonal matrix of
observation weights and MSE is the weighted residual sum of squares
divided by the error degrees of freedom n - p (with p
coefficients). A non-constant 'ErrorModel' is fitted by generalized
least squares, re-deriving the observation weights from the fitted values
each iteration; the 'proportional' model weights each observation by
the inverse squared fitted value, and MSE then estimates the
proportionality constant of the variance.

For a robust fit ( 'RobustWgtFun' ) the coefficients are found by
iteratively reweighted least squares applied to leverage-adjusted residuals
(the leverage is taken from the ordinary fit and held fixed). The robust
coefficient covariance follows the Street-Carroll-Ruppert convention, the
same one used by robustfit : CovB = s^2 * inv ( J ' *
J ) and MSE = s^2 , where the scale s blends the
ordinary-fit scale ols_s with the robust scale robust_s at the
solution as s^2 = (p^2 &times; ols_s^2 + n &times; robust_s^2) / (n + p^2) , taken
to be at least robust_s .

The robust MSE and CovB differ from MATLAB&rsquo;s by up to a few
tenths of a percent, because the shared robust scale does; robustfit
documents that difference and why it is left in place. The coefficients
themselves agree to about 1e-8.

See also:
fitnlm,
nlparci,
nlpredci,
NonLinearModel,
robustfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 33
Fit a nonlinear regression model.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
nlparci


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1072
statistics: ci = nlparci ( beta , resid , 'covar' , CovB )
statistics: ci = nlparci ( beta , resid , 'jacobian' , J )
statistics: ci = nlparci (&hellip;, 'alpha' , alpha )

Confidence intervals for the coefficients of a nonlinear regression.

ci = nlparci ( beta , resid , 'covar' ,
CovB ) returns the 100 (1 - alpha )% confidence intervals
for the fitted coefficients beta of a nonlinear regression, given the
residual vector resid and the estimated coefficient covariance matrix
CovB (both produced by nlinfit ). ci is a
p -by- 2 matrix whose rows are the lower and upper bounds for the
corresponding coefficient.

ci = nlparci ( beta , resid , 'jacobian' ,
J ) instead derives the coefficient covariance from the Jacobian
J and the residuals. A legacy positional form nlparci
( beta , resid , J ) is also accepted.

The confidence level defaults to 95% ; pass 'alpha' ,
alpha for a 100 (1 - alpha )% interval. The intervals use
Student&rsquo;s t distribution with numel ( resid ) - numel
( beta ) degrees of freedom.

See also:
nlinfit,
nlpredci,
fitnlm,
NonLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
Confidence intervals for the coefficients of a nonlinear regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
nlpredci


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1994
statistics: [ ypred , delta ] = nlpredci ( modelfun , X , beta , resid , 'Jacobian' , J )
statistics: [ ypred , delta ] = nlpredci ( modelfun , X , beta , resid , 'Covar' , CovB )
statistics: [ ypred , delta ] = nlpredci (&hellip;, Name , Value )

Confidence intervals for predictions of a nonlinear regression.

[ ypred , delta ] = nlpredci ( modelfun , X ,
beta , resid , 'Jacobian' , J ) returns the predicted
responses ypred of the model modelfun ( beta ,
X ) at the new predictor values X , together with the half-widths
delta of the 100 (1 - alpha )% confidence intervals, so
that ypred - delta and ypred + delta
bound the response. beta , resid (the residuals) and J (the
Jacobian) come from nlinfit .

Instead of the Jacobian, an estimated coefficient covariance may be supplied
with 'Covar' , CovB . The following Name /
Value pairs are also accepted:

Name Value
'MSE' The mean squared error from nlinfit , required
with 'Covar' for observation (prediction) intervals.
'PredOpt' 'curve' (default) for confidence
intervals on the fitted curve, or 'observation' for prediction
intervals on a new observation.
'SimOpt' 'off' (default) for pointwise intervals,
or 'on' for simultaneous (Scheffe) intervals.
'Alpha' The significance level; the interval has
confidence 100 (1 - alpha )% (default alpha = 0.05).

Algorithm

Each half-width is delta = c * sqrt (v) . The variance v
of the fitted curve is diag ( Jnew * V * Jnew ') ,
where V is the coefficient covariance (either CovB , or
MSE * inv ( J ' * J ) when a Jacobian is supplied) and
Jnew is the Jacobian of modelfun at X ; an
'observation' interval adds the error variance MSE to v .
The critical value c is the Student&rsquo;s t quantile at
1 - alpha /2 with the error degrees of freedom for a pointwise
interval, or the Scheffe value sqrt (k * finv (1 - alpha , k,
dfe)) for a simultaneous interval, where k is the number of
coefficients (plus one for an observation interval).

See also:
nlinfit,
nlparci,
fitnlm,
NonLinearModel


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
Confidence intervals for predictions of a nonlinear regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
plsregress


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4466
statistics: [ xload , yload ] = plsregress ( X , Y )
statistics: [ xload , yload ] = plsregress ( X , Y , NCOMP )
statistics: [ xload , yload , xscore , yscore , coef , pctVar , mse , stats ] = plsregress ( X , Y , NCOMP )
statistics: [ xload , yload , xscore , yscore , coef , pctVar , mse , stats ] = plsregress (&hellip;, Name , Value )

Calculate partial least squares regression using SIMPLS algorithm.

plsregress uses the SIMPLS algorithm, and first centers X and
Y by subtracting off column means to get centered variables. However,
it does not rescale the columns. To perform partial least squares regression
with standardized variables, use zscore to normalize X and
Y .

[ xload , yload ] = plsregress ( X , Y ) computes a
partial least squares regression of Y on X , using NCOMP
PLS components, which by default are calculated as
min (size ( X , 1) - 1, size( X , 2)) , and returns the
the predictor and response loadings in xload and yload ,
respectively.

X is an N&times;P matrix of predictor variables, with rows
corresponding to observations, and columns corresponding to variables.
Y is an N&times;M response matrix.
xload is a P&times;NCOMP matrix of predictor loadings, where
each row of xload contains coefficients that define a linear
combination of PLS components that approximate the original predictor
variables.
yload is an M&times;NCOMP matrix of response loadings, where
each row of yload contains coefficients that define a linear
combination of PLS components that approximate the original response
variables.

[ xload , yload ] = plsregress ( X , Y ,
NCOMP ) defines the desired number of PLS components to use in the
regression. NCOMP , a scalar positive integer, must not exceed the
default calculated value.

[ xload , yload , xscore , yscore , coef ,
pctVar , mse , stats ] = plsregress ( X , Y ,
NCOMP ) also returns the following arguments:

xscore is an N&times;NCOMP orthonormal matrix with the predictor
scores, i.e., the PLS components that are linear combinations of the
variables in X , with rows corresponding to observations and columns
corresponding to components.
yscore is an N&times;NCOMP orthonormal matrix with the response
scores, i.e., the linear combinations of the responses with which the PLS
components xscore have maximum covariance, with rows corresponding to
observations and columns corresponding to components.
coef is a (P+1)&times;M matrix with the PLS regression
coefficients, containing the intercepts in the first row.
pctVar is a 2&times;NCOMP matrix containing the percentage of
the variance explained by the model with the first row containing the
percentage of explained varianced in X by each PLS component and the
second row containing the percentage of explained variance in Y .
mse is a 2&times;(NCOMP+1) matrix containing the estimated mean
squared errors for PLS models with 0: NCOMP components with the
first row containing the squared errors for the predictor variables in
X and the second row containing the mean squared errors for the
response variable(s) in Y .
stats is a structure with the following fields:

stats .W is a P&times;NCOMP matrix of PLS weights.
stats .T2 is the T^2 statistics for each point in
xscore .
stats .Xresiduals is an N&times;P matrix with the
predictor residuals.
stats .Yresiduals is an N&times;M matrix with the
response residuals.

[&hellip;] = plsregress (&hellip;, Name , Value , &hellip;)
specifies one or more of the following Name / Value pairs:

Name Value
'CV' The method used to compute mse . When
Value is a positive integer K , plsregress uses
K -fold cross-validation. Set Value to a cross-validation
partition, created using cvpartition , to use other forms of
cross-validation. Set Value to 'resubstitution' to use both
X and Y to fit the model and to estimate the mean squared errors,
without cross-validation. By default, Value = "resubstitution" .
'MCReps' A positive integer indicating the number of
Monte-Carlo repetitions for cross-validation. By default,
Value = 1 . A different 'MCReps' value is only
meaningful when using the 'HoldOut' method for cross-validation,
previously set by a cvpartition object. If no cross-validation method
is used, then 'MCReps' must be 1 .

Further information about the PLS regression can be found at
https://en.wikipedia.org/wiki/Partial_least_squares_regression

References

SIMPLS: An alternative approach to partial least squares regression.
Chemometrics and Intelligent Laboratory Systems (1993)


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 66
Calculate partial least squares regression using SIMPLS algorithm.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 7
regress


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1135
statistics: [ b , bint , r , rint , stats ] = regress ( y , X , [ alpha ])

Multiple Linear Regression using Least Squares Fit of y on X
with the model y = X * beta + e .

Here,

y is a column vector of observed values

X is a matrix of regressors, with the first column filled with
the constant value 1

beta is a column vector of regression parameters

e is a column vector of random errors

Arguments are

y is the y in the model

X is the X in the model

alpha is the significance level used to calculate the confidence
intervals bint and rint (see &lsquo;Return values&rsquo; below). If not
specified, ALPHA defaults to 0.05

Return values are

b is the beta in the model

bint is the confidence interval for b

r is a column vector of residuals

rint is the confidence interval for r

stats is a row vector containing:

The R^2 statistic
The F statistic
The p value for the full model
The estimated error variance

r and rint can be passed to rcoplot to visualize
the residual intervals and identify outliers.

NaN values in y and X are removed before calculation begins.

See also:
regress_gp,
regression_ftest,
regression_ttest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 93
Multiple Linear Regression using Least Squares Fit of y on X with the model y = X * beta + e.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
regress_gp


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3474
statistics: [ Yfit , Yint , m , K ] = regress_gp ( X , Y , Xfit )
statistics: [ Yfit , Yint , m , K ] = regress_gp ( X , Y , Xfit , 'linear' )
statistics: [ Yfit , Yint , Ysd ] = regress_gp ( X , Y , Xfit , 'rbf' )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , 'linear' , Sp )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , Sp )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , 'rbf' , theta )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , 'rbf' , theta , g )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , 'rbf' , theta , g , alpha )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , theta )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , theta , g )
statistics: [&hellip;] = regress_gp ( X , Y , Xfit , theta , g , alpha )

Regression using Gaussian Processes.

[ Yfit , Yint , m , K ] = regress_gp ( X ,
Y , Xfit ) will estimate a linear Gaussian Process model m
in the form Y = X ' * m , where X is an
N&times;P matrix with N observations in P dimensional space
and Y is an N&times;1 column vector as the dependent variable. The
information about errors of the predictions (interpolation/extrapolation) is
given by the covariance matrix K .
By default, the linear model defines the prior covariance of m as
Sp = 100 * eye (size ( X , 2) + 1) . A custom prior
covariance matrix can be passed as Sp , which must be a P+1&times;P+1
positive definite matrix. The model is evaluated for input Xfit , which
must have the same columns as X , and the estimates are returned in
Yfit along with the estimated variation in Yint .
Yint (:,1) contains the lower boundary and
Yint (:,2) the upper boundary of the interval about
Yfit , at the confidence level 1 - alpha .

[ Yfit , Yint , Ysd ] = regress_gp ( X ,
Y , Xfit , 'rbf' ) will estimate a Gaussian Process model
with a Radial Basis Function (RBF) kernel with default parameters
theta = 5 and g = 0.01 , which corresponds to the
nugget effect, and
alpha = 0.05 which defines the confidence level for the
estimated intervals returned in Yint . The function also returns the
predictive covariance matrix in Ysd . For multidimensional predictors
X the function will automatically normalize each column to a zero mean
and a standard deviation to one.

Four things about the RBF kernel are worth stating, because they decide
what the numbers mean.

theta is not the characteristic lengthscale. The kernel is
exp (-d^2 / theta ) with d the distance between two
points, so theta is twice the square of a lengthscale l , and
theta = 2 * l^2 .

The intervals in Yint are prediction intervals for a new
observation , not confidence intervals on the mean: the nugget is carried
in the predictive variance, so the noise of an observation is included.

The predictors are centred and scaled only when there is more than one of
them, so theta is measured in the units of X for a single
predictor and in standard deviations for several.

A nugget of zero is accepted and gives an interpolating process, one that
reproduces Y at the training points and reports almost no uncertainty
there. It also leaves the kernel matrix rank deficient whenever two inputs
are close, so in that case the covariance is applied through its
pseudoinverse and the fit is the minimum-norm solution. This is a genuine
answer rather than a refusal, but a small nugget is the better way to ask
for a smooth fit.

Run demo regress_gp to see examples.

See also:
fitrgp,
RegressionGP,
regress,
regression_ftest,
regression_ttest


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 36
Regression using Gaussian Processes.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 5
ridge


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1270
statistics: b = ridge ( y , X , k )
statistics: b = ridge ( y , X , k , scaled )

Ridge regression.

b = ridge ( y , X , k ) returns the vector of
coefficient estimates by applying ridge regression from the predictor matrix
X to the response vector y . Each value of b is the
coefficient for the respective ridge parameter given k . By default,
b is calculated after centering and scaling the predictors to have a
zero mean and standard deviation 1.

b = ridge ( y , X , k , scaled ) performs the
regression with the specified scaling of the coefficient estimates b .
When scaled = 0 , the function restores the coefficients to the
scale of the original data thus is more useful for making predictions. When
scaled = 1 , the coefficient estimates correspond to the scaled
centered data.

y must be an N&times;1 numeric vector with the response data.

X must be an N&times;p numeric matrix with the predictor data.

k must be a numeric vector with the ridge parameters.

scaled must be a numeric scalar indicating whether the coefficient
estimates in b are restored to the scale of the original data. By
default, scaled = 1 .

Further information about Ridge regression can be found at
https://en.wikipedia.org/wiki/Ridge_regression

See also:
lasso,
stepwisefit,
regress


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
Ridge regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
robustfit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2097
statistics: b = robustfit ( X , y )
statistics: b = robustfit ( X , y , wfun )
statistics: b = robustfit ( X , y , wfun , tune )
statistics: b = robustfit ( X , y , wfun , tune , const )
statistics: [ b , stats ] = robustfit (&hellip;)

Robust linear regression.

b = robustfit ( X , y ) returns the coefficient vector
b of a linear regression of the response y on the predictors
X , fitted by robust M-estimation (iteratively reweighted least squares)
so that outlying observations are downweighted. A column of ones is added to
X by default, so b (1) is the intercept.

b = robustfit ( X , y , wfun , tune ,
const ) selects the weight function wfun , its tuning constant
tune , and whether a constant term is included. wfun is one of
'bisquare' (default), 'andrews' , 'cauchy' ,
'fair' , 'huber' , 'logistic' , 'ols' ,
'talwar' , 'welsch' , or a function handle @(r) giving
the weights as a function of the scaled residual. tune defaults to the
value that gives 95% efficiency for each weight function. const is
'on' (default) to include a constant term or 'off' to omit.

[ b , stats ] = robustfit (&hellip;) also returns a structure
stats with fields ols_s , robust_s , mad_s ,
s , se , covb , coeffcorr , t , p ,
w , R , dfe , h , and resid . The coefficients
and the fields ols_s , mad_s , dfe , h , w ,
and resid match MATLAB. The standard errors and quantities derived
from them ( se , t , p , covb ) agree with MATLAB to
within a small fraction of a percent; robust_s is the
Street-Carroll-Ruppert robust scale estimate and differs from MATLAB&rsquo;s by
about 1.5%, measured, with a negligible effect on the standard errors.

That difference is left in place deliberately. The squared influence is
averaged here over n , where the estimator as it is usually published
averages over n-p ; taking that published form moves the result
further from MATLAB rather than closer, so MATLAB implements neither, and
matching it would mean reproducing an undocumented variant. The same scale
serves nlinfit , which is why its robust MSE and CovB
carry the same difference.

See also:
regress,
fitlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
Robust linear regression.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
stepwisefit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3057
statistics: stepwisefit ( X , y )
statistics: b = stepwisefit ( X , y )
statistics: b , se , pval , finalmodel , stats , nextstep , history = stepwisefit ( X , y , varargin )

Perform stepwise linear regression using conditional p-value criteria.

stepwisefit fits a linear regression model to response vector
y using predictor matrix X and performs stepwise variable
selection based on hypothesis tests for individual regression coefficients.

At each iteration, predictors not currently in the model are tested for
inclusion using partial F- or t-tests. The predictor with the smallest
p-value below the entry threshold is added. Predictors currently in the
model (excluding forced predictors) are then tested for removal, and the
predictor with the largest p-value exceeding the removal threshold is
removed. The procedure repeats until the model stabilizes or the maximum
number of iterations is reached.

After variable selection, the final regression model is refit using
regress to compute coefficient estimates and inferential statistics
for both included and excluded predictors.

Arguments

X is an n -by- p numeric matrix of predictor variables.

y is an n -by-1 numeric response vector.

Optional Name-Value pairs may be supplied to control the stepwise
selection procedure.

Name-Value Arguments

'InModel'
Logical row vector of length p specifying predictors that are initially
included in the model.
'Keep'
Logical row vector of length p specifying predictors that must remain
in the model and are never removed during stepwise selection.
'PEnter'
Scalar significance level in the open interval (0,1) specifying the maximum
p-value required for a predictor to enter the model. Default is 0.05 .
'PRemove'
Scalar significance level in the open interval (0,1) specifying the minimum
p-value required for a predictor to be removed from the model. If not
specified, a default value greater than or equal to 'PEnter' is used.
'MaxIter'
Positive integer specifying the maximum number of stepwise iterations.
Default is Inf .
'Scale'
Either 'on' or 'off' . When enabled, predictors are
standardized prior to stepwise selection only. Final regression
coefficients are always reported on the original data scale.
'Display'
Either 'on' or 'off' . Accepted for compatibility but
currently does not affect output.

Return Values

b is a p -by-1 vector of regression coefficients. Coefficients
for excluded predictors are computed conditionally.

se is a p -by-1 vector of standard errors.

pval is a p -by-1 vector of two-sided p-values.

finalmodel is a logical row vector indicating which predictors are
included in the final model.

stats is a structure containing regression diagnostics, including
sums of squares, degrees of freedom, residuals, covariance estimates,
F-statistic, and related quantities.

nextstep is a scalar indicating whether an additional stepwise
iteration is recommended. Currently always zero.

history is a structure summarizing the final model state, including
selected predictors and coefficient history.

See also:
regress


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
Perform stepwise linear regression using conditional p-value criteria.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
stepwiseglm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4632
statistics: mdl = stepwiseglm ( X , y )
statistics: mdl = stepwiseglm ( X , y , modelspec )
statistics: mdl = stepwiseglm ( tbl )
statistics: mdl = stepwiseglm ( tbl , modelspec )
statistics: mdl = stepwiseglm (&hellip;, Name , Value )

Fit a generalized linear regression model by stepwise term selection.

mdl = stepwiseglm ( X , y ) starts from a model given
by modelspec and repeatedly adds or removes terms, one at a time, until
no further move improves the selection criterion. It returns the fitted
GeneralizedLinearModel object mdl , whose Steps property
records the term-selection trace. X is an n -by- p numeric
predictor matrix and y the response; mdl = stepwiseglm
( tbl ) instead takes the predictors and response from the table
tbl (the last column is the response unless overridden).

modelspec is the starting model. It is a Wilkinson formula
string (e.g. 'y ~ x1 + x2' ), a keyword ( 'constant'
(default), 'linear' , 'interactions' , 'purequadratic' ,
'quadratic' , or 'full' ), or a terms matrix. The candidate
terms available to the search are bounded below by 'Lower' and above
by 'Upper' .

The following Name / Value pairs control the stepwise search:

Name Value
'Lower' the smallest model considered (terms in it are
never removed). Defaults to 'constant' .
'Upper' the largest model considered (the candidate term
universe). Defaults to 'interactions' .
'Criterion' the selection criterion: 'Deviance'
(default), 'sse' , 'aic' , or 'bic' . Under
'Deviance' and 'sse' , terms enter or leave by a chi-squared
or F test on the change in deviance; under 'aic' / 'bic'
the move that most reduces the information criterion is taken.
'PEnter' the p -value (or criterion margin) below
which a term is added. Defaults to 0.05 for 'Deviance' and
'sse' , and 0 for 'aic' / 'bic' .
'PRemove' the p -value (or criterion margin) above
which a term is removed. Defaults to 0.10 for 'Deviance' and
'sse' , and 0 for 'aic' / 'bic' .
'NSteps' the maximum number of steps. Defaults to
Inf (run to convergence).
'Verbose' 0 to run silently, or 1 (default)
to print each accepted step.

As in fitglm , a 'binomial' response is the number of
successes, and the trials come either from 'BinomialSize' or from
passing y as an n -by- 2 matrix of successes and trials.
Changed in 1.9.0 : y was previously read as the proportion.

All Name / Value pairs accepted by fitglm (such as
'Distribution' , 'Link' , 'Weights' , 'Offset' ,
'BinomialSize' , 'Intercept' , 'DispersionFlag' ,
'CategoricalVars' , and 'Exclude' ) are also accepted and
forwarded to the fit.

The Steps property

The returned model&rsquo;s Steps property records the trace, as a
structure with seven fields. Start , Lower , and Upper
are LinearFormula objects for the starting model and the two bounds;
Criterion is the criterion as it was asked for; PEnter and
PRemove are the thresholds it ran under; and History is 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&rsquo;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, which is why a history is read by name and not by position:

Criterion Further columns
'Deviance' Deviance , then Chi2Stat or
FStat as the dispersion is fixed or estimated, then PValue .
'sse' FStat and pValue .
'aic' , 'bic' one column, AIC or
BIC , holding the criterion&rsquo;s value after the step, the starting
model included.

The first row is the starting model, named by its right-hand side.

Categorical predictors

A categorical predictor with L levels contributes L - 1
indicator columns, the first level being the omitted reference, and the
search treats that whole group as a single term : it is added or
removed in one step, worth L - 1 degrees of freedom, and never one
indicator at a time. An interaction naming a categorical predictor behaves
the same way, contributing one column per indicator and entering as one
term. Steps.History names such a term by the predictor
( 'g' , or 'x1:g' for the interaction) rather than by its
indicators, while CoefficientNames names the indicators
( 'g_B' , 'x1:g_C' ).

In a table, every column that groups its observations is taken as
categorical: a cell array of character vectors, a categorical array,
a string array, or a logical column. 'CategoricalVars' adds to
these, and is the only way to mark a column of a predictor matrix ;
it takes predictor names, column indices, or a logical vector.

See also:
GeneralizedLinearModel,
fitglm,
stepwisefit,
glmfit,
glmval


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 69
Fit a generalized linear regression model by stepwise term selection.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
stepwiselm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9276
statistics: mdl = stepwiselm ( tbl )
statistics: mdl = stepwiselm ( tbl , ResponseVarName )
statistics: mdl = stepwiselm ( tbl , y )
statistics: mdl = stepwiselm ( X , y )
statistics: mdl = stepwiselm (&hellip;, InitialModel )
statistics: mdl = stepwiselm (&hellip;, Name , Value , &hellip;)

Fit a linear regression model using stepwise regression and return a
LinearModel object.

stepwiselm starts from an initial model and repeatedly searches for
a term to add to, or remove from, the current model, based on the value of
the 'Criterion' option, until no single addition or removal
improves the model any further.

Basic Syntax

mdl = stepwiselm ( tbl ) fits a stepwise model using the
variables in the table (or dataset) tbl , starting from a constant
model. By default, the last variable in tbl is used as the response
and all other variables are candidate predictors. Variables that are
categorical arrays, cell arrays of character vectors, or logical
arrays are automatically treated as categorical predictors.

mdl = stepwiselm ( tbl , ResponseVarName ) uses the
variable named ResponseVarName in tbl as the response, and all
remaining variables in tbl as candidate predictors.

mdl = stepwiselm ( tbl , y ) uses the variables in
tbl as candidate predictors and the external numeric vector y
as the response.

mdl = stepwiselm ( X , y ) fits a stepwise model of
the response y to the predictor data X , an N&times;P numeric
or logical matrix. By default, the predictors are named 'x1' ,
'x2' , &hellip;, 'xP' and the response is named
'y' .

Initial Model, and Lower/Upper Bounds

mdl = stepwiselm (&hellip;, InitialModel ) additionally
specifies the model to start the stepwise search from, using any of the
input combinations shown above. InitialModel can be any of the
following, and the same set of values can also be used for the
'Lower' and 'Upper' options below, which bound the
smallest and largest set of terms stepwiselm is allowed to reach.

Value Description
'constant' Model contains only an intercept term. This
is the default InitialModel and default 'Lower' bound.
'linear' Model contains an intercept and one term
for each predictor variable.
'interactions' Model contains an intercept, all
linear terms, and all pairwise products of distinct predictor variables
(no squared terms). This is the default 'Upper' bound.
'purequadratic' Model contains an intercept, all
linear terms, and all squared terms.
'quadratic' Model contains an intercept, all linear
terms, all pairwise products of distinct predictor variables, and all
squared terms.
'polyijk' Model is a polynomial with maximum degree
i in the first predictor, j in the second, and so on, given
as a run of single-digit numerals, one per predictor (e.g.
'poly21' for two predictors). The model contains interaction
terms, but the degree of each interaction term never exceeds the largest
of the specified per-predictor degrees.
terms matrix A T&times;P or T&times;(P+1) numeric matrix,
where T is the number of terms and P is the number of
predictor variables, following the same convention as fitlm &rsquo;s
terms matrix. When InitialModel is given as a terms matrix, the
'PredictorVars' option may not also be used.
Wilkinson formula A character vector of the form
'y ~ terms' . When a formula is combined with 'ResponseVar'
or 'PredictorVars' , the formula&rsquo;s response and predictor terms
must agree with those options, or stepwiselm errors.

Options

mdl = stepwiselm (&hellip;, Name , Value , &hellip;)
specifies additional options using one or more Name-Value pair
arguments.

Name Value
'Criterion' Criterion used to decide whether a term is
added or removed at each step. One of 'sse' (default),
'aic' , 'bic' , 'rsquared' , or 'adjrsquared' .
For 'sse' , the p-value of an F-test comparing the model with and
without the candidate term is used; for the others, the raw change in the
named quantity is used directly against 'PEnter' / 'PRemove' .
'PEnter' Threshold to add a term. Defaults depend on
'Criterion' : 0.05 for 'sse' , 0 for
'aic' / 'bic' , 0.1 for 'rsquared' , 0
for 'adjrsquared' .
'PRemove' Threshold to remove a term. Defaults depend
on 'Criterion' : 0.10 for 'sse' , 0.01 for
'aic' / 'bic' , 0.05 for 'rsquared' ,
-0.05 for 'adjrsquared' .
'NSteps' Maximum number of add/remove steps to take,
given as a nonnegative integer. Default is unlimited. 'NSteps'
set to 0 returns the initial model unchanged.
'Lower' Model specification (in the same form as
InitialModel , above) describing terms that may never be removed from
the model. Terms in 'Lower' are protected from removal, but are
not automatically added if absent from InitialModel . Default is
'constant' .
'Upper' Model specification (in the same form as
InitialModel , above) describing the largest set of terms
stepwiselm may add. Default is 'interactions' .
'Verbose' Controls how much progress information is
printed while stepping. 0 suppresses all output, 1
(default) prints the action taken at each step, 2 additionally
prints the p-value or criterion value considered for every candidate term
examined at each step.
'Intercept' A logical scalar indicating whether the
initial model includes a constant (intercept) term. Only applies when
InitialModel is a character vector model name (or omitted); ignored
when InitialModel is a terms matrix or formula. Default is
true .
'Weights' A numeric vector of nonnegative observation
weights, one per observation. Default is a vector of ones.
'Exclude' A numeric or logical vector specifying
observations to exclude from the fit.
'CategoricalVars' Specifies which predictor variables
are treated as categorical, given as a vector of column indices, a logical
vector, or a cell array of variable names (table input only). Each
categorical predictor with L distinct categories is expanded into
L-1 indicator variables, and stepwiselm always adds or
removes that entire group of indicator variables together, in a single
step, treating the categorical predictor as one term.
'VarNames' A cell array of character vectors naming the
predictor and response variables, response last. Only applies when
X and y are supplied directly, not table input.
'ResponseVar' A character vector naming the response
variable, overriding the response that would otherwise be inferred (the
last table variable, or 'y' for matrix input).
'PredictorVars' A cell array of character vectors
naming which variables in tbl to consider as candidate predictors.
By default, all variables in tbl other than the response are used.
May not be combined with a terms-matrix InitialModel , and must
agree with any formula-based InitialModel .

The Steps property

The returned model&rsquo;s Steps property records the trace, as a
structure with seven fields. Start , Lower , and Upper
are LinearFormula objects for the starting model and the two bounds;
Criterion is the criterion as it was asked for; PEnter and
PRemove are the thresholds it ran under; and History is 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&rsquo;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, which is why a history is read by name and not by position:

Criterion Further columns
'SSE' FStat and pValue .
'AIC' , 'BIC' , 'Rsquared' ,
'AdjRsquared' one column named for the criterion, holding its
value after the step, the starting model included.

The first row is the starting model, named by its right-hand side.
step appends to the history it inherits rather than beginning a new
one, and inherits Criterion , Lower , PEnter , and
PRemove from it; Steps.Start is then the model stepped from.

Algorithm

At each step, stepwiselm examines every term not currently in the
model but within the 'Upper' bound, and every term currently in
the model but not protected by the 'Lower' bound. If any term
outside the model would improve it by at least 'PEnter' , the best
such term is added; otherwise, if any term inside the model falls short of
'PRemove' , the worst such term is removed. The process repeats
until neither an addition nor a removal improves the model, or until
'NSteps' steps have been taken.

stepwiselm never adds a higher-order term unless all of its
lower-order marginal terms are already in the model (e.g. it will not add
x1:x2^2 unless both x1 and x2^2 are already present),
and correspondingly never removes a lower-order term that a higher-order
term still in the model depends on. At every step, if a term in the
current model is found to be exactly redundant (linearly dependent on the
other terms already in the model), it is removed immediately regardless of
the 'Criterion' value.

Because the final model depends on the initial model and the order in
which terms are considered, stepwiselm finds a locally, but not
necessarily globally, optimal model.

Robust fitting cannot be combined with stepwise regression; do not pass
'RobustOpts' to stepwiselm .

mdl is returned as a LinearModel object. See also the
step method of LinearModel , which performs a single bounded
round of stepwise search starting from an already-fitted model.

See also:
LinearModel,
fitlm


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 88
Fit a linear regression model using stepwise regression and return a LinearModel object.





