Skip to Main Content Skip to Search
Product Documentation

mnrval - Multinomial logistic regression values

Syntax

PHAT = mnrval(B,X)
YHAT = mnrval(B,X,ssize)
[...,DLO,DHI] = mnrval(B,X,...,stats)
[...] = mnrval(...,param1,val1,param2,val2,...)

Description

PHAT = mnrval(B,X) computes predicted probabilities for the multinomial logistic regression model with predictors X. B contains intercept and coefficient estimates as returned by the mnrfit function. X is an n-by-p matrix of p predictors at each of n observations. PHAT is an n-by-k matrix of predicted probabilities for each multinomial category.

YHAT = mnrval(B,X,ssize) computes predicted category counts for sample sizes ssize. ssize is an n-by-1 column vector of positive integers.

[...,DLO,DHI] = mnrval(B,X,...,stats) also computes 95% confidence bounds on the predicted probabilities PHAT or counts YHAT. stats is the structure returned by the mnrfit function. DLO and DHI define a lower confidence bound of PHAT or YHAT minus DLO and an upper confidence bound of PHAT or YHAT plus DHI. Confidence bounds are nonsimultaneous and they apply to the fitted curve, not to new observations.

[...] = mnrval(...,param1,val1,param2,val2,...) allows you to specify optional parameter name/value pairs to control the predicted values. These parameters must be set to the corresponding values used with the mnrfit function to compute B. Parameters are:

Examples

Fit multinomial logistic regression models to data with one predictor variable and three categories in the response variable:

x = [-3 -2 -1 0 1 2 3]';
Y = [1 11 13; 2 9 14; 6 14 5; 5 10 10; 5 14 6; 7 13 5;...
    8 11 6];
bar(x,Y,'stacked'); 
ylim([0 25]);

% Now fit a nominal model for the individual response
% category probabilities, with separate slopes on the
% single predictor variable, x, for each
% category:

% The first row of betaHatNom contains the intercept terms
% for the first two response categories.  The second row
% contains the slopes.
betaHatNom = mnrfit(x,Y,'model','nominal',...
    'interactions','on')

% Compute the predicted probabilities for the three
% response categories:
xx = linspace(-4,4)';
pHatNom = mnrval(betaHatNom,xx,'model','nominal',...
    'interactions','on');
line(xx,cumsum(25*pHatNom,2),'LineWidth',2);

 

Fit a "parallel" ordinal model for the cumulative response category probabilities, with a common slope on the single predictor variable, x, across all categories:

% The first two elements of betaHatOrd are the
% intercept terms for the first two response categories.
% The last element of betaHatOrd is the common slope.
betaHatOrd = mnrfit(x,Y,'model','ordinal',...
    'interactions','off')

% Compute the predicted cumulative probabilities for the
% first two response categories.  The cumulative
% probability for the third category is always 1.
pHatOrd = mnrval(betaHatOrd,xx,'type','cumulative',...
    'model','ordinal','interactions','off');
bar(x,cumsum(Y,2),'grouped'); 
ylim([0 25]);
line(xx,25*pHatOrd,'LineWidth',2);

References

[1] McCullagh, P., and J. A. Nelder. Generalized Linear Models. New York: Chapman & Hall, 1990.

See Also

glmfit | glmval | mnrfit

How To

  


 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS