[R] [R]Intercept in model formulae
tlumley at u.washington.edu
Wed Jan 22 19:46:06 CET 2003
On Wed, 22 Jan 2003, sadok walid wrote:
> I'm a new user of R and I'm trying to make a linear model from this kind of
>  16.87 19.93 25.85 20.94 17.06 19.49 19.93 25.45 27.74 20.15 25.81
> 21.06 17.17 20.03 25.50 27.79 20.44 16.88 19.93 25.79
>  0.80 1.27 2.22 1.32 0.90 1.18 1.84 2.41 2.97 1.25 2.07 1.41 1.14 1.66
> 2.59 3.51 1.53 0.81 1.26 2.30
> I want to be able to force the line of the model(mymodel<-lm(y~z)) to pass
> through the origin (zero) and the line of the model(mymodel<-lm(y~x)) to
> pass through 10 as an x-intercept.
> For the first case i have used the (y~x-1) syntax, but the linear model
> returned a regresssion that didn't pass trough the points (with a higher
> Rsq than expected).
It works for me
gives a line nicely through the points. The fact that the Rsq is higher
than expected may be a defect of the expectations. Rsq is often high
for models with no intercept because the null model is that the mean of y
> For the second case, i did not find a solution yet..
It's the same as the first case, and that's about the only way to do it.
though I think it looks neater written as
More information about the R-help