Guanyuan Shuai
Guanyuan Shuai

Reputation: 1

How to define random effects in the linear mixed effects model?

I read a paper which applied linear mixed-effects model for data analysis. I am confused about defining random effects in the equations.

First, how to define a combined random effect, such as 𝜀𝑓𝑖𝑒𝑙𝑑−𝑠𝑡𝑎𝑏𝑖𝑙𝑖𝑡𝑦 where 𝑓𝑖𝑒𝑙𝑑 indicates plot number and 𝑠𝑡𝑎𝑏𝑖𝑙𝑖𝑡𝑦 indicates somewhat classification results. Second, how to include random effects in the slope term, such as intercept + slope * (var1 + random effect) + residuals

I do not know how to write code to represent this equations.

I expect an expression of these equations.

Upvotes: 0

Views: 123

Answers (1)

Nafis S.
Nafis S.

Reputation: 314

Like Nate mentioned, the lme4 package will do all that you'd need. Their vignette here will have the examples for your answer, particularly section 2.2.

Simple REs can be written using (1 | group) which will add a group-specific intercept estimated, and a random effect on the intercept varying by group for the fixed effect x let's say, can be written as (1 + x | group).

Upvotes: 0

Related Questions