BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fannavivian
Obsidian | Level 7

Hi,

 

Can anyone tell me how SAS calculates probalibility using proc logistic score statement? Why my manual probability calculation is so different from SAS's? Does SAS take all variables into calculation or only significant ones?

 

P=exp(F)/(1+exp(F)) = 1 / (1+exp(-F))

 

Analysis of Maximum Likelihood Estimates Parameter   DF Estimate Standard
Error Wald
Chi-Square Pr > ChiSq
Intercept 1-0.97240.233117.4036<.0001
classA110.01500.08270.03280.8562
classA21-0.06940.03803.34680.0673
classA31-0.16810.046712.92760.0003
classA410.14980.07064.50500.0338
classB11-0.17600.054710.35360.0013
classC111.49620.02802863.0571<.0001
classD11-0.54370.0445149.1918<.0001
classE110.13580.17940.57270.4492
classE210.11910.32480.13450.7138
classE31-0.36800.44820.67400.4117
Numeric1 1-0.23140.0197138.3852<.0001
Numeric2 10.0002590.00004042.9420<.0001
Numeric3 12.11900.1641166.7216<.0001

 

 

Thank you!!!

Fan

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Without seeing your code or data, it is difficult to guess your problem.

 

Do you have missing values? If so, you need to handle them correctly. Are you using the full precision of the parameter estimates or just the 4 decimal place shown in the table?

 

The following is a brief example that uses the DATA step to score.  In practice, you would use the CODE statement, the SCORE statement, or PROC PLM, as explained in the article that Reeza links to.

 

proc logistic data=sashelp.class;
model sex = height weight age;
output out=LogiPred(keep=P) pred=P;
run;

data DataPred;
set sashelp.class;
F = -1.19262669802445  + 
    -0.15172772458382 * Height +  
    -0.13262689324423 * Weight +
     1.76465589368491 * Age;
P = 1 / (1 + exp(-F));
keep P;
run;

proc compare base=LogiPred compare=DataPred method=absolute criterion=1e-12;
run;

View solution in original post

4 REPLIES 4
Reeza
Super User

It uses the variables listed in the ParameterEstimates tables.

If you're doing a selection method, the last table is the significant one. 

 

If you want code that replicates the scoring code, look at CODE statement within PROC LOGISTIC. 

See the various methods for scoring data here:

http://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html

 

Here's a fully worked example to demonstrate the issue.

https://communities.sas.com/t5/SAS-Statistical-Procedures/How-to-determine-logistic-regression-formu...

fannavivian
Obsidian | Level 7

Appreciate your answer. Please correct me if I am wrong. As for SAS's calculation, it takes all the variables in the parameter estimates report, just the all the predictor variables. And as in your answers, there's still difference. So I really would like to know what makes the difference.

 

Thanks!

Rick_SAS
SAS Super FREQ

Without seeing your code or data, it is difficult to guess your problem.

 

Do you have missing values? If so, you need to handle them correctly. Are you using the full precision of the parameter estimates or just the 4 decimal place shown in the table?

 

The following is a brief example that uses the DATA step to score.  In practice, you would use the CODE statement, the SCORE statement, or PROC PLM, as explained in the article that Reeza links to.

 

proc logistic data=sashelp.class;
model sex = height weight age;
output out=LogiPred(keep=P) pred=P;
run;

data DataPred;
set sashelp.class;
F = -1.19262669802445  + 
    -0.15172772458382 * Height +  
    -0.13262689324423 * Weight +
     1.76465589368491 * Age;
P = 1 / (1 + exp(-F));
keep P;
run;

proc compare base=LogiPred compare=DataPred method=absolute criterion=1e-12;
run;
Reeza
Super User

99% of the time the difference will be due to an error in the manual calculation. 

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 8458 views
  • 4 likes
  • 3 in conversation