Help with Linear Mixed effects model formulas

6 次查看(过去 30 天)
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!

回答(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?

Community Treasure Hunt

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

Start Hunting!

Translated by