Very nice example. I particularly like the way to automatically label the plot with the coefficient of the regression. I have used it in an study I am doing on F1 races. Thanks a lot! ]]>

What about if you have two different datasets that have differnt variables and you need all the variables to be in your regression, how would you do it?

I tired cbind function but when I run my regression, I had same names for all of the varialbles that are in my regrssion.

Thanks again

Hisham Alhawal

What if you want to use your own defined fitted model which includes more than 1 input variable instead of the geom_smooth?

(i.e. myfit = lm(y ~ x + z + d + x:d, mydata)

Is there a patch or equivalent function that allows using “myfit” in geom_smooth instead of formula = …. ?

]]>ggplotRegression <- function (fit, jit=FALSE) {

require(ggplot2)

if(jit){

fit$model[,1] <- jitter(fit$model[,1])

fit$model[,2] <- jitter(fit$model[,2])

}

ggplot(fit$model, aes_string(x = names(fit$model)[2], y = names(fit$model)[1])) +

geom_point() +

stat_smooth(method = "lm", col = "red") +

labs(title = paste("Adj R2 = ",signif(summary(fit)$adj.r.squared, 5),

"Intercept =",signif(fit$coef[[1]],5 ),

" Slope =",signif(fit$coef[[2]], 5),

" P =",signif(summary(fit)$coef[2,4], 5)))

}

I have problem to plot dose-response curves from a create model of class “drm” from a “drc” package using “ggplot”.

do you have any tips?

Thanks,

Danilo

]]>