[英]R return p-value from glm within cbind
统计数据和R noob想知道是否有一种方法可以将gl值中的p值添加到输出结尾,这是由以下命令产生的:
exp(cbind(OR = coef(mod1), confint(mod1)))
也许是这样的:
summary(mod1)$coefficients[,4]
我意识到这有点像一个“装饰性”问题,但它仍然会很方便。
谢谢
您可以保存摘要(mod1)的结果,然后使用coefficients
访问系数表。
您可以编写一个函数来完成整个过程...
OR.summary <- function(x){
# get the summary
xs <- summary(x)
# and the confidence intervals for the coefficients
ci = confint(x)
# the table from the summary object
coefTable <- coefficients(xs)
# replace the Standard error / test statistic columns with the CI
coefTable[,2:3] <- ci
# rename appropriatly
colnames(coefTable)[2:3] <- colnames(ci)
# exponentiate the appropriate columns
coefTable[,1:3] <- exp(coefTable[,1:3])
# return the whole table....
coefTable
}
一种更强大的方法是使用像rms
这样的包....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.