decreasing coefficients in R's coefplot?

和自甴很熟 提交于 2019-12-11 06:39:14

问题


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

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