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
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.
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
Thnx
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!
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?
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.
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?
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
That is correct. If the objective is to see significance of predictors only then you don't need to use offset.
Thank you for your clarifications
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.