Display all comparisons for factor variables in R for lm or coxph

混江龙づ霸主 提交于 2019-12-25 03:45:18

问题


In R, the default method when using a factor variable in regression is to use contrasts. I.E we set a reference class, and then the results are reported as (factor) vs. reference.

For example, if we had 3 groups, and set 1 to be the reference group, then the results will be (2 vs 1) and (3 vs 1). But we don't get to see 3 vs 2. I know that you can get this by rerunning the regression and re-leveling with 2 as the reference class. But is there any way to get all comparisons in one line of code, instead of running two regression calls?

来源:https://stackoverflow.com/questions/33698979/display-all-comparisons-for-factor-variables-in-r-for-lm-or-coxph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!