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?
(source: tarchomin.pl)
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.
Sign up to join this communityI 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?
(source: tarchomin.pl)
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.
Regarding the adequacy of the model, R-squared is indeed not a good statistic. Maybe you can try to compare two or more models using the AIC or BIC values.
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.