Re: R-alpha: lm ( formula ) : quadratic formula 'fails'

Bill Venables (bill@stats.ox.ac.uk)
Mon, 2 Dec 1996 14:05:20 GMT


Date: Mon, 2 Dec 1996 14:05:20 GMT
Message-Id: <199612021405.OAA04100@brunhilde.stats>
From: Bill Venables <bill@stats.ox.ac.uk>
To: maechler@stat.math.ethz.ch
Subject: Re: R-alpha: lm ( formula ) : quadratic formula 'fails'

Martin Maechler writes:

 >   From the students' exercises of  my class,
 >   I ask them to do  a quadratic fit through the origin
 >   (for a model:  W=distance V=speed  (traffic situation)):

(V = time would seem physically more reasonable to me, but that's
an orthogonal side issue.)

 >   This is how it works in  S :
 >
 >	     lm(W ~ V + V^2 -1)
 >
 >   Unfortunately, R 'simplifies the formula' by dropping the
 >   V^2 term.
 >
 >   R works alright if I use
 >
 >	     lm(W ~ V + I(V^2) -1)
 >			==   =

Of course S `simplifies the formula' too by replacing V^2 by
I(V^2) if V is not a factor (and removing it altogether if it
is), and if you want to use update on it, for example, this is
how you must refer to that term.  If you update with .~.-V^2, for
example, nothing changes.

I think the R protocol is preferable and I would oppose changing
it.  It emphasises that in linear model formulae the operators
are *formula* operators with a special meaning and not arithmetic
operators.  When students first get their fingers burnt this way
they should learn a valuable lesson.

Bill
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-