A setting to subjectively adjust random effect variance in R package glmmTMB?

huangapple go评论74阅读模式
英文:

A setting to subjectively adjust random effect variance in R package glmmTMB?

问题

根据我对频率派层次模型的初步理解,似乎在似然函数中内置了一种惩罚机制,以防止随机效应对数据进行过度拟合,而是将它们“收缩”到一个组的平均值附近。

显然,有时模型师可以调整这种惩罚机制,以反映他们认为在组之间的随机效应应该具有更多/更少方差,而不是使用似然函数的默认设置所达到的。

在R中的glmmTMB中,是否有此选项?是否有可调整以调整随机效应方差的设置/参数?

英文:

From my layman understanding of frequentist hierarchical models, there is some penalty mechanism built into the likelihood function, that prevents the random effects from overfitting to the data and instead ‘shrinks’ them towards a group mean.

Apparently, this penalty mechanism can sometimes be adjusted by the modeller to reflect their belief that there should be more/less variance between groups’ random effects than is achieved with the likelihood function’s default setting.

Is this an option with glmmTMB in R? Is there a setting/parameter than can be adjusted to regulate the variance attributed to random effects?

答案1

得分: 2

Yes, you can set the random effects variance using the map argument to specify which model parameters should be fixed rather than estimated (and start to specify their values).

To illustrate, start by fitting the model (a model with only a single random effects variance, for simplicity) to see what the data (+ assumptions) say the variance "should" be:

library(glmmTMB)
data("sleepstudy", package = "lme4")
m1 <- glmmTMB(Reaction ~ Days + (1|Subject), sleepstudy)
VarCorr(m1)
Conditional model:
 Groups   Name        Std.Dev.
 Subject  (Intercept) 36.012  
 Residual             30.895  

Now suppose we think the model has (for some reason) overestimated the among-subject variance, i.e. the subject intercepts "should" be more tightly grouped.

We need to know that the random effects are parameterized on a log-SD scale, and that the relevant parameter is called theta.

m2 <- update(m1, 
             map = list(theta = factor(NA)), 
             start = list(theta = log(10)))

Check that this worked:

Conditional model:
 Groups   Name        Std.Dev.
 Subject  (Intercept) 10.000  
 Residual             37.248  

You could look at the fixed effects and their SEs etc. to see how this choice affects the rest of the model.

英文:

Yes, you can set the random effects variance to whatever you want by using the map argument to specify which model parameters should be fixed rather than estimated (and start to specify their values).

To illustrate, start by fitting the model (a model with only a single random effects variance, for simplicity) to see what the data (+ assumptions) say the variance "should" be:

library(glmmTMB)
data(&quot;sleepstudy&quot;, package = &quot;lme4&quot;)
m1 &lt;- glmmTMB(Reaction ~ Days + (1|Subject), sleepstudy)
VarCorr(m1)
Conditional model:
 Groups   Name        Std.Dev.
 Subject  (Intercept) 36.012  
 Residual             30.895  

Now suppose we think the model has (for some reason) overestimated the among-subject variance, i.e. the subject intercepts "should" be more tightly grouped.

We need to know that the random effects are parameterized on a log-SD scale, and that the relevant parameter is called theta (there is a little bit of this information in the "Mapping" section of the covstruct vignette).

m2 &lt;- update(m1, 
             map = list(theta = factor(NA)), 
             start = list(theta = log(10)))

(You don't have to use update() - you could have fitted the model from scratch with these arguments.) Check that this worked:

Conditional model:
 Groups   Name        Std.Dev.
 Subject  (Intercept) 10.000  
 Residual             37.248  

You could look at the fixed effects and their SEs etc. to see how this choice affects the rest of the model.

huangapple
  • 本文由 发表于 2023年5月7日 19:18:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76193593.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定