降低 R 的系数图中的系数?

decreasing coefficients in R's coefplot?

library(coefplot) 中的

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")

您需要设置sort = "magnitude":

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

默认排序是"natural",实际上是1:length(coef(mod1)).