Reputation: 971
I am trying to use coefplot(), as described in this article: http://www.r-bloggers.com/visualization-of-regression-coefficients-in-r/
However, when I run that exact code, I get only one regression plotted, rather than 3. Here is a screenshot showing the exact code I have run, plus the output plot. https://i.sstatic.net/ezghR.png
I am really not sure what else to do. Your help would be much appreciated.
Upvotes: 1
Views: 1016
Reputation: 226522
I will point out that coefplot2
(my extension of coefplot
which has some nice features but still needs more work), available from R-forge, does this:
library(coefplot2)
coefplot2(list(M2,M1,M3),col=c("black","red","blue"),legend=TRUE)
Upvotes: 2
Reputation: 263391
The code for coefplot does not accept an argument for offset anymore. It's not in the documentation and its not in the formals list. You can make a version that does by modifying the code for coefplot:
Type coefplot2 return . Copy-paste the function to the command line and precede it with
coefplot2 <- # the rest of the pasted function should follow
then add voffset=0
to the formals list and change this line:
arrows(ci1, (1:k), ci2, (1:k), lty = lty[1], lwd = lwd[1], col = col,
To this
arrows(ci1, (1:k)+voffset, ci2, (1:k)+voffset, lty = lty[1], lwd = lwd[1], col = col,
And change the points line to:
points(cf , (1:k)+voffset, pch = pch, col = col)
Then hit enter and you should have a new coefplot2 function. Then this should work
coefplot2(M2, xlim=c(-2, 6) )
par(new=TRUE) # could not get the add=TRUE argument to work either.
coefplot2(M3, col="blue", xlim=c(-2, 6), voffset=0.4)
par(new=TRUE)
coefplot2(M1, col="red", xlim=c(-2, 6) , voffset=0.2)
Upvotes: 2