[R] Curve Fitting Question - Newbie

Liaw, Andy andy_liaw at merck.com
Wed Jan 29 01:51:02 CET 2003


If you don't need the parameters in the curve, it seems like

library(modreg)
lines(supsmu(1:1000, foo.dat), lwd=3)

gives a very reasonable result.

HTH,
Andy

> -----Original Message-----
> From: C Grant [mailto:cgrant02589 at yahoo.com]
> Sent: Tuesday, January 28, 2003 6:39 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Curve Fitting Question - Newbie
> 
> 
> Hello, I have what should be an easy question. I'm a
> new r user and making the transition from menus to the
> command line so as to do batch processing of tons of
> data. One of my data streams needs to be detrended.
> It's a vector of numbers that follows a negative
> exponential decay. I need to fit a curve to it and use
> the residuals as an object. The data looks something
> like this:
> 
> foo.dat <- (0.83 * exp(-0.017 * 1:1000) + 0.5) +
> rnorm(1000,0,0.05)
> plot(foo.dat, type = "l")
> 
> That is an example the parameters for foo.dat change
> slightly. So, I need to fit a neg exponential curve to
> that type of data without specifying the parameters
> beforehand and save the residuals as an object. It
> will have to accomadate being in a loop.
> 
> How can I do this?
> 
> Regards, CG
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


------------------------------------------------------------------------------




More information about the R-help mailing list