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


Hi,

I have oversampled my data to build a logistic regression model (50/50). The original response rate was for example 0.6%.

Is there any formula that will help me to adjust my scores? I have found this below online (attached PDF), but I am struggling to understand how it works...

Your help would be much appreciated.

http://www.dnbtechnology.com/pdf/DandB-Correcting%20Sample%20Bias%20in%20Oversampled%20Logistic%20Mo...

Many Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
JakesVenter
Obsidian | Level 7

Hi Kanyange,

You can use this equation:

P_i** = ( P_i*  x  R_0 P_1) / ( (1-P_i*) (R_1)(P_0)  +  (P_i*)(R_0)(P_1) )

where:

P_i* is the unadjusted probability you get from your model

R_0 and R_1 are the sample proportions of 1 and 0 respectively

P_0 and P_1 are the original event and non_event rates (population rates)

P_i** is the true probability

View solution in original post

7 REPLIES 7
stat_sas
Ammonite | Level 13

Use priorevent=0.6 in score statement of proc logistic to get adjusted scores.

Kanyange
Fluorite | Level 6

Hi

Thank you for your response....

I have used Enterpise Miner to build the model. I would like to adjust the formula , outsise Enterprise Miner,,

I have found this formula in this forum, I think it's what I need : 1/(1+(1/population proportion)/(1/sample proportion-1)*(1/score-1));

Thank you

Alice

M_Maldonado
Barite | Level 11

Hi Kanyange,

The way I do it in Enterprise Miner is I add a Decisions node after my 50/50 sample.

Click the Decisions ellipsis, then go to the Decisions tab, and Specify "Do you want to use decisions" as Yes.

Go to the Decision Weights and fill the matrix according to each level.

Remember that you are using the inverse of the prior probabilities. For your example, if the event A happens 0.6% or 0.006, then the inverse prior probability is 1/0.006=166.66. This means that event B has a prior probability of 0.994 and an inverse prior probability of 1.006

Then your table would look like:

LevelDecision1Decision2
A166.660
B01.006

The decision node will take care of adjusting the weights of your model.

Your flow can look like: Data->Sample->Decisions->Partition->Regression

Is this the answer you were looking for?

I generally don't use logistic regression for rare events, does logistic work well with your data?

Thanks,

Miguel

aysin
Calcite | Level 5

Hi ,

I don't understand how to use Decisions node for adjusting probabilities. I have 0.7% response rate with 6,000 responses. I used Sample node and created a sample with 50/50 response rate. When I run the sample with Neural Network and Random Forest, I see the results with ROC but my score data was not adjusted to 0.7%. Then I redid everhthing with Decision node; Data-->Sample-->Decisions-->Data Portition (as described above with Decision Weights. In Prior Probabilities, Prior is not 50% it is already 0.7% . I still changed the adjusted prior to 0.7%. Count is 6000/6000). Now, all my results changed. All I see is the baseline with all the models overlapped in my ROC (Zero True Positive and Zero False Positive). I have the score data with adjusted probabilities but I am not sure if I am doing the right thing. I just don't understant how EM is using this process with the sample data. I appreciate any of your comments.

Thanks.

JakesVenter
Obsidian | Level 7

Hi Kanyange,

You can use this equation:

P_i** = ( P_i*  x  R_0 P_1) / ( (1-P_i*) (R_1)(P_0)  +  (P_i*)(R_0)(P_1) )

where:

P_i* is the unadjusted probability you get from your model

R_0 and R_1 are the sample proportions of 1 and 0 respectively

P_0 and P_1 are the original event and non_event rates (population rates)

P_i** is the true probability

MagicalEmerald
Calcite | Level 5

Hi Aysin, you problem is similar to mine, did you get any soulution?As I understand you used two sample nodes to get the prior adjusted. Can I used two decision nodes to make it done? Looks like a solution to me. The advange with the decision node is that EM do all the adjustment by itself.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 16197 views
  • 3 likes
  • 7 in conversation