Logistic Regression, Small Sample Size, Issue with Categorization

So I’m looking at a data set. I am thinking about a logistic regression method for it because we’re looking at many different surfaces in households and whether they were positive or negative for a specific bacteria markers, given the distance from some different potential sources and whether the households have pets. The problem is that there are 3-4 surfaces of different types each coming from 21 different homes. Making a dummy that accounts for each different household definitely would be dumb because it would essentially add 21 new variables. haha. So total number of surfaces is around 150. So, we are trying to a lot with very little data.

We need to account for the different households in my opinion because different families might be more similar in their carriage,etc... I was thinking of categorizing the houses by similar traits (different combinations of things), then use those as the dummies. Is there any easy solution that comes to mind for you?

• This sounds like a job for a random effect. Checkout the gelman and hill book. – Matthew Drury Jun 15 '17 at 14:38
• Exactly. Households are a random effect. The type of surface, eg, fridge, stove, tabletop, is likely a fixed effect and multiple surfaces of one type within a household is another random effect. – David Smith Jun 15 '17 at 17:02

If you are using R for data analyses, I strongly recommend using the lme4 and lmerTest packages. Your model would look something like this:
glmer(bacteria ~ surfacetype + pets + surfacetype*pets + (1 + surfacetype | houseid), family=binomial, data=data)