[R] lm Help!!

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Apr 12 12:20:03 CEST 2000


> To: Kenneth Cabrera <krcabrer at epm.net.co>
> From: Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk>
> Date: 12 Apr 2000 11:23:09 +0200
> 
> Kenneth Cabrera <krcabrer at epm.net.co> writes:
> 
> > Hi, everybody!!
> >
> > How can I calculate the Type III ss, as defined by SAS, for a linear 
regresion?
> 
> Like this:
> 
> > drop1(lm1, test="F")
> Single term deletions

My belief is that does not work with models with interactions, which is
where the Type III notation comes into its own (mess).

> options(contrasts=c("contr.helmert", "contr.poly"))
> example(warpbreaks)
> drop1(fm1)
Single term deletions

Model:
breaks ~ wool + tension + wool:tension
             Df Sum of Sq    RSS    AIC
<none>                    5745.1  264.0
wool:tension  2    1002.8 6747.9  268.7

> drop1(fm1, . ~ .) # as suggested by Bill Venables
Single term deletions

Model:
breaks ~ wool + tension + wool:tension
             Df Sum of Sq    RSS    AIC
<none>                    5745.1  264.0
wool          1     450.7 6195.8  266.1
tension       2    2034.3 7779.4  276.4
wool:tension  2    1002.8 6747.9  268.7

looks as if it does work in R (we know it works in S-PLUS, as Bill found
out when trying to do the opposite).  However, watch out as

> drop1.default(fm1, . ~ .)
Single term deletions

Model:
breaks ~ wool + tension + wool:tension
             Df    AIC
<none>          264.02
wool          0 264.02
tension       0 264.02
wool:tension  2 268.71

does respect the hierarchy, and is probably what drop1.lm should have
given.  (Looks like I did copy one of the S errors, probably deliberately, when 
I wrote drop1.*.)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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