使用brms实现多元Logistic Regression:响应变量相关性设置求助
关于brms多元Logistic回归的求助
我是brms的新用户,正在探索如何用brms进行多元Logistic回归。我拥有6个二分类响应变量,以及5个预测变量(1个连续变量、1个有序变量、3个二分类变量)。我知道可以使用bernoulli族进行建模,但当前的模型设定默认这6个响应变量相互独立,这与我使用多元回归的初衷相悖。我翻遍了brms的R文档也没找到替代方法,因此来向各位同行求助,万分感谢!
以下是复现问题的代码:
# Set seed for reproducibility set.seed(123) # Number of observations n <- 1000 # Generate predictors x1 <- rnorm(n, mean = 50, sd = 10) x2 <- sample(1:5, n, replace = TRUE) x3 <- rbinom(n, 1, 0.5) x4 <- rbinom(n, 1, 0.3) x5 <- rbinom(n, 1, 0.7) # Generate response variables y1 <- rbinom(n, 1, plogis(x1*0.02 + 0.3 + x2*0.1 + x3*0.5 + x4*0.4 + x5*0.6)) y2 <- rbinom(n, 1, plogis(x1*0.01 + 0.2 + x2*0.2 + x3*0.3 + x4*0.6 + x5*0.7)) y3 <- rbinom(n, 1, plogis(x1*0.03 + 0.1 + x2*0.3 + x3*0.4 + x4*0.5 + x5*0.2)) y4 <- rbinom(n, 1, plogis(x1*0.05 + 0.4 + x2*0.4 + x3*0.2 + x4*0.3 + x5*0.1)) y5 <- rbinom(n, 1, plogis(x1*0.02 + 0.6 + x2*0.1 + x3*0.7 + x4*0.8 + x5*0.9)) y6 <- rbinom(n, 1, plogis(x1*0.04 + 0.5 + x2*0.2 + x3*0.1 + x4*0.2 + x5*0.3)) # Combine predictors and response variables into a data frame data <- data.frame(x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, y6) # brms model model = brm(mvbind(y1,y2,y3,y4,y5,y6) ~ x1+x2+x3+x4+x5, data = data, family = bernoulli(link = "logit"))
系统信息
- 操作系统:Mac OS Monterey 12.4
- brms版本:2.19.0
内容的提问来源于stack exchange,提问作者some
相关产品推荐
相关产品推荐

