I want to add an installed function from GLM to ggplot . By default, it automatically creates a graph with the interaction. I am wondering if I can build a function created from a model without interaction. For instance,
dta <- read.csv("http://www.ats.ucla.edu/stat/data/poisson_sim.csv") dta <- within(dta, { prog <- factor(prog, levels=1:3, labels=c("General", "Academic", "Vocational")) id <- factor(id) }) plt <- ggplot(dta, aes(math, num_awards, col = prog)) + geom_point(size = 2) + geom_smooth(method = "glm", , se = F, method.args = list(family = "poisson")) print(plt)
gives a graph with the interaction, 
However, I need a graph from the model,
`num_awards` = ร0 + ร1*`math` + ร2*`prog` + error
I tried to do it this way
mod <- glm(num_awards ~ math + prog, data = dta, family = "poisson") fun.gen <- function(awd) exp(mod$coef[1] + mod$coef[2] * awd) fun.acd <- function(awd) exp(mod$coef[1] + mod$coef[2] * awd + mod$coef[3]) fun.voc <- function(awd) exp(mod$coef[1] + mod$coef[2] * awd + mod$coef[4]) ggplot(dta, aes(math, num_awards, col = prog)) + geom_point() + stat_function(fun = fun.gen, col = "red") + stat_function(fun = fun.acd, col = "green") + stat_function(fun = fun.voc, col = "blue") + geom_smooth(method = "glm", se = F, method.args = list(family = "poisson"), linetype = "dashed")
Withdrawal chart 
Is there an easy way in ggplot to do this efficiently?