Programming the statistical procedures from SAS

Calculation about score function in Proc Logistic

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Calculation about score function in Proc Logistic

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


Accepted Solutions
Solution
‎02-22-2017 01:24 PM
SAS Super FREQ
Posts: 3,319

Re: Calculation about score function in Proc Logistic

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


All Replies
Grand Advisor
Posts: 16,933

Re: Calculation about score function in Proc Logistic

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...

Occasional Contributor
Posts: 13

Re: Calculation about score function in Proc Logistic

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!

Solution
‎02-22-2017 01:24 PM
SAS Super FREQ
Posts: 3,319

Re: Calculation about score function in Proc Logistic

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;
Grand Advisor
Posts: 16,933

Re: Calculation about score function in Proc Logistic

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

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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