Magic incantations are good

March 7, 2010

Some people say magic incantations are bad.

But then, you find a code snippet — sorry, incantation — on Hadley Wickham’s web site, and find out how to plot that interaction effect graph you need.


Isn’t it pretty? The bare bones:

effectdf <- function(...) {
suppressWarnings(as.data.frame(effect(...)))
}


my.xlevels=list(x=seq(0,1,0.05), rol=c(TRUE,FALSE)
both2 <- effectdf("x*z", lm.mod,xlevels=my.xlevels)


fplot <- ggplot(mapping = aes(y = fit, ymin = lower, ymax = upper)
fplot %+% both2 + aes(x=x,group=z,color=z,fill=z) + geom_smooth(stat="identity")

If you want substance, the paper in which the graph features will be uploaded in a week's time, ready for the UK PSA in Edinburgh.

posted in Uncategorized by Chris

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org