MATLAB Answers

Help with Linear Mixed effects model formulas

2 ビュー (過去 30 日間)
Rorie Duncan
Rorie Duncan 2020 年 3 月 27 日
コメント済み: Rorie Duncan 2020 年 6 月 10 日
Hello,
I am new to Matlab and would like to fit a linear mixed effects model to some biological field data.
I have four predictors in (body_weight, avg_temp, sex, latitude, location). If my understanding is correct, sex (male/female) and location (any of 9 different locations) are grouping variables (latitude and avg_temp will vary according to location).
I have one response variable (wing_area).
My predictors and response are contained in a variable called ds (of the table class).
I have been instructed to use body_weight, avg_temp, sex and latitude as fixed effects. Location is my only random effect.
The code I am using so far is:
lme = fitlme(ds, 'wing_area ~ body_weight + avg_temp + sex + latitude + (1|location)');
My questions:
1) Does this syntax appropriately describe the model I am trying to develop?
2) Does it make sense that I am using avg_temp and latitude as fixed effects when they are dependent on location?
3) If so, do I need to somehow define these two fixed effects to be part of the grouping variable location? (I understand how to do this for random effects, i.e. ...(random_effect | group variable) but I'm not sure how to do this for fixed effects)
Thank you so much for any help you might be able to provide!

  0 件のコメント

サインインしてコメントする。

回答 (1 件)

Peng Li
Peng Li 2020 年 5 月 11 日
For statistical questions, the first thing we ask is what the hypothesis is.
From your equation, I guess you'd like to examine whether wing area differs across (some variable here I'm not sure), and you need to adjust for a couple of covariates (like sex, body weight, etc).
From model equation allows you to have location specific intercept--by (1|location).
And for sure that there would be many variables that vary depending on location. That is one argument that you use the mixed model (to better solve the violation re independence).
If your questions is whether wing area changes with the change of latitude, for example, you have a fixed slope (estimate corresponding to latitude) with your formula. If you think this is better to be changable depending on location, you can then allow a random variation along the average estimate of latitude. To do so, you can specify (latitude|location) in your formula (by default 1 is included so this is equivalent to (1+latitude|location)).
Does this make sense for you?

  1 件のコメント

Rorie Duncan
Rorie Duncan 2020 年 6 月 10 日
Thanks a lot for your reponse Peng Li. Yes, it does make sense.
Kind regards.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by