I am novice at R studio. I'm trying to fit a sigmoidal curve for this data
x <- c(0, 0.19, 0.3, 0.4, 0.52, 0.65, 0.78, 0.9, 1, 1.5, 2, 3)
y <- c(0, 0.001131392946767, 0.001429213070191, 0.001695405556196, 0.008619063174144, 0.00970100252551, 0.014973553352495, 0.022978522580874, 0.038357458205673, 0.045039437163441, 0.052570608708667, 0.050651474312204)
Even after reading a lot online, I still can't figure out how to set up the fitting.
fit <- nls(y~max(y)*x^n/k^n+x^n, start=list(n=4, k=1))
When I run the fit, it gives me a singular gradient error. Anybody can help? :(
Use a self-starting model:
plot(y ~ x)
help("SSlogis")
fit <- nls(y ~ SSlogis(x, Asym, xmid, scal), data = data.frame(x, y))
summary(fit)
curve(predict(fit, newdata = data.frame(x = x)), add = TRUE)
Your proposed model seems problematic because it doesn't fit the upper asymptote. Your proposal of using max(y)
doesn't take into account uncertainties in a sensible way. I also suspect you might miss a parenthesis in the formula.