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 -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20001026/e7876bfe/attachment.html
>>>>> "isabelle" == isabelle Zabalza-Mezghani <isabelle.zabalza-mezghani at ifp.fr> writes:isabelle> Hello Everybody, I have a problem with the output of lm. In isabelle> fact, when I compare the R output and the Splus output, the isabelle> results appears to be different : isabelle> I have a dataframe with 5 factors , 16 rows and a response. isabelle> First, I tried to fit this response to a linear model : isabelle> lm(rep~(A+B+C+D+E),data). The results beetween SPlus and R isabelle> are different. isabelle> In a second time, I tried a new fit : isabelle> lm(rep~(A+B+D+E+A:B),data). The estimation of the main isabelle> effects in the model are the same as the one obtained for the isabelle> first fit for Splus, and are different for R. isabelle> Here an exemple : ...omitted... isabelle> Can someone explain what happens with these fitting isabelle> procedure. It's because your "A",.. are factors, and the default contrasts (for non-ordered factors) are different in R from those in S-plus (on purpose!): R uses "treatment" contrasts by default (intuitive to most users) S-plus has "helmert" ones " " (neat for orthogonality reasons, somewhat hard to interpret) See ?contrasts (and read Venables & Ripley ..) isabelle> Thanks isabelle> Isabelle Zabalza-Mezghani (and then, the whole stuff once more, with <HTML> tags .. Isabelle, please re-configure your E-mail program to *NOT* send html, at least not to mailing lists ...) Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._