# poisson regression for events in a slice of time for a cohort (rather than in a designated start and stop time)

I am interested in determining if the different version of my favorite gene a patient has affects the number of prescription they fill for opiods.

I think I can do this with poisson regression. My understanding of good experimental design for this would be to enroll say 5000 patients that I know will undergo some surgical event then use poisson regression to evaluate counts of prescriptions filled for some designated time, say 2 years after the surgical event). This way I ensure study participants are comparable.

I don't have data gotten form this tidy example, what I do have is data mined from a hospital system that describes opioid prescriptions filled for ~5000 patients from 2010-2019 plus the gene version of interest for each patient.

Would it still be valid to use poisson regression for this group of people if what I am interested in answering is if gene version impacts the number of prescriptions (just in general, regardless of any specific procedure)?

One possible issue that I see is that (probably many) individuals of the cohort may undergo procedures that prompt opioid prescription asynchronously throughout the 2010-2019 window. If a big chunk of them undergo some surgery for this first time in 2018 for example, this might increase patients that have only low counts for number of opioids prescribed due to the recent nature of the produce, which might reduce my chance finding if any version of the gene increases number of prescriptions over time. I have not been able to think of a bias scenario that would make some gene version seem more significantly associated with number of prescriptions filled, although I would not be surprised if one exists.

$$\log \left( \frac{\text{Events}}{\text{Obs time}}\right) = \beta_0 + \sum_{i=1}^p \beta_i X_i$$
where $$X_i$$ is the vector of covariates adjusting the intensity $$\lambda$$. In a Poisson model, you handle the denominator using an offset term for the log of the event time: a patient followed more is expected to have more events.
If you don't know the $$\text{Obs time}$$, it's hard to justify any analysis at all. It's impossible to tell between times when a patient was eligible to fill scrips within an EHR versus when they didn't. You would need to scan the literature and get an appreciation for how not all medical databases are created equally. You could propose that, for instance, you can include subjects who fill at least one scrip within a time frame, and continue to fill another scrip within twelve month intervals to identify "active users" in a database system.