Is Poisson regression possible with row level mixed numeric / factor data?

I checked different sources here and here but was still unclear of the response so I am asking. I am thinking of using a Poisson regression for several reasons. One: response is a count, two: data not all numeric three: distribution is not normal. The problem is my data is not aggregated, it is row level and I'm no sure if it's possible to use Poisson (Note: management does not want a logistic regression). If my data must be rearranged to use Poisson, I am unsure which rearrangement to use. I am using R so here is my data frame

## patient hospital data

id <- c(123, 234, 456, 567, 678, 789, 890, 901, 1000)  # factor
year <- c(2015, 2017, 2016, 2017, 2015, 2016, 2016, 2015, 2017)  # factor
state <- c('NY', 'CA', 'NY', 'MI', 'NV', 'CA', 'CA', 'NY', 'NH')  # factor
age <- c(25, 45, 67, 24, 17, 34, 75, 22, 51) # integer
wagesWk <- c(200, 1220.75, 500, 600, 500.5, 1200, 900, 200.5, 400.5) # continuous
numStateHosp <- c(45, 100, 54, 100, 37, 90, 71, 92, 52) # integer
residence <- c("condo", "shelter", "hospice", "rental", "parents", "condo", "hospice", "parents", "rental") #factor
ethnicity <- c('group1','group4','group3','group1','group1','group4','group2','group1','group4') #factor
underPhysCare <- c('N','Y','Y','N','Y','N','Y','Y', 'N')  #factor

df <- data.frame(id, year, state, stage, age, wagesWk, numStateHosp, residence, ethnicity, underPhysCare)


response: count of number patients by year and ethnicity a = year b = ethnicity

therefore: response: countPatients with subscripts ab explanatory variables: year, state, stage, age, wagesWk, ethnicity, underPhysCare

The problem is this is row level data. If I aggregate like this:

num_patients_2015_group1
num_patients_2015_group2
num_patients_2015_group3...
num_patients_2016_group1
num_patients_2016_group2
num_patients_2016_group3...


Wouldn't this require multiple Poisson regressions? If so, how do I incorporate my explanatory variables? If Poisson is not a good choice, what other choice can I use? For sure I cant OLS because the normality assumption is violated and I am not allowed to use logistic.

If I've understood correctly, you're looking to do a Poisson regression in which the data can be aggregated by year and ethinicity into a contingency table which may look like (using the data you provide)

     ethnicity
year   group1 group2 group3 group4
2015      3      0      0      0
2016      0      1      1      1
2017      1      0      0      2


If that is correct, Poisson regression is an excellent way to do this. In fact, Poisson regression is one of the main ways you can analyze contingency tables like this (the other way is logistic regression and I find it strange they won't allow you to use it). You can simply group by year and ethnicity and count the number of rows in each group. This would be the outcome and you can adjust the expected mean by year and group very simply.

Using some R code...


library(tidyverse)
tabl = xtabs(~year + ethnicity, data = df)
model_data = tabl %>%
as.data.frame() %>%
mutate(year = as.numeric(year))

model = glm(Freq ~ year + ethnicity, data = model_data, family = poisson)
summary(model)


You can add additional predictors quite naturally by adding them to the xtabs formula.

• Thanx for your suggestions. Isn't it a problem to make the year numeric? Shouldn't it be categorical because it is not quantitative? Apr 23 at 17:29
• @ithoughtso If you're willing to make the assumption that the effect of year to year is constant, then you can leave it as such. There are good reasons to treat year as a numeric variable, and it would take very good rationale to say otherwise. Apr 24 at 0:29
• Thanx for your input. I just realized I made a mistake. I need to look into the counts of 'underPhysCare' by year and ethnicities, can Poisson regression still be used or is this now a proportion problem? Apr 25 at 7:15
• It works, thanx! Apr 26 at 6:58