Hi,
I am trying to use proc logit to predict a multinomial variable (polyshaptria) with 3 levels (1,2,3). The code is as follow:
proc logistic data=triathlon_pct;
class polyshaptria;
model polyshaptria =pctPoly_bysurg age sex/ link=glogit;
output out=pred predicted=pred;
run;
quit;
As polyshaptria has 3 level, I assume the predicted probability will distributed consistently with each level (sas will give three predicted probability for each polyshaptria level). That is if the polyshaptria is 1, SAS gives three probability for it corresponding to level 1,2,3. However, the predicted probability of level 1 is always larger than the other two levels. It doesn't make sense. See the data below:
polyshaptria | _LEVEL_ | pred_prob |
1 | 1 | 0.40541 |
1 | 2 | 0.37396 |
1 | 3 | 0.22063 |
1 | 1 | 0.39646 |
1 | 2 | 0.36705 |
1 | 3 | 0.23648 |
2 | 1 | 0.45166 |
2 | 2 | 0.44938 |
2 | 3 | 0.09896 |
For polyshaptria=2, pred_prob should get the largest when _level_=2. But it's still largest when _level_=1.
Can anyone explain the reasons? How SAS predicted multinomial logistic model?
Thanks,
Andrea
> For polyshaptria=2, pred_prob should get the largest when _level_=2. But it's still largest when _level_=1.
No, that is not correct. Just because the observed value is 2 does not mean that the predicted value will be 2. The predicted value is based on the values of the explanatory variables. Some observations will be inevitably be misclassified
I suggest you change from the PREDICTED= option to the PREDPROBS=(INDIVIDUAL_ option. That will create an output data set that is the same size as the input data. The variables _FROM_ and _INTO_ in the output data set show the observed and predicted categories for each observation, You can use PROC FREQ to display a misclassification table, as follows:
proc logistic data=sashelp.cars;
class origin;
model origin = mpg_city weight / link=glogit;
output out=pred predprobs=(individual);
run;
quit;
proc freq data=pred;
tables _FROM_*_INTO_;
run;
Hi Rick,
Thanks!
I did have a look at the misclassification. The proportion is huge (around 50%). That's the reason I want to know how proc logistic works when predicting using glogit.
Just look at the documentation, which has all the details in the "Details" Chapter. You might start with these two sections:
The generalized logit model
Wikipedia also has a nice overview article on multinomial logistic regression.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.