[R] loess.control extrapolation

Kang, Zhuang Zhuang.Kang at moodys.com
Tue Apr 22 16:58:53 CEST 2014


Dear r-help,

What exactly the extrapolation in loess does by using suface="direct"? I tried to dig into stats:::simpleLoess and even the C/fortan code, but find it's real difficult to read through them. 

A toy example is below, I would appreciate if anyone to show me how to (closely enough)  replicate the value of extrapolation.

Thanks!


# a toy example with extrapolation in loess
xx2<-as.data.frame(cbind(c(1,2,3,4,5,6,7,8,9,10,11),c(3,5,6,7,8,9,8,8,NA,NA,NA)))
plot(xx2,type="b",col=2)
ll<-loess(V2~V1,data=xx2,control=loess.control(surface="direct"),degree=2)
xx2p<-predict(ll,xx2)
plot(xx2,type="b",ylim=c(0,15))
lines(xx2$V1,xx2p,type="p",col=2)

# spline can't exactly replicate the extrapolation
zz<-spline(xx2$V1[1:8],xx2p[1:8],xout=c(9,10,11),
           method="fmm")
zz$y-xx2p[9:11]
# not the same.. difference is:
#           9          10          11 
# 0.004405272 0.055746248 0.244225235



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

The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Thank you. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.




More information about the R-help mailing list