Tuesday, April 23, 2013

Curve fitting in R


This is a simple example of a linear fit where a perfect fit is distorted with the help of a gaussian function. This data is then fit to a linear model. The most important factor determining the success of a fit is the model equation and the second most important factor is suitable starting values of the fit variables (a and b in this case). Further, if you assign the output to a variable called fit, values a and b can be extracted using:

fit < - nls
coef(fit)[1]
coef(fit)[2]

No comments:

Post a Comment