我试图用nls模型来绘制我的数值并用曲线拟合它们。但我得到了一个错误,说我的变量没有起始值。
conc <- c(1.83, 3.66, 7.32, 14.65, 29.30, 58.59, 117.19, 468.75, 937.5, 1875, 3750)
avg <- c(0.02, 0.03, 0.05, 0.09, 0.23, 0.40, 0.60, 0.79, 0.98, 0.82, 1)
DataSet <- data.frame(conc, avg)
ggplot(DataSet, aes(x = conc, y = avg)) +
geom_point() +
scale_x_log10() +
stat_smooth(aes(x=conc, y = avg), method = "nls",
formula = "avg~Emax*(conc^Hill)/((EC50^Hill)+(conc^Hill))",
method.args=list(start=c(Emax = 1, EC50 = 100, Hill = 2)),
se = FALSE)
# Warning message:
# Computation failed in `stat_smooth()`:
# parameters without starting value in 'data': avg, conc 发布于 2018-07-15 17:05:53
您需要在公式中调整x,因为scale_x_log10()已用于axis。因此,log10的逆(例如^10)应该用于公式中的x。
解决办法如下:
library(ggplot2)
ggplot(DataSet, aes(x = conc, y = avg)) +
geom_point() +
scale_x_log10() +
stat_smooth(method = "nls",
formula = y~Emax*((10^x)^Hill)/((EC50^Hill)+((10^x)^Hill)),
method.args=list(start=c(Emax = 1, EC50 = 100, Hill = 2)),
se = FALSE)

https://stackoverflow.com/questions/51350033
复制相似问题