Reputation: 321
I would like to plot the dose response curve using ggplot
but when I do so it looks very different.
Is it possible to plot the curve with ggplot
as it looks exactly when it is polotted using plot
function from base R?
My second question about the drm model
summary:
Which parameter is more reflective of the binding: b, c, d, or e?
library(drm)
library(ggplot2)
test_data <- data.frame(Conc = c(0.0004882812, 0.001953125 ,0.0078125, 0.03125 ,0.125 ,0.5),
Response = c(1.616017 ,1.165835, 0.5783709, 0.3440007, 0.2668585, 0.2336709))
## plot drm model
model_drm <- drm(Response ~ Conc, data=test_data,
fct=LL.4())
summary(model_drm)
plot(model_drm)
## now using ggplot
ggplot(test_data, aes(x = Conc, y = Response )) +
geom_point() +
stat_smooth(method = "drm",
method.args = list(
fct = LL.4()),se = FALSE)
Model fitted: Log-logistic (ED50 as parameter) (4 parms)
Parameter estimates:
Estimate Std. Error t-value p-value
b:(Intercept) 1.15894518 0.08339821 13.896 0.005138 **
c:(Intercept) 0.24398009 0.01385086 17.615 0.003207 **
d:(Intercept) 1.81356338 0.05324814 34.059 0.000861 ***
e:(Intercept) 0.00261968 0.00020635 12.695 0.006148 **
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error:
0.01758151 (2 degrees of freedom)
EDIT: Adding the log transformation leads to that the curve is not drawn anymore:
ggplot(test_data, aes(x = Conc, y = Response )) +
geom_point() +
stat_smooth(
method = "drm",
method.args = list(
fct = LL.4()
),
se = FALSE
)+
scale_x_continuous(trans="log10")
Upvotes: 1
Views: 991
Reputation: 1
ggplot(test_data, aes(x = Conc, y = Response )) +
geom_point() +
geom_line(aes(y = predict(model_drm))) +
scale_x_log10()
Upvotes: 0
Reputation: 270448
The X axis needs to be log10 scaled. Also we can reuse the calculation of the model already done.
ggplot(cbind(test_data, fit = fitted(model_drm)), aes(x = Conc, y = Response )) +
geom_point() +
geom_line(aes(y = fit)) +
scale_x_continuous(trans = "log10")
Upvotes: 1