# fit nonlinear regression model to data

I was wondering how can I best fit nonlinear regression model to this data, using an R package.

How can I check if model is good fitted since $$R^2$$ value is not returned in most functions for nonlinear models?

• What makes you think this data fits a nonlinear function and what function do you think that is? To me it looks pretty much like a horizontal line with a couple of outliers are 0. – John Jun 4 '14 at 15:02
• @John: Might as well partially fit an under-damped harmonic oscillation (hyperphysics.phy-astr.gsu.edu/hbase/oscda.html) or similar function. – Aleksandr Blekh Oct 26 '14 at 2:59

I am not terribly familiar with R but I believe the standard way to perform nonlinear regression is using the nls function. Since you do not say what specific model you are trying to fit to the data, I cannot help you any further. But maybe this small tutorial will help.
As I mentioned in my comment, one possible parametric solution that the data might fit could be an under-damped harmonic oscillation or similar function: http://hyperphysics.phy-astr.gsu.edu/hbase/oscda.html. In terms of non-parametric solutions, I agree with @joaoFaria's answer, but I'd like to extend it a little. You could use nls or optim R functions from the standard stats package: http://cran.r-project.org/doc/manuals/r-release/R-intro.html#Nonlinear-least-squares-and-maximum-likelihood-models.
In addition to the suggested use of AIC and BIC statistics as analytic fit criteria, you also may be interested in regression fit visualization, using, for example, R package visreg (http://cran.r-project.org/web/packages/visreg), which supports both linear and some nonlinear models.