【发布时间】:2021-01-20 12:30:58
【问题描述】:
我正在使用finalfit 包处理带有二进制结果变量的病例对照研究数据集。
当使用 finalfit 函数(它结合了逻辑回归的 glm 函数时,在结合超过 11 个解释性二元变量时我会遇到麻烦。
这是一个例子
library(dplyr)
library(finalfit)
#An example of the dataset:
o <- c(0,1,1,1,1,0,0,1,1,0,1,0) #would be the outcome variable
exp1 <- c(0,0,1,0,1,1,0,0,1,0,1,1)
exp2 <- c(1,0,0,0,0,1,1,0,1,0,0,1)
exp3 <- c(0,1,1,1,1,1,1,1,1,0,0,1) #would be the explanatory variable and so on....
data<-as.dataframe(o,exp1,exp2,exp3) #and the other variables
explanatory = c("exp1", "exp2", "exp2")
dependent = 'o'
data %>%
finalfit(dependent, explanatory)
当使用少于 11 个解释变量运行代码时,它可以正常工作,但如果解释变量超过 11 个则崩溃。 错误是 Tibble 列必须具有兼容的大小。 * 大小 5:现有数据。 * 大小 4:位置 5 的列。ℹ 仅回收大小为 1 的值。
【问题讨论】:
标签: r