# Test for comparing number of observed events between two groups of subjects

I have two groups of subjects ('intervention' and 'control'), I am observing how many times people attend a hospital over a period of time and basically just want to know if the groups differ from each other.

What makes it complicated:

• The groups are of different size
• The subjects entered the study at different points in time so that the observation time is not the same for all (for some it's one year, for others just two months)

My question basically is what statistical test I have to use/how the data has to be transformed/preprocessed?

My first guess was to use a Poisson regression but I don't know how the dataset should be prepared for that. Do I need one row per subject/event/unit time?

Your outcome for a poisson regression is a count, so you should have every row be a person, with some variables measuring:

• number of hospital visits (dv)

• time under observation

• treatment/control

• other variables of interest

Once you have the data set up you just do a poisson regression with these variables and any others you want to test.

Depending on which program you use, the output will probably display coefficients in log counts. Just something to keep in mind for interpreting the results.

Other models to consider: If you have a lot of people who never went to the hospital, you could consider a zero inflated regression model

Good luck!

• Thanks. That's how I thought I should do it. I really only got confused because I got a "template" analysis where the dataset was transformed so that there was one row per unit time (days) and group (and, of course, the people who have made that have left my dept and there is no explanation) Commented Dec 5, 2017 at 15:31
• @PhilippL with the data set up like that you could do grouped (multilevel) logistic regression or on the likelihood of a hospital visit or e.g. cox regression on time till hospital visit, but then you would have to include a measurement of prior visits, time since visit, etc. For logistic regression, each row would be a hospital visit; for time series analysis each row is a day. Another alternative that occurred to me re: how to deal with the different time frames is, you could make your dependent variable a function of time, for example the number of hospital visits per month. Commented Dec 5, 2017 at 15:38
• It really depends on what you want to know. If you specifically want a count of hospital visits, I think you're right that poisson is best Commented Dec 5, 2017 at 15:39
• Great, thanks. I'm going to accept your first answer as it answers my questions perfectly. Thanks for all the other input as well. I guess an alternative to your last suggestion (i.e. making the dv a function of time) would be to include the time under observation as offset in the regression. Commented Dec 5, 2017 at 15:56