Is it appropriate to calculate odds ratios from random effects glmm
output?
about the data:
- grown (binary): whether flower grows over a certain height (TRUE/FALSE)
- fertilizer(factor): whether fertilizer was used (yes, no, unknown)
- flowertype (factor): 5 types of flowers
Here's my code:
model <- glmmTMB(grown ~ fertilizer+ (1 + fertilizer | flowertype),
data = flower_data, family = "binomial")
random_effects <- as.data.frame(ranef(model))
flower_types <- unique(random_effects$grp)
parameter_type <- unique(random_effects$term)
odds_ratios <- data.frame(flowertype = flower_types,
ParameterType = parameter_type,
OddsRatio = exp(random_effects$condval))
My code works, I just want to make sure that I'm doing the right thing
broom.mixed::tidy(model, effects = "ran_vals") |> transform(estimate = exp(estimate))
? $\endgroup$