2

Is there anybody facing the same as I am when running the command multiplot from Rpackage coefplot?

Even for the example:

data(diamonds)
model1 <- lm(price ~ carat + cut, data=diamonds)
model2 <- lm(price ~ carat + cut + color, data=diamonds)
model3 <- lm(price ~ carat + color, data=diamonds)
multiplot(model1, model2, model3)

I´m now getting the below error:

Error in get(x, envir = this, inherits = inh)(this, ...) : 
attempt to apply non-function

Any hint?

Fábio Salles
  • 345
  • 4
  • 14
  • 1
    maybe inconsistencies between `coefplot` and the newest version of `ggplot` - I had trouble even installing `coefplot` with `ggplot2` version 2.0.0 installed ... – Ben Bolker Jan 07 '16 at 22:01

1 Answers1

4

This answer is a bit tangential, but I have found the slightly more recent combination of the broom and dotwhisker packages to be useful - broom is the back end (converting models to "tidy" data frames of coefficients) and dotwhisker is the front end (creating plots via a fairly thin ggplot2 layer)

library(ggplot2)
library(dotwhisker)
library(broom)

update: re-installed dotwhisker v 0.2.0.3, this appears to work:

dwplot(list(model1,model2,model3))

You can also dwplot(list(m1=model1,m2=model2,m3=model3)) if you want to pick different model names on the fly.

Alternatively, for finer control you can construct the full data frame yourself:

mList <- list(carat_cut=model1, carat_cut_color=model2,
              carat_color=model3)
library(plyr)
## extract tidy data frames and combine them ...
mFrame <- ldply(mList,tidy,conf.int=TRUE,.id="model")

Now you can just do

dwplot(mFrame)
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453