Linear Mixed Model

Hi, I am having difficulties in running a mixed model. The question is like this:
A researcher observes variation in wing size in a beetle species in South-America and wants to know whether wing size is associated to altitude. He therefore collects and measures beetles along an altitudinal gradient on several mountains (at 6 different altitudes: 150m, 300m, 450m, 600m, 750m and 900m). At each altitude he samples 2 patches and collects 6 beetles in each patch. In total he samples 3 such mountains, thus 216 individuals in total. In addition, he determines the sex (male vs female) of each beetle. Finally, he repeats the entire sampling design in Africa for the same species.

The researcher asks you to analyze his data set and to report to him whether altitude affects wing length in this species or not.

So the fixed effects are altitude, sex and continent;
random effects: Patch, mountain.
The data is something like this:

So, I created the model like this:
bett.lmm<-lmer(length~altitude.f+sex+continent+(1|Patch:mountain)+(1|mountain), data=bett)

Am I correct about this?

Hi @limkahkheng! Welcome!

It sounds like you might be quoting from a problem set, textbook, or other class assignment. Unfortunately, posting verbatim text from an assignment is something we can't allow. Please read this: FAQ: Homework Policy

Here's the short version:

How to Ask a Homework Related Question:

  1. Do not ask verbatim copy-paste questions
  2. Explicitly mention the course you are taking.
  3. Try to make your question as close to a reproducible example (reprex) as you can. Preferably using the reprex package

Can you please edit your post to align better with these guidelines? If you just want to know whether you're specifying the model correctly, the most useful information is a list of the variables and the roles you want them to play in your model. The output of summary() and str() applied to your data frame could also be helpful (here's how to post code and console output here — screenshots are difficult to read!).

Determining whether you are interpreting the problem properly is honestly beyond the scope of this forum — only the person who wrote the problem can say for sure how they intended you to interpret it.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.