0

I am looking for advice on the proper model notation to test for differences between sex in my data. My goal is to determine whether or not I need to split my data into M and F, or if I can keep my data combined (I hope that I will be able to keep it combined due to sample size).

I am using the glmmTMB package in R for resource selection function analysis and my plan is to run 1 model with random intercepts and slopes, without sex, and then compare this model to essentially the same model but contains sex as an interaction term. I will compare AIC to determine the most supported model (i.e. if the model with sex is supported, then I will separate my data into M and F and analyze separately. If the model without sex is supported, then I will keep it combined).

I am following the code provide in the supplementary materials by Muff et al. 2019 (model M4): https://conservancy.umn.edu/bitstream/handle/11299/204737/Goats_RSF.html?sequence=21&isAllowed=y

For example: My model without sex looks like this: glmmTMB(Used_and_Available_Locations ~ Urbanization + (1|AnimalID) + (0 + Urbanization|AnimalID), family = binomial(),...)

My model with sex is where I am confused...How do I account for sex as a random effect when there is an interaction? Should I not account for sex as a random effect?

glmmTMB(Used_and_Available_Locations ~ Sex + Sex*Urbanization + Urbanization + (1|AnimalID) + (0 + Urbanization|AnimalID), family = binomial(),...)

M--
  • 25,431
  • 8
  • 61
  • 93
bruss
  • 21
  • 3
  • Please [edit] your question title to something that describes the problem you're having or question you're asking. Your current title is primarily information that is already available in the tags you used. Your title should be clear and descriptive enough to have meaning to a future user of this site who is skimming a list of search results trying to find a solution to their problem. Your current title is useless in that regard, because it's mostly just regurgitating tags. Thanks. – Ken White Sep 27 '21 at 01:26
  • *How do you incorporate random effects with interactions?* - it looks vaguely like another question about Haskell. How about: "*Data modelling - reconciling random effects with interactions*" ...? – atravers Sep 27 '21 at 01:52
  • atravers - do you have a hyperlink by chance? Nothing is coming up for me when I search that whole title or parts of that title. – bruss Sep 27 '21 at 02:34
  • You misunderstand: I'm suggesting using something like "*Data modelling - reconciling random effects with interactions*" as the title for this question - it isn't the name of a research article. Apologies for the confusion. – atravers Sep 27 '21 at 03:12
  • [*missed edit timeout*] ...I'm only here *because* I thought this was another question about effects in Haskell (or a similar language). – atravers Sep 27 '21 at 03:21

1 Answers1

0

My goal is to determine whether or not I need to split my data into M and F, or if I can keep my data combined (I hope that I will be able to keep it combined due to sample size).

I have never come across a scenario in which it is a good idea to split data along these lines. It results in a massive loss of statistical power, and provides no benefits.

When you have an "effect" of a predictor variable that differs depending on the level of another predictor such as Urbanization in your model having a different effect in females than in males, the interaction term will uncover this, without any loss of statistical power. The main thing to be aware of when fitting an interaction is that the main effect of the variables involved are then each conditional on the other variable being at zero (or at it's refernce level in the case of the categorical variable such as sex)

My model with sex is where I am confused...How do I account for sex as a random effect when there is an interaction? Should I not account for sex as a random effect?

Sex would never be a random effect. It does not make sense as a random intercept because there are only 2 levels of it (and can't really be considerd as a random factor for any other reason) and since it does not vary within individuals it does not make sense for it to be a random slope either.

Robert Long
  • 5,722
  • 5
  • 29
  • 50