[R] Loess fit
David Winsemius
dwinsemius at comcast.net
Mon May 17 15:07:28 CEST 2010
On May 17, 2010, at 4:47 AM, Chintanu wrote:
> Hi,
>
> I wonder why my attempt to extend an existing loess fit to a new
> data set is
> producing error. I was trying the following:
>
> dat = read.csv(choose.files())
> x = dat[,2]; y = dat[,1]
> x.sort = sort(x)
That is not needed, furthermore, you don't even use it.
> y.loess = loess(y~x, span=0.75)
>
> # For testing the above fit with a new dataset:
>
> test = read.csv(choose.files()) # test data
> new_x = test [,1]; new_y = test[,2]
> new_x.sort = sort(new_x)
That sort is not needed.
> predicted <- predict(y.loess, newdata=new_x.sort)
>
> Am I doing any mistake ? Please correct me.
How can we tell when the inputs to these functions are not offered?
>
> I could see that though the rest of the values of "predicted" looks
> alright,
> however the first output of it is an NA !!
Perhaps outside the range of the loess function that was generated?
dat = matrix(rnorm(100), ncol=2); x = dat[,2]; y = dat[,1]
predicted <- predict(y.loess, newdata=x<-1:10 )
predicted
# [1] 0.1022490 0.2574732 NA NA NA
NA NA NA
# [9] NA NA
>
> Many thanks,
>
> Chintanu
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list