| Contents | Index |
PHAT = mnrval(B,X)
YHAT = mnrval(B,X,ssize)
[...,DLO,DHI] = mnrval(B,X,...,stats)
[...] = mnrval(...,param1,val1,param2,val2,...)
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.
Note mnrval automatically includes a constant term in all models. Do not enter a column of 1s directly into X. |
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:
'model' — The type of model that was fit by mnrfit; one of the text strings 'nominal' (the default), 'ordinal', or 'hierarchical'.
'interactions' — Determines whether the model fit by mnrfit included an interaction between the multinomial categories and the coefficients. The default is 'off' for ordinal models, and 'on' for nominal and hierarchical models.
'link' — The link function that was used by mnrfit for ordinal and hierarchical models. Specify the link parameter value as one of the text strings 'logit'(the default), 'probit', 'comploglog', or 'loglog'. You may not specify the 'link' parameter for nominal models; these always use a multivariate logistic link.
'type' — Set to 'category' (the default) to return predictions and confidence bounds for the probabilities (or counts) of the k multinomial categories. Set to 'cumulative' to return predictions and confidence bounds for the cumulative probabilities (or counts) of the first k–1 multinomial categories, as an n-by-(k–1) matrix. The predicted cumulative probability for the kth category is 1. Set to 'conditional' to return predictions and confidence bounds in terms of the first k–1 conditional category probabilities, i.e., the probability for category j, given an outcome in category j or higher. When 'type' is 'conditional', and you supply the sample size argument ssize, the predicted counts at each row of X are conditioned on the corresponding element of ssize, across all categories.
'confidence' — The confidence level for the confidence bounds; a value between 0 and 1. The default is 0.95.
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);

[1] McCullagh, P., and J. A. Nelder. Generalized Linear Models. New York: Chapman & Hall, 1990.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |