Gabriel
Gabriel

Reputation: 33

Lowess smoothing in R that extract values given X

In R when I use lowess() and plot the smooth using line() function, am I able to extract the smoothed y value given any value of the x? How to do it, please? Thanks!

any alternative smoothing methods in R that I can extract a smoothed y-value given a specified x?

Upvotes: 1

Views: 733

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368409

If you switch from lowess to the newer loess that replaces it, then you get a predict method. From example(predict.loess):

cars.lo <- loess(dist ~ speed, cars)
predict(cars.lo, data.frame(speed = seq(5, 30, 1)), se = TRUE)   
# extrapolation
cars.lo2 <- loess(dist ~ speed, cars, control = loess.control(surface = "direct"))
predict(cars.lo2, data.frame(speed = seq(5, 30, 1)), se = TRUE)

Upvotes: 1

Related Questions