[R] Predict with loess

From: Jouanin Celine <celine_jouanin_at_yahoo.fr>
Date: Tue 13 Jun 2006 - 18:37:31 EST

    I want to do a nonparametric regression. Iím using the function loess.

      The variable are  the year from 1968 to 1977 and the dependant variable is  a proportion P. The dependant variable have  missing value (NA). 
      The script is :
       
      year <- 1969:2002
      length(year) 

[1] 34
P <- c(NA,0.1,0.56,NA,NA,0.5,0.4,0.75,0.9, 0.98,0.2,0.56,0.7,0.89,0.3,0.1,0.45,0.46,0.49,0.78, 0.25,0.79,0.23,0.26,0.46,0.12,0.56,0.8,0.55,0.41, 0.36,0.9,0.22,0.1) length(P)
[1] 34
lo1 <- loess(P~year,span=0.3,degree=1) summary(lo1) yearCo <- 1969:2002 year_lo <- data.frame(year = yearCo ) length(year_lo)
[1] 34
mlo <- predict(loess(P~year,span=0.3,degree=1),new.data=year_lo,se=T) mlo$fit mlo$se.fit plot(year,P,type='o') lines(year,predict(loess(P~year,span=0.15,degree=1),new.data=year_lo, se=T,na.action=na.omit)$fit,col='blue',type='l') The message error indicates that x and y donít have the same length. In fact in m$fit and m$se.fit there are 3 values who donít have a fitted value. There is no predicted value when the dependant variable have a NA. The synthase na.action=na.omit donít seem to ignore the missing value, generating an error. What is the source, the solution to my problem? Thanks for the help Cťline I want to do a nonparametric regression. Iím using the function loess. The variable are the year from 1968 to 1977 and the dependant variable is a proportion P. The dependant variable have missing value (NA). The script is : year <- 1969:2002 length(year)
[1] 34
P <- c(NA,0.1,0.56,NA,NA,0.5,0.4,0.75,0.9, 0.98,0.2,0.56,0.7,0.89,0.3,0.1,0.45,0.46,0.49,0.78, 0.25,0.79,0.23,0.26,0.46,0.12,0.56,0.8,0.55,0.41, 0.36,0.9,0.22,0.1) length(P)
[1] 34
lo1 <- loess(P~year,span=0.3,degree=1) summary(lo1) yearCo <- 1969:2002 year_lo <- data.frame(year = yearCo ) length(year_lo)
[1] 34
mlo <- predict(loess(P~year,span=0.3,degree=1),new.data=year_lo,se=T) mlo$fit mlo$se.fit plot(year,P,type='o') lines(year,predict(loess(P~year,span=0.15,degree=1),new.data=year_lo, se=T,na.action=na.omit)$fit,col='blue',type='l') The message error indicates that x and y donít have the same length. In fact in m$fit and m$se.fit there are 3 values who donít have a fitted value. There is no predicted value when the dependant variable have a NA. The synthase na.action=na.omit donít seem to ignore the missing value, generating an error. What is the source, the solution to my problem? Thanks for the help Cťline __________________________________________________ [[alternative HTML version deleted]]

______________________________________________

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 13 18:41:39 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 13 Jun 2006 - 20:12:20 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.