BookmarkSubscribeRSS Feed
chemicalab
Fluorite | Level 6

Hi all,

I have the following situation, I have created a training and validation sample in which both the analogy of events/nonevents is the same thus 50-50.

I have fitted the training sample and tested my model  on the validation sample (using proc logistic) with good results and i want to score now the initial population as a final test from which i made the two samples.

The initial population consists of 80% nonevents (0) and 20% events (1), if am not mistaken this means that i will have to adjust my predicted probabilities on the population to the true event rate since my model was build on a 50-50 analogy is that correct?

How could i do that in SAS Base? I mean which output from the logistic regression must I investigate and apply this alteration? Any ideas? If i could know how the predicted probability in the first case is calculated maybe i could adjust within that calculation.

Thank you in advance

12 REPLIES 12
stat_sas
Ammonite | Level 13

I think you oversampled the population to make event/non-event in 50-50 proportions in your training/validation samples. Check offset option in logistic regression to adjust predicted probabilities.

chemicalab
Fluorite | Level 6

Exactly that's what I did, would you happen to have any example on the offset option syntax wise so i could understand it better?

Thanks

M_Maldonado
Barite | Level 11

Thanks @stat@sas !
An awesome read... I stopped doing what I was doing just to read this even if I don't use base SAS (I use EM). Still, very nice article... Thanks!

chemicalab
Fluorite | Level 6

One more question though, by using either prior or offset will i be adjusting the probabilities in the population data that i want to score or the already predicted probabilities in the training and validation set?

stat_sas
Ammonite | Level 13

Offset just aligns intercept it does not effect beta coefficients. Use offset in proc logistic using your training data set and get the parameter estimates. Score validation dataset using estimates obtained through training dataset. If you see results are almost similar then you can use this model for population dataset as well.

chemicalab
Fluorite | Level 6

Ok , I was just under the impression that since the intercept gets "inflated" that would mean that the predicted probabilities would get inflated too ,thus they would need adjustment too, am I wrong?

chemicalab
Fluorite | Level 6

Aha ok i misread since i am adjusting intercept I am good to go, so for scoring the validation which is also of a 50-50 analogy i dont need to adjust, that would be only for the population scoring where the true rates of events and non events is depicted

stat_sas
Ammonite | Level 13

That is correct. If the objective is to see significance of predictors only then you don't need to use offset.

chemicalab
Fluorite | Level 6

Thank you for your clarifications

chemicalab
Fluorite | Level 6

I have tried the following :

proc freq data=OUTPUT.POPULATION (THE SET WITH 95% nonevents and 5% events) noprint;

        table TARGET / out=priors(drop=percent rename=(count=_prior_));

        run;

and i try to score it with the parameters based on the training set:

PROC LOGISTIC INMODEL=MODELPARAMETERSTRAINING (the 50-50 sample)  ;

     SCORE DATA=OUTPUT.POPULATION PRIOR=PRIORS

     OUTROC=ROC

    OUT=SCORESPOP PREDICTED=ESTPROB

;

RUN;

Would that be the correct syntax? I am wondering cause when i compare the estimated probabilities of scoring with or without the priors i see a huge difference in p_1

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!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 12 replies
  • 1816 views
  • 0 likes
  • 3 in conversation