[R] Linear Models with mean as Intercept.
Ghislain Vieilledent
ghislainv at gmail.com
Thu Jun 30 15:35:30 CEST 2005
Dear advanced statisticians,
*******Objectif********
I try to set up linear models with mean as intercept:
Answer: y
Variable: x, as factor of two modalities: x(1), x(2).
I would like to have a model as:
y = mean(y)+A(i)+residuals,
with i in (1,2) and A(1) coefficient for x(1) and A(2) coefficient for x(2).
*******Trials in R*******
## Firstly:
I write in R:
>Model<-lm(y~x,Data)
>summary(Model)
...
I've got the coefficients for:
- the intercept (x(1) as been choosen) that we can call B(1)
- the second modality: x(2) that we can call B(2)
If I have well understood we have for the model and predictions:
if x(1): y=B(1)
if x(2): y=B(1)+B(2)
which is quite different as y=mean(y)+A(i)
## Secondly
I tried to skip the intercept
>Model2<-lm(y~0+x,Data)
>summary(Model2)
...
I've got the coefficients for:
- the first modality: x(1) that we can call C(1)
- the second modality: x(2) that we can call C(2)
And the model and predictions, if I'm right, are:
if x(1): y=C(1)
if x(2): y=C(2)
******* Questions ***********
How can I obtain a predictive model y=mean(y)+A(i) ?
Is it possible to settle mean(y) as intercept?
Thanks for your help.
Ghislain V., retarded statistician.
More information about the R-help
mailing list