[R] details about lm()

vincent@7d4.com vincent at 7d4.com
Mon Oct 10 17:38:38 CEST 2005


Uwe Ligges a écrit :

> vincent at 7d4.com wrote:
>> Sorry for my lack of knowledge, but will the above trick really force
>> the regression line to pass through P ?
>> adding (0,0) in this new system of coordinates isn't it equivalent to 
>> add P to the dataset in the original system ?
> 
> Well, you do not add that point, but transform the others:
> Say you have (let's make a very simple 1-D example) points P_i = (x_i, 
> y_i), and P = (x_0, y_0). Then calculate for all i:
>   P'_i = (x_i - x_0, y_i - y_0)
> Now you can calculate a regression without any Intercept by
>   lm(y ~ x - 1)
> You got the slope now and the Intercept is 0 so far for P'.
> After that, you can re-transform to get the real data's intercept:
>   Intercept = -(slope * x_0) + y_0

Thank you very much for the kind answer and for your time.
(I'll read that carefully and take my rule, pencil and R).
Vincent




More information about the R-help mailing list