[R] Forcing the extrapolation of loess through the origin

Charles C. Berry cberry at tajo.ucsd.edu
Wed Apr 15 18:11:53 CEST 2009


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




More information about the R-help mailing list