简体   繁体   English

使用Rstanarm计算二项式Logit中的边际效应的可信区间

[英]Calculating credible intervals for marginal effects in binomial logit using rstanarm

In this method for calculating marginal effects for a binomial logit using rstanarm, https://stackoverflow.com/a/45042387/9264004 在使用rstanarm计算二项式logit的边际效应的这种方法中, https: //stackoverflow.com/a/45042387/9264004

nd <- md
nd$x1 <- 0
p0 <- posterior_linpred(glm1, newdata = nd, transform = TRUE)
nd$x1 <- 1
p1 <- posterior_linpred(glm1, newdata = nd, transform = TRUE)
ME <- p1 - p0
AME <- rowMeans(ME)

Can intervals for the marginal effects be calculated by taking quantiles, like this: 边际效应的间隔可以通过分位数来计算,如下所示:

QME <- quantile(AME, c(.025,.25,.5,.75,.975))

or is there a more correct way to calculate a standard error for the effect? 还是有一种更正确的方法来计算效果的标准误差?

If you are interested in the posterior standard deviation of the average (over the data) "marginal" effect of changing x1 from 0 to 1, then it would be sd(ME) or possibly mad(ME) . 如果您对将x1从0更改为1的平均值(在数据上)的“边际”效应的后验标准偏差感兴趣,那么它将是sd(ME)或可能是mad(ME) But if you want quantiles, then call quantile . 但是,如果您需要分位数,请致电quantile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM