I want to do a nonparametric regression. Im 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 dont have the same length.
In fact in m$fit and m$se.fit there are 3 values who dont have a
fitted value.
There is no predicted value when the dependant variable have a NA. The
synthase na.action=na.omit dont 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. Im 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 dont have the same length.
In fact in m$fit and m$se.fit there are 3 values who dont have a
fitted value.
There is no predicted value when the dependant variable have a NA. The
synthase na.action=na.omit dont 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]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html