问题
coefplot from library(coefplot) has a variable decreasing which when set to to TRUE the coefficients should be plotted in descending order
But when I run a toy example:
data(tips, package = "reshape2")
mod1 <- lm(tip ~ day + sex + smoker, data = tips)
coefplot.glm(mod2, decreasing = TRUE)
the coefficients aren't in descending order.
What am I missing?
EDIT I was missing sort = "magnitude". However, this doesn't work with 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:
You need to set sort = "magnitude":
coefplot(mod1, decreasing = TRUE, sort = "magnitude")
The default sorting is "natural", which is effectively 1:length(coef(mod1)).
来源:https://stackoverflow.com/questions/40197807/decreasing-coefficients-in-rs-coefplot