From ripley at stats.ox.ac.uk  Mon Feb 21 20:59:27 2011
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 21 Feb 2011 19:59:27 +0000 (GMT)
Subject: [Rd] Anomaly in [.terms
In-Reply-To: <1298316714.27061.25.camel@punchbuggy>
References: <1298316714.27061.25.camel@punchbuggy>
Message-ID: <alpine.LFD.2.02.1102211956370.17303@gannet.stats.ox.ac.uk>

>From the NEWS for 2.13.0-to-be

       \item \code{drop.terms} and the \code{[} method for class
       \code{"terms"} no longer add back an intercept.  (Reported by
       Niels Hansen.)

so it has been fixed, just not rolled out yet.

On Mon, 21 Feb 2011, Terry Therneau wrote:

> This arose when working on an addition to coxph, which has the features
> that the X matrix never has an intercept column, and we remove strata()
> terms before computing an X matrix.  The surprise: when a terms object
> is subset the intercept attribute is turned back on.
>  My lines 2 and 3 below were being executed just before a call to
> model.frame.  The simple solution was of course to do them in the
> opposite order so I am not waiting on a "fix".
>  Not to mention that I am not sure a fix is required, though I was
> surprised.
>    Terry T.
>
>
> tmt1131% R
>
> R version 2.12.0 (2010-10-15)
> Copyright (C) 2010 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
>> test <- terms(Surv(time, status) ~ age + strata(ph.ecog),
> +    specials='strata')
>
>> attr(test, 'intercept') <- 0  #turn off intercept
>> test <- test[-2]   #remove strata
>
>> test
> Surv(time, status) ~ age
> attr(,"variables")
> list(Surv(time, status), age)
> attr(,"factors")
>                   age
> Surv(time, status)   0
> age                  1
> attr(,"term.labels")
> [1] "age"
> attr(,"specials")
> attr(,"specials")$strata
> NULL
>
> attr(,"order")
> [1] 1
> attr(,"intercept")
> [1] 1
> attr(,"response")
> [1] 1
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Anomaly in [.terms
Prof Brian Ripley