How many events per variable you can afford
Today let's understand how many patients a logistic regression model actually needs, by building a study where the correct answer is already known and watching a model get it wrong anyway.
A hospital wants to predict which patients get readmitted within 30 days of discharge, from 5 measurements taken at discharge, x1 through x5. We will simulate these patients ourselves and fix the true relationship between those 5 measurements and readmission before fitting a single model. That is the one advantage a simulation gives that a real dataset never can: we already know the right answer, so we can measure exactly how far a fitted model drifts from it.
We will build this same simulated study five times over, giving the model fewer and fewer patients to learn from each time, while the true relationship underneath stays exactly the same. The chart below plots what happened each time. Moving right to left, each point is this same model fitted with less and less data relative to its 5 predictors, and the height of each point is how much the model's predicted probabilities can still be trusted on a patient it has never seen: 1.0 means fully, and well below 1 means the model is overconfident.
That line drops from 0.97 on the right down to 0.53 on the left, as the model saw fewer and fewer patients.
What events per variable actually counts
A study like the one you just saw actually has three separate quantities buried inside it, not one. The sample size, n, is how many patients are in the study. The number of events is how many of those patients had the outcome you actually care about, a readmission here, and it is never the same number as n, because not every patient gets readmitted.
Why does the event count matter more than n on its own? A model learns what distinguishes the readmitted patients from everyone else, so it is the readmitted patients, the rarer group, that actually carry that information. A study with 10,000 patients but only 20 readmissions has barely more to learn from than a much smaller study with those same 20 readmissions.
The third quantity is p, the number of predictor variables the model uses. Events per variable, or EPV, is the number of events divided by p. It measures how much evidence the model actually has relative to how many things it is trying to estimate, which is a very different question from how many patients it has.
Because readmission is a yes or no outcome, this lesson uses logistic regression rather than ordinary linear regression. A logistic regression does not predict the readmission probability directly. It predicts the log odds of readmission, log(prob / (1 - prob)), as a straight-line combination of the predictors, then converts that number back into a probability. Each coefficient, like the 0.8 you will see on x1 below, is how much that log odds number moves for a one-unit change in that predictor.
Here is the running example this whole lesson uses. A hospital records 5 measurements at discharge, x1 through x5. We rig the true relationship between them and readmission ourselves: x1 raises the log odds of readmission by 0.8, x2 lowers it by 0.6, x3 raises it by 0.5, x4 lowers it by 0.4, and x5 raises it by 0.3. An intercept of -1.6 keeps the overall readmission rate close to 20%.
Let's build one such dataset and see its EPV.
With 1250 patients, only 272 of them were actually readmitted, and with 5 predictors that gives an EPV of 54.4. A long-standing rule of thumb, from Peduzzi and colleagues in 1996, says a logistic regression needs at least 10 events per variable to be trusted. Rather than take that on faith, let's refit this exact true model at several descending events-per-variable levels and watch what actually happens to it.