How to perform logistic regression with unbalanced classes? I will be doing a logistic regression to determine if a number of variables influence whether or not a patient received a certain health care service. I will likely have approximately 500 or so observations, and there will likely be far more zeros (patient did not receive service) than ones (patient did receive service).
In the event that I have a very small amount of ones (I am guessing I will have maybe 20-30), what would be the best method to account for this?
 A: Logistic regression does not care about the degree of skew that you have (more events than non-events, or vice versa); the math will work out fine in that sense. Since you mention that you wish to adjust for multiple variables, you will be very limited here. There are various "rules of thumb" concerning how many events per variable should be used. 10 or 15 EPV are quite common, though one may need at lest 50 in some cases to avoid excessive bias in parameter estimation. The best thing to do is almost always collect more data, but assuming this is not possible, you will have to select the most interesting one or two variables.
A: This is exactly what I had faced in using logistic model in ad-click prediction.Your data suffers from rare event scenario. The best way is to -
1) over sample the positive class.(Calibrate the probabilities) At least 10 % positive class. 
2) Run logit model.
3) re-calibrate the inflated probabilities.As by over sampling you will get inflated probabilities.
One thing also, which might be helpful for you is to use L-1 regularisation because many 0s will make your data sparce.
hope this will certainly help.
