Skip to content

LOESS function Newton optimization

1 message · David Winsemius

#
On Jul 12, 2011, at 7:53 PM, KenjiPsyD wrote:

            
I don't see how that would be examining slopes.
> cars.lo <- loess(dist ~ speed, cars)
 > is.function( cars.lo)
[1] FALSE

If you want to make it a function, there is approxfun in the stats  
package.

car.fun <- approxfun(x=cars.lo$x, cars.lo$fitted)
plot(dist~speed, data=cars)
curve(car.fun, add=TRUE)

Some functions require that a function be offered that takes x as its  
argument.

 > car.fun(x=5)
Error in car.fun(x = 5) : unused argument(s) (x = 5)

If that is the case with your optimization routine then you can create  
one with:

 > car.funx <- function(x) car.fun(x)
 > car.funx(x=5)
[1] 8.095681