【发布时间】:2021-02-02 00:21:20
【问题描述】:
我的响应变量为比例,其值介于 0 和 1 之间,不包括 0 和 1。我想执行贝叶斯 logit 回归。我在 R 中使用包 arm,并按照 Jon Starkweather 博士发布的 Bayesian Generalized Linear Models in R 中的示例进行操作。我想到的困难或困惑是,使用常客 glm 方法,我可以进行 beta 回归(并指定 logit 链接)。但是当谈到贝叶斯 glm 时,我不确定如何为这个比例数据指定链接函数,尤其是使用 arm 包中提供的例程以及上面引用的关于 Bayesglm 函数的论文中使用的例程。
我正在使用的改编代码如下:
#install.packages("arm")
library(arm)
Model<-bayesglm(y ~x1 + I(x1^2) + x2 + x3 + x4 + x5 + x6
+ x7 + x8 + x9,family = gaussian, data=mydata,prior.mean=0, prior.scale=Inf, prior.df=Inf)
summary(Model)
Call:
bayesglm(formula = y ~x1 + I(x1^2) + x2 + x3 + x4 + x5 + x6
+ x7 + x8 + x9, family = gaussian, data = panel1_neg, prior.mean = 0,
prior.scale = Inf, prior.df = Inf)
Deviance Residuals:
Min 1Q Median 3Q Max
-0.024267 -0.006407 -0.001379 0.006257 0.042012
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.046806 0.011057 4.233 5.16e-05 ***
x1 0.327205 0.084408 3.876 0.000191 ***
I(x1^2) -1.351503 0.395559 -3.417 0.000921 ***
x2 -0.333285 0.056133 -5.937 4.30e-08 ***
x3 0.074882 0.029916 2.503 0.013949 *
x4 0.012951 0.003231 4.009 0.000119 ***
x5 -0.053934 0.059021 -0.914 0.363042
x6 -0.082908 0.051511 -1.610 0.110690
x7 -0.019248 0.068604 -0.281 0.779623
x8 -0.012700 0.002549 -4.981 2.68e-06 ***
x9 0.006289 0.002575 2.442 0.016382 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 0.0001288981)
Null deviance: 0.032699 on 109 degrees of freedom
Residual deviance: 0.012761 on 99 degrees of freedom
AIC: -660.64
Number of Fisher Scoring iterations: 7
所以我的问题是,如何在 Bayesglm 函数中指定一个 logit 链接?如果响应变量是二进制的,我可以指定family=binomial(link=logit)。
非常感谢任何帮助。
【问题讨论】:
-
不确定
bayesglm,但rstanarmhas a Beta regression implementation。