Skip to content
Prev 5677 / 398506 Next

truncated regressor

At 16:45 14/05/00 +0100, Brian D. Ripley wrote:
I am trying to understand this. The help for ?I says:

...
     To avoid this confusion, the function `I()' can be used to bracket
     those portions of a model formula where the operators are used in
     their arithmetic sense.  For example, in the formula `y ~ a +
     I(b+c)', the term `b+c' is to be interpreted as the sum of `b' and
     `c'.
...

which is clear to me: doing lm(y ~ a + I(b+c)) is similar to

	d <- b + c
	lm(y ~ a + d)

But what if the expression in I() is a logical? After playing a moment, I
found out that a formula can include a logical variable, and treats it as a
factor:
Call:
lm(formula = y ~ x < 25)

Coefficients:
(Intercept)       x < 25  
      78.24       -53.92
Call:
lm(formula = y ~ x > 25)

Coefficients:
(Intercept)       x > 25  
      24.32        53.92  


Is it worth adding a few lines in this help file on the use of logical
variables in formula? (also characters can be included but must be
converted into factors before)

Emmanuel Paradis
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._