turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Calculation about score function in Proc Logistic

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-21-2017 03:52 PM

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

Error Wald

Chi-Square Pr > ChiSq

Intercept | 1 | -0.9724 | 0.2331 | 17.4036 | <.0001 | |

classA | 1 | 1 | 0.0150 | 0.0827 | 0.0328 | 0.8562 |

classA | 2 | 1 | -0.0694 | 0.0380 | 3.3468 | 0.0673 |

classA | 3 | 1 | -0.1681 | 0.0467 | 12.9276 | 0.0003 |

classA | 4 | 1 | 0.1498 | 0.0706 | 4.5050 | 0.0338 |

classB | 1 | 1 | -0.1760 | 0.0547 | 10.3536 | 0.0013 |

classC | 1 | 1 | 1.4962 | 0.0280 | 2863.0571 | <.0001 |

classD | 1 | 1 | -0.5437 | 0.0445 | 149.1918 | <.0001 |

classE | 1 | 1 | 0.1358 | 0.1794 | 0.5727 | 0.4492 |

classE | 2 | 1 | 0.1191 | 0.3248 | 0.1345 | 0.7138 |

classE | 3 | 1 | -0.3680 | 0.4482 | 0.6740 | 0.4117 |

Numeric1 | 1 | -0.2314 | 0.0197 | 138.3852 | <.0001 | |

Numeric2 | 1 | 0.000259 | 0.000040 | 42.9420 | <.0001 | |

Numeric3 | 1 | 2.1190 | 0.1641 | 166.7216 | <.0001 |

Thank you!!!

Fan

Accepted Solutions

Solution

02-22-2017
01:24 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to fannavivian

02-22-2017 12:00 PM

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;
```

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to fannavivian

02-21-2017 04:01 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

02-22-2017 11:35 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to fannavivian

02-22-2017 12:00 PM

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;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to fannavivian

02-22-2017 01:18 PM

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