2
我正在嘗試建立一個GLMM,但我有問題表達R與glmer
分層數據結構。我的數據結構如下:模型規格與glmer
y (dependent variable);
visit (L1: nested independent variable);
year (L2: nested independent variable);
site (L3: independent variable);
其中visit
嵌套在year
,這是嵌套在site
(即有可能達到每年5人次,其中可能有長達10年的數據,每個站點)。
我感興趣的year
在y
的效果,同時也希望把site
作爲隨機效應(即攔截和斜坡[同期]通過網站而異)。
我用下面的命令:
model <- glmer(y ~ year + (year | site) + (visit|year),
family=poisson, data=data)
有我正確表達的模式?