# Random versus fixed effects

**URL:** <https://forum.biobakery.org/t/random-versus-fixed-effects/9056>\
**Category:** MaAsLin\
**Created:** [September 11, 2026, 12:09pm UTC](https://forum.biobakery.org/t/random-versus-fixed-effects/9056 "2026-09-11T12:09:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rriudavets](https://avatars.discourse-cdn.com/v4/letter/r/bc8723/32.png) [@rriudavets](https://forum.biobakery.org/u/rriudavets)\
**Post date:** [September 11, 2026, 12:09pm UTC](https://forum.biobakery.org/t/random-versus-fixed-effects/9056/1 "2026-09-11T12:09:18Z")

</div>

Hello,

First of all, thank you so much for developing MaAsLin and for your continuous help to the community! I am using MaAsLin3 to analyze my metagenomics dataset and I am a bit unsure on how to proceed with the specification of my model.

My dataset contains 3 disease groups (control, disease\_group1, disease\_group2). Each participant in my study belongs to one of these groups, and each participant provided up to three samples (each one on separate days). I am interested in studying the differences between the three groups, especially in comparing controls to disease\_group1 and disease\_group2, and also disease\_group1 to disease\_group2.

As far as I understand, I should run the model using the formula `~ disease_group + covariates + (1 | participant_id)`, where covariates include variables like batch, ethnicity, diet, etc. However, when I do that I get no significant results at all. After reading the documentation in the package github repository, I found this part:

- `random_effects`: A vector of variable names to be included as random intercepts. **Random intercept models may produce poor model fits when there are fewer than 5 observations per group.** In these scenarios, per-group fixed effects should be used and subsequently filtered out. (See `strata_effects` as well.)
  - Random effects models are fit with `lmer` (linear) and `glmer` (logistic), and the significance tests come from `lmerTest` and `glmer` respectively.

As I have up to 3 samples per participant\_id, I thought this statement may apply to my case. So, I tried to specify the model as `~ disease_group + covariates + participant_id` and in this case I did get a bunch of significant results, many of which make sense biologically. I also tested using the `small_random_effects` option, but if I understand correctly that only applies to the logistic model part.

So, my questions are:

- In my setting, is it correct/appropriate to use participant\_id as a fixed effect?
- Since each participant will always have the same values for other covariates like ethnicity, diet, etc, should I skip them from the model specification when using participant\_id as a fixed effect?

Thank you so much for your help!

---

<div class="post-metadata">

**Author:** ![WillNickols](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/willnickols/32/3223_2.png) [@WillNickols](https://forum.biobakery.org/u/WillNickols)\
**Post date:** [September 12, 2026, 2:47am UTC](https://forum.biobakery.org/t/random-versus-fixed-effects/9056/2 "2026-09-12T02:47:42Z")

</div>

Hi,

1. Yes, it’s always valid to use participant ID as a fixed effect instead of random effect. People often try to use it as a random effect to get more power, but if you’re getting significant results with it as a fixed effect you’re probably in good shape. It’s worth checking the `small_random_effects` option since that’ll use the same fixed effect for logistic regression but apply the participant ID as a random effect in the linear regression. If you get the same results with participant ID as a fixed effect and with participant ID as a `small_random_effect`, you can probably use either model, but if you end up with quite different sets of significant features, it’s worth figuring out why.
2. Regardless of whether you use participant ID as a fixed or random effect, if there are other covariates that are always the same per participant ID, you can skip them in the model specification since they’ll be collinear with the participant ID (and therefore already controlled for with the participant ID).

Will
