降低R系数的系数?

时间:2016-10-22 22:50:26

标签: r regression linear-regression lm coefplot

来自coefplot

library(coefplot)有一个变量decreasing,当设置为TRUE时,系数应按降序绘制

但是,当我运行一个玩具示例时:

data(tips, package = "reshape2")
mod1 <- lm(tip ~ day + sex + smoker, data = tips)
coefplot.glm(mod2, decreasing = TRUE)

系数不按降序排列。

我错过了什么?

编辑我失踪了sort = "magnitude"。但是,这不适用于multiplot

data(tips, package = "reshape2")
mod1 <- lm(tip ~ day + sex + smoker, data = tips)
mod2 <- lm(tip ~ day + sex + smoker + size, data = tips)
multiplot(mod1, mod2, decreasing = TRUE, sort = "magnitude")

1 个答案:

答案 0 :(得分:2)

您需要设置sort = "magnitude"

coefplot(mod1, decreasing = TRUE, sort = "magnitude")

enter image description here

默认排序是“自然”,实际上是1:length(coef(mod1))