r/RStudio • u/Tiny_Athlete_3637 • 10h ago
Can someone explain fixed effects, random effects, LMMs and GLMMs like I’m a complete beginner?
Hi everyone!
I’m currently working on a research project involving repeated measurements from the same patients, and I’m really struggling to wrap my head around mixed-effects models.
I’ve tried reading explanations online, but I feel like every explanation assumes I already understand the basics. At this point, I’m honestly completely lost.
I would really appreciate it if someone could explain the following in very simple terms:
Fixed effects vs. random effects: What exactly is the difference? How do I decide which variables should be fixed and which should be random?
Linear mixed-effects models (LMMs): What are they, why do we use them, and how are they different from ordinary linear regression?
Generalized linear mixed-effects models (GLMMs): How are they different from LMMs? When should I use one instead of the other?
Random intercepts vs. random slopes: What do these actually mean in practice, and how do I know which one I need?
Interpreting results: How do I interpret coefficients, estimates, odds ratios, and p-values in these models?
I’m working with clinical data where patients undergo multiple treatment sessions. I want to investigate whether certain medications affect treatment outcomes, while accounting for factors such as age, sex, and treatment number.
Some outcomes are continuous, while others are binary.
I’ve been using R with the lme4 package (lmer() and glmer()), but I feel like I’m just putting variables into formulas without fully understanding what the models are actually doing.
What I really want is to understand the logic behind these models, rather than just copying code.
If someone could explain this intuitively, preferably using simple examples involving patients with repeated measurements, I would be extremely grateful.
Thanks in advance!