tags:

views:

104

answers:

3

Hi all,

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

+1  A: 

I would say

predict(cars.lo, data.frame(speed=5))
[1] 7.797353
gd047
oops - I'll rephrase - I want the fitted **polynomial parameters**, not the fitted value.
Tal Galili
Have you tried `str(summary(cars.lo))` ? Can you get any help there?
gd047
I did try it, that's why I am asking here :) (the output is complex, and I'd rather have someone's help). Thanks any way :)
Tal Galili
Take a look here. It seems it's not so straightforward. http://www.mail-archive.com/[email protected]/msg77935.html
gd047
Thanks gd047, I decided to ask in the R mailing list, and see if some of the "big guys" would lend a hand. BTW, in your website, notice that the left-right arrows of your "featured content" sliding windows are leading no-where. Consider removing them or adding content.Cheers,Tal
Tal Galili
+2  A: 

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.

Rob Hyndman
Thanks Rob,I thought of doing it this way but a senior statistician in my workplace said it would cause unstable results (compared to the polynomial fit that relies on many data points around x0) ...
Tal Galili
A: 

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.

hadley
Thanks Hadley. I feared this was the case. I'll go back to the client and see how important this is... Best,Tal
Tal Galili