Poisson Regression I am trying to analyze the data described in the following table. "Patient" column indicates patient ID. The "Disease" column indicates whether the patient gets a disease (1) or not (0). The "Treatment" column indicates the kind of treatment the patient is taken. There are two treatments A and B. "Time" records the time of each visit. Finally, "Visit" indicates the number of visit times.




Patient
Disease
Treatment
Time (Months)
Visit




1
0
A
0
1


1
1
A
3
2


1
0
B
7
3


1
1
B
13
4


2
0
A
0
1


2
0
A
5
2


2
0
A
10
3


2
1
B
15
4


...
...
...
...
...




I am interested in modeling the number of disease occurrence each year and how the treatment influences it. I think I should use GLM Poisson regression to model the number of occurrences. We can use the treatment to fit the number of occurrences. We can add up the number of the disease occurrence for each patient and the total number of months. We create the table like the following:




Patient
#. Disease
Time (Months)




1
2
13


2
1
15


...
...
...




The problem is that I do not know how to handle the treatment. As shown in the first table. Treatments A and B are mixed and there are switches between them. If I add things up as the second table, I will miss the switch information. Then I cannot analyze the influence of each treatment to the disease. How should I process the data? Please help!!!
 A: For a Poisson regression, you could break up the data for each Patient into two rows, corresponding to the times during which each Treatment was in place. Then you could use Treatment as a predictor, the log of time duration within that Treatment for the Patient as an offset, and model disease events per unit time as a function of Treatment. To account for different overall disease susceptibility among patients, you could use a mixed model with Patient as a random effect.
The Poisson model makes a lot of assumptions, however. It assumes that prior history (prior treatments, overall elapsed time, prior events) doesn't affect the risk of later events. It implicitly assumes that each disease "event" is essentially instantaneous with no dead-time or delay before the next "event" can be recorded. There's also a question whether you are missing disease events between visits.
This might better be handled by a repeated-events or multi-state survival model, which can get around most of those assumption. Such models take time, censoring (cases where the last observation time isn't an event), treatments, and changes over time into account in a systematic way. They are implemented, for example, in the R survival package and explained in an associated vignette covering repeated events (among many other topics), and another vignette that explains multi-state modeling and introduces other R packages for such modeling.
Making reliable causal inferences based on time-varying treatments, even with survival-analysis models, is very tricky. I'd recommend that you look at the Causal Inference book by Hernán and Robins to get an idea of the difficulties that arise.
