[R] Best fitted curve

andrewcd andrewcd at gmail.com
Sun Oct 28 16:47:00 CET 2012


Looking at that data, it looks like the two species respond differently to
GDD.  "Fitting a curve" means first defining and then fitting a model that,
once fit, has fitted values that will give you the curve that you wold like
to draw.

The simplest would be a series regression with interaction terms:

weight_i = a + b1(gdd) + b2(species) + b3(gddxspecies) + b4(gdd^2) +
b5(gdd^2 x species) .. more polynomials.. + e_i

Better might be a "generalized additive model" where the continuous
variables (both GDD and the GDD-species interaction) are replaced by smooth
terms that are estimated nonparametricaly.  The package here is 'mgcv', and
the routine is 'gam'.  

The problems here are two: 
1. GAMs are complicated stats.  Learning how to do them right is an
investment.
2.  I don't think that the gam package yet gives functionality to put two
smooth fits onto one plot, as you have.  If you go this route and figure out
how to plot more than one GAM fit on a plot, please let me know how you did
it.



--
View this message in context: http://r.789695.n4.nabble.com/Best-fitted-curve-tp4647692p4647703.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list