从GAM/BAM模型中计算有条件和边际R2
我有一个使用MGCV软件包的BAM
函数计算得出的广义添加剂模型。我在模型中有两个随机效应,有5个固定效果,其中一种是平滑的。 R2很高(见下文),我有兴趣知道这是否是由随机效应以及固定效果在解释差异中所扮演的角色的驱动。
我以前通过计算条件和边缘R2值来对GLMM进行此操作。有没有一种方法可以使用伽玛?特别是使用MGCV的BAM函数的一种?
deg_test1 <- bam(deg ~ SE_score + s(ri,bs="ad") + sex + species + year +
s(code, bs = 're') + s(station, bs = 're'),
family=nb(), data=node_dat, na.action = "na.fail", discrete = TRUE)
> summary(deg_test1)
Family: Negative Binomial(41687141.289)
Link function: log
Formula:
deg ~ SE_score + s(ri, bs = "ad") + sex + species + year +
s(code, bs = "re") + s(station, bs = "re")
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.06071 0.10751 -0.565 0.57232
SE_score -0.30396 0.15245 -1.994 0.04618 *
sexM 0.17797 0.09329 1.908 0.05643 .
speciesSilvertip Shark 0.58195 0.09445 6.161 7.24e-10 ***
year2015 -0.07197 0.05307 -1.356 0.17508
year2016 -0.11550 0.05927 -1.949 0.05131 .
year2017 -0.18810 0.06467 -2.908 0.00363 **
year2018 -0.43988 0.07953 -5.531 3.19e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(ri) 6.029 7.228 21.651 < 2e-16 ***
s(code) 83.744 133.000 8.133 0.001792 **
s(station) 43.302 62.000 15.196 0.000659 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.836 Deviance explained = 95.7%
fREML = 76757 Scale est. = 1 n = 82210
I have a generalised additive model calculated using the bam
function from the mgcv package. I have two random effects in the model and 5 fixed effects, one of which is smoothed. The R2 are quite high (see below) and I'm interested to know if this is being driven by the random effects and how much of a role the fixed effects play in explaining the variance.
I've previously done this on GLMM by calculating the conditional and marginal R2 values. Is there a way of doing this with a GAMM? Specifically one using the bam function from mgcv?
deg_test1 <- bam(deg ~ SE_score + s(ri,bs="ad") + sex + species + year +
s(code, bs = 're') + s(station, bs = 're'),
family=nb(), data=node_dat, na.action = "na.fail", discrete = TRUE)
> summary(deg_test1)
Family: Negative Binomial(41687141.289)
Link function: log
Formula:
deg ~ SE_score + s(ri, bs = "ad") + sex + species + year +
s(code, bs = "re") + s(station, bs = "re")
Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.06071 0.10751 -0.565 0.57232
SE_score -0.30396 0.15245 -1.994 0.04618 *
sexM 0.17797 0.09329 1.908 0.05643 .
speciesSilvertip Shark 0.58195 0.09445 6.161 7.24e-10 ***
year2015 -0.07197 0.05307 -1.356 0.17508
year2016 -0.11550 0.05927 -1.949 0.05131 .
year2017 -0.18810 0.06467 -2.908 0.00363 **
year2018 -0.43988 0.07953 -5.531 3.19e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df F p-value
s(ri) 6.029 7.228 21.651 < 2e-16 ***
s(code) 83.744 133.000 8.133 0.001792 **
s(station) 43.302 62.000 15.196 0.000659 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.836 Deviance explained = 95.7%
fREML = 76757 Scale est. = 1 n = 82210
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论