簡體   English   中英

如何在 r 中添加第二個隨機變量

[英]how to add a second random variable in mixed effects model in r

我想使用lme4::lmer

lmer(minpH ~ vetg + `VET EIWIT ratio` +(1|proefcode), data = phase_data_compleet)
lmer(minpH ~ vetg + `VET EIWIT ratio` +(1|cow), data = phase_data_compleet)

這兩個代碼確實可以單獨工作,但我想要一個proefcodecow都在同一個 model 中的代碼。 我已經嘗試了幾件事,比如(1|proefcode, cow)(1|proefcode + cow) ,這些都不起作用。 我收到下一條錯誤消息:

Error: unexpected ',' in "lmer(minpH ~ vetg + `VET EIWIT ratio` +(1|cow,"

Error: Invalid grouping factor specification, cow + experiment In addition: Warning message: In Ops.factor(cow, experiment) : ‘+’ not meaningful for factord

我究竟做錯了什么??

提前致謝

回答

lmer(minpH ~ vetg + `VET EIWIT ratio` + (1|proefcode) + (1|cow), data = phase_data_compleet)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM