Does something like this do what you want: data(ethanol, package='lattice') fit1 <- loess(NOx ~ E, data=ethanol, span=.6)
predfun <- function(x){ tmp.df <- data.frame(E=x) predict(fit1, tmp.df) } integrate(predfun, 0.6, 1.2) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Shirin Safa > Sent: Tuesday, July 01, 2008 2:28 PM > To: stephen sefick > Cc: r-help@r-project.org > Subject: Re: [R] Fitting a curve to data > > no this is not what I want. > I was using "loess" function or smooth.spline. > but For loess I don't know how would I be able to get the integral. > > > On 7/1/08, stephen sefick <[EMAIL PROTECTED]> wrote: > > > > ?lm > > lm(x[,1]~x[,2]) > > > > On Tue, Jul 1, 2008 at 2:28 PM, Shirin Safa > <[EMAIL PROTECTED]> wrote: > > > >> Hi > >> > >> I have a set of data like this: > >> > >> *Time of Day* *Pct of Daily Volume* 9:45 7.50% 10 6.25% 10:15 > >> 4.45% 10:30 4.80% 10:45 4.45% 11:00 4.20% 11:15 2.50% 11:30 2.30% > >> 11:45 2.25% 12:00 2.45% 12:15 2.60% 12:30 2.00% 12:45 2.05% 13:00 > >> 2.40% 13:15 1.90% 13:30 3.10% 13:45 2.90% 14:00 2.80% 14:15 2.50% > >> 14:30 3.40% 14:45 4.40% 15:00 5.40% 15:15 4.00% 15:30 4.70% 15:45 > >> 6.20% 16:00 8.50% > >> > >> I want to fit a curve to the data and get the best > function fitted, > >> therefore I can calculate the integral of the function. > >> How can I do that? > >> > >> Thanks, > >> Shirin > >> > >> [[alternative HTML version deleted]] > >> > >> ______________________________________________ > >> R-help@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >> > http://www.R-project.org/posting-guide.html<http://www.r-project.org/ > >> posting-guide.html> and provide commented, minimal, > self-contained, > >> reproducible code. > >> > > > > > > > > -- > > Let's not spend our time and resources thinking about > things that are > > so little or so large that all they really do for us is > puff us up and > > make us feel like gods. We are mammals, and have not exhausted the > > annoying little problems of being mammals. > > > > -K. Mullis > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.