set.seed(12345)
data_to_plot <- data.frame(x1 = rep(c(0, 25, 50, 100, 200, 400, 600), 10)) %>%
dplyr::mutate(AUC = x1*rlnorm(length(x1), 0, 0.3),
x2 = x1*stats::rlnorm(length(x1), 0, 0.3),
Response = (15 + 50*x2/(20+x2))*stats::rlnorm(length(x2), 0, 0.3))
gg <- ggplot2::ggplot(data = data_to_plot, ggplot2::aes(x = AUC, y = Response)) +
ggplot2::geom_point() +
xgx_geom_smooth(method = "nls",
method.args = list(formula = y ~ E0 + Emax* x / (EC50 + x),
start = list(E0 = 15, Emax = 50, EC50 = 20) ),
color = "black", size = 0.5, alpha = 0.25)
gg
mod <- stats::nls(formula = Response ~ E0 + Emax * AUC / (EC50 + AUC),
data = data_to_plot,
start = list(E0 = 15, Emax = 50, EC50 = 20))
predict.nls(mod)
predict.nls(mod, se.fit = TRUE)
predict.nls(mod,
newdata = data.frame(AUC = c(0, 25, 50, 100, 200, 400, 600)),
se.fit = TRUE)
predict.nls(mod,
newdata = data.frame(AUC = c(0, 25, 50, 100, 200, 400, 600)),
se.fit = TRUE, interval = "confidence", level = 0.95)
predict(mod,
newdata = data.frame(AUC = c(0, 25, 50, 100, 200, 400, 600)),
se.fit = TRUE, interval = "confidence", level = 0.95)
Run the code above in your browser using DataLab