Skip to content
Prev 333175 / 398506 Next

Fitting arbitrary curve to 1D data with error bars

Thanks, this was a useful pointer. Since the function I am trying to fit is exponential, I decided to use nls. And I was able to reproduce exactly the results and the plot in the URL I had posted. For future reference, here is the R code I wrote:


require("gplots")
xx <- 1:10
yy <- c(1.56,1.20,1.10,0.74,0.57,0.55,0.31,0.27,0.28,0.11)
dy <- c(0.02,0.02,0.20,0.03,0.03,0.10,0.05,0.02,0.10,0.05)
plotCI(xx,yy,uiw=dy,gap=0)
nlmod <- nls(yy ~ Alpha * exp(Beta * xx), start=list(Alpha=1, Beta=-1))
lines(xx, predict(nlmod), col = "blue")
wnlmod <- nls(yy ~ Alpha * exp(Beta * xx), start=list(Alpha=1, Beta=-1), weights=dy^-2)
lines(xx, predict(wnlmod), col = "red")


Thanks to everybody who responded,

e.
On 14 Nov 2013, at 11:34, Suzen, Mehmet wrote: