[R] Problem with lm

Martin Maechler maechler at stat.math.ethz.ch
Thu Oct 26 14:50:24 CEST 2000


>>>>> "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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list