jimm-panse at gmx.de
2009-Apr-14 17:08 UTC
[R] Forcing the extrapolation of loess through the origin
Hi all, I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface="direct" for extrapolation. l1<-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface="direct")) In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R? Thanks in advance. Cheers, Torsten --
Bert Gunter
2009-Apr-14 17:30 UTC
[R] Forcing the extrapolation of loess through the origin
Below. Bert Gunter Genentech Nonclinical Biostatistics 650-467-7374 -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of jimm-panse at gmx.de Sent: Tuesday, April 14, 2009 10:08 AM To: r-help at r-project.org Subject: [R] Forcing the extrapolation of loess through the origin Hi all, I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface="direct" for extrapolation. l1<-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface ="direct")) In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R? -- No. Indeed, this appears to me to contradict the nature of loess as a locally adaptive fit. Bert Thanks in advance. Cheers, Torsten -- ______________________________________________ R-help at 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.
Stavros Macrakis
2009-Apr-14 18:15 UTC
[R] Forcing the extrapolation of loess through the origin
On Tue, Apr 14, 2009 at 1:08 PM, <jimm-panse at gmx.de> wrote:> I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface="direct" for extrapolation. > > l1<-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface="direct")) > > In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R?Well, you could always add lots of artificial data points x=0, y=0 ..., like this: l1<-loess(y1~x1,span=0.1,data.frame(x=c(rep(0,100),x1),y=c(rep(0,100),y1)),control=loess.control(surface="direct")) which will eventually drive f(0) to near 0, but surely that will create fitting artifacts. -s
Julian Burgos
2009-Apr-14 18:22 UTC
[R] Forcing the extrapolation of loess through the origin
Hi Torsten, If you are fitting a line, why are you using "loess"? Why not simply use "lm" to fit a regression line that goes through the origin? (i.e. with no intercept). Julian jimm-panse at gmx.de wrote:> Hi all, > > I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface="direct" for extrapolation. > > l1<-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface="direct")) > > In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R? > > Thanks in advance. > > Cheers, > Torsten > -- > > ______________________________________________ > R-help at 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. >
Charles C. Berry
2009-Apr-15 16:11 UTC
[R] Forcing the extrapolation of loess through the origin
On Tue, 14 Apr 2009, jimm-panse at gmx.de wrote:> Hi all, > > I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface="direct" for extrapolation. > > l1<-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface="direct")) > > In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R?Well, yes, but as Burt suggests it may not be sensible. There are several ways. For one, include a reflection of the (x,y) data into opposite quandrants as well as the original data. Something like l1<-loess( y ~ x , span=0.1, data.frame(x = c(-x1,x1), y = c(-y1,y1)), control=loess.control(surface="direct")) will force the prediction through the origin. (I corrected what seems to be as typo in your code, too.) Of course, if any( x < 0 ) it is hard to see how the substantive results would make any sense. HTH, Chuck> > Thanks in advance. > > Cheers, > Torsten > -- > > ______________________________________________ > R-help at 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. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901