[R] covariates in lm
mrufino@cmima.csic.es
mrufino at cmima.csic.es
Fri May 14 16:54:51 CEST 2004
Dear R list,
I have been trying to do a linear model, extracting the effect of a
covariate.... and the results do not match, when I do it with other programs
(e.g. minitab).... so it is obvious that I was doing something wrong.
Whan I do it with minitab, I have this results: (sector is a factor and depth
is the covariate):
Source DF Seq SS Adj SS Adj MS F P
sector 6 9.0605 2.9989 0.4998 1.21 0.297
depth 1 34.2072 11.9973 11.9973 29.16 0.000
sector*depth 6 1.5364 1.5364 0.2561 0.62 0.712
Error 578 237.7830 237.7830 0.4114
Total 591 282.5871
If I do with R, I have been trying everything it occurrs to me and looked
everywhere and I could not obtain the same results and nothing is clear to
me... (I am so sorry... probably it is lack of statistical knowledge):
If I do:
> anova(lm(Expr1~depth*sector))
Analysis of Variance Table
Response: Expr1
Df Sum Sq Mean Sq F value Pr(>F)
depth 1 38.2 38.2 92.76 <2e-16 ***
sector 6 5.1 0.9 2.07 0.055 .
depth:sector 6 1.5 0.3 0.62 0.712
Residuals 578 237.8 0.4
I am simply fitting a crossed anova, or because depth is continuos ... what is
it doing?
then, as it was not right, I went to look in the manuals, and in 'an
introduction to R' states:
y ~ A + x Single classification analysis of covariance model of y, with classes
determined by A, and with covariate x. Is it like this?
> anova(lm(Expr1~sector+depth)) #I don't think so...
But I interpreted this as a additive model... and besides it did not work as
well, so I tried what a friend recomended, i.e. x:z, whereas we are extacting
the effect of x (covariate) on y... but it does not work as well...
> anova(lm(Expr1~sector+depth+depth:sector)) # Would it be like this?
Analysis of Variance Table
Response: Expr1
Df Sum Sq Mean Sq F value Pr(>F)
sector 6 9.1 1.5 3.67 0.0014 **
depth 1 34.2 34.2 83.15 <2e-16 ***
sector:depth 6 1.5 0.3 0.62 0.7124
Residuals 578 237.8 0.4
-
or like: anova(lm(Expr1~depth:depth*sector))
I am lost... in the other times I just did with minitab, but I realy wanted to
do it with R... can someone give me some lights?
Is it very difficult to do it with R?
Sorry for the long and messy email,
thank you very much in advance,
Marta
More information about the R-help
mailing list