How can I extract what the parameters that the loess function fitted for the polynomial function it uses, for a particular x of my data?
For example, in:
cars.lo <- loess(dist ~ speed, cars)
cars.lo
What did it fit for when cars.lo$x == 5 ?
Update: I want the parameters of the polynomial function, not the prediction (predict) of the loess.
I am asking for it to get an estimate of the slope开发者_运维技巧 in that point.
Thanks, Tal
I would compute the predicted values at x, x+eps, x-eps, and then fit a quadratic to the results. It's not very efficient in computer time, but if you haven't got to do it very often, it is very efficient in programmer time.
I would say
predict(cars.lo, data.frame(speed=5))
[1] 7.797353
I think you're going to be on your own for this one. I'd start by reading the references in lowess
, and then read the source for the C lowess
function. I'd recommend starting there instead of with loess
because it's an older and slightly simpler algorithm that you might find easier to adapt for your needs.
精彩评论