2
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ This sounds like a job for a random effect. Checkout the gelman and hill book. $\endgroup$ – Matthew Drury Jun 15 '17 at 14:38
  • $\begingroup$ 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. $\endgroup$ – David Smith Jun 15 '17 at 17:02
3
$\begingroup$

This is a job for logistic multilevel regression. Your data are structured hierarchically in two levels.

  • Surfaces are at Level 1. You measure the presence of bacteria (yes or no) here, which is the dependent variable (DV). You also measure type of surface here, which is an independent variable (IV1). You can include any measurements that are about surfaces here.

  • Households are at Level 2. You measure the presence of pets (yes or no) here, which is an independent variable (IV2). Any other measurements of the household could be included here.

You just need to make sure your data include an identification variable that is unique for every single surface as well as an identification for household that is unique to every household.

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)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.