0
$\begingroup$

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

$\endgroup$
1
  • 1
    $\begingroup$ You might try broom.mixed::tidy(model, effects = "ran_vals") |> transform(estimate = exp(estimate)) ? $\endgroup$
    – Ben Bolker
    Commented May 8 at 0:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.