# Frequency weights, rare events and logistic regression

I'm working on a model that requires me to look for predictors for a rare event (less than 0.5% of the total of my observations). My total sample is a significant part of the total population (50,000 cases). My final objective is to obtain comparable probability values for all the non-events, without the bias of the groups difference in the logistic regression.

I've been reading the info in the following link:

http://gking.harvard.edu/files/gking/files/0s.pdf

It advises me first to use a sample of my original sample, containing all the events (1) and a random sample of 1-5 times bigger of the non-event (0) sample.

Then it suggests using weights based on the proportion of the sample 1s to 0s. In the section 4.2 of the linked text, he offers a "easy to implement" weighted log-likelihood that can be implemented in any logit function.

I wish to implement these weights somehow with R's glm(...,family=binomial(link="logit")) or similar function ( the "weights" parameter is not for frequency weighting), but I don't really know how to apply this weighting.

Does anybody knows how to make it or any other alternative suggestion?

Edit1: As suggested bellow, is Firth's method for bias-correction by penalizing the likelihood in the logistf package a correct approach in this case? I'm not much knowledgeable in statistics, and, while I understand the input and the coefficients/output of the logistic model, what happens in between is still quite a mystery to me, sorry.

• He doesn't advise that at all: "If collecting zeros were costless, we should collect as many as we can get, since more data are always better." If you've already got the data then what's the extra cost of using all of it? See here on down-sampling. – Scortchi - Reinstate Monica May 9 '14 at 10:35
• BTW: Firth's method for bias-correction by penalizing the likelihood is implemented in user-friendly fashion by the logistf package. – Scortchi - Reinstate Monica May 9 '14 at 10:50
• "However, since the marginal contribution to the explanatory variables information content for each additional zero starts to drop as the number of zeros passes the number of ones, we will not often want to collect more than (roughly) two to five times more zeros than ones. In general, the optimal number of zeros depends on how much more valuable the explanatory variables become with the resources saved by collecting fewer observations. Finally, a useful practice is sequential,..." – Edu May 10 '14 at 18:16
• You are confusing study design with data analysis. There are reasons to over- or under-sample groups to save time and resources when designing a study. That is precisely what King was discussing. Once the data are collected, it is a mistake to discard some of the data. – Frank Harrell May 10 '14 at 19:47
• If logistic regression is a mystery for you, you should not attempt building up any complicated variations of it on that shaky foundation. Study logistic regression more before returning to this -- using Hosmer-Lemeshow and/or J Scott Long books, for instance. (And yes, Firth's logistic regression is exactly what Gary King actually proposes, without admitting it straightforwardly.) – StasK May 10 '14 at 20:15