[R] Problem with lm
John Fox
jfox at mcmaster.ca
Thu Oct 26 16:47:46 CEST 2000
Dear Isabelle,
R and S-Plus have different default options for constructing contrasts
(columns of the model matrix) from factors. For S-Plus:
> options("contrasts")
$contrasts:
factor ordered
"contr.helmert" "contr.poly"
For R:
> options("contrasts")
$contrasts
unordered ordered
"contr.treatment" "contr.poly"
By changing the contrasts option you should be able to get R and S-Plus to
agree. Help in R and S-Plus provides additional information about contrast
codings.
I hope that this helps,
John
At 10:22 AM 26/10/2000 +0200, you wrote:
>Hello Everybody,
>
>I have a problem with the output of lm.
>In fact, when I compare the R output and the Splus output, the results
>appears to be different :
>
>I have a dataframe with 5 factors , 16 rows and a response.
>First, I tried to fit this response to a linear model :
>lm(rep~(A+B+C+D+E),data).
>The results beetween SPlus and R are different.
>
>In a second time, I tried a new fit : lm(rep~(A+B+D+E+A:B),data).
>The estimation of the main effects in the model are the same as the one
>obtained for the first fit for Splus,
>and are different for R.
>
>Here an exemple :
>
>
>On R: On Splus
>
> lm(rep~(A+B+C+D+E),data)
> -> Intercept 12.6297 12.5573
> A
> 0.0391 0.0195
> B
> -0.0073 -0.0036
> C
> 0.0443 0.0221
> D
> -0.0321 -0.016
> E
> -0.18887 -0.0944
>
> lm(rep~(A+B+D+E+A:B),data) -> Intercept 12.7937 12.5573
> A
> -0.2445 0.0195
> B
> -0.2910 -0.0036
> D
> -0.03213 -0.016
> E
> -0.18887 -0.0944
> A:B
> 0.5672 0.1418
>
>Can someone explain what happens with these fitting procedure.
>
>Thanks
>
>
>Isabelle Zabalza-Mezghani
>
>
>
>
>--
>Isabelle Zabalza-Mezghani Tel : 01 47 52 61 99
>Institut Français du Pétrole E-mail : isabelle.zabalza-mezghani at ifp.fr
>1-4 Av. Bois Preau - Bat Lauriers
>92852 Rueil Malmaison Cedex, France
>
________________________________
John Fox
Department of Sociology
McMaster University
email: jfox at McMaster.ca
web: www.socsci.mcmaster.ca/jfox
________________________________
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list