mnrval
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: […] = mnrval (…, 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 numeric matrix of observations on
predictors. pihat is an matrix, where 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 vector).
[pihat, dlo, dhi] = mnrval (B, X,
stats) also returns 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 matrix. With
'interactions','off', B is a vector holding the
intercepts followed by the 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, category probabilities),
'cumulative' ( cumulative probabilities of the first
categories), or 'conditional' ( 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 . Default is . |
Source Code: mnrval
See also: mnrfit, glmval, logistic_regression
Source Code: mnrval
Fit an ordinal model and predict the category probabilities
X = [1; 2; 3; 4; 5; 6; 7; 8]; Y = [1; 1; 1; 2; 2; 2; 3; 3]; B = mnrfit (X, Y, 'model', 'ordinal'); pihat = mnrval (B, X, 'model', 'ordinal')
pihat = 1.0000 0 0 1.0000 0 0 1.0000 0.0000 0 0.0000 1.0000 0 0.0000 1.0000 0 0.0000 1.0000 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 1.0000