Re: [S] "-" doesn't work in "tree" formula

Bill Venables (wvenable@attunga.stats.adelaide.edu.au)
Fri, 13 Nov 1998 09:02:36 +1030


>>>>> "Samuel" == Samuel E Buttrey
<buttrey@sun10or.or.nps.navy.mil> writes:

> Hi. Here's a fascinating fact that bit me. In a formula for a
> "tree" model, using a "-" to exclude a column in the data frame
> doesn't work.

Yes, this is an apparent anomaly. It can be explained, I
suggest, by noting that the formula is not a *linear model*
formula, so the same operator rules are not guaranteed to apply.

With tree models you only need state which variables you want to
use and the tree formula deciphering function appears to treat
"+" and "-" interchangably, and does not care if you put the same
variable in twice.

> summary (tree (y ~ . - y1, data = tt))

This is where "-" for exclusion would indeed be convenient. The
curious feature to me is that "." does work, not that "-" does
not. The only half-way elegant way round it I have found is to
use things like

tm <- tree(y ~ ., data = tt[, -match("y1", names(tt))])

As I said, at best only half-way elegant!

Bill Venables

-- 
_________________________________________________________________
Bill Venables, Head, Dep't of Statistics,   Tel.: +61 8 8303 5418
               ^^^^ (but not for much longer!)
The University of Adelaide,                 Fax.: +61 8 8303 3696
South AUSTRALIA.     5005.   Email: Bill.Venables@adelaide.edu.au
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news