From therneau at mayo.edu  Mon Feb 21 20:31:54 2011
From: therneau at mayo.edu (Terry Therneau)
Date: Mon, 21 Feb 2011 13:31:54 -0600
Subject: [Rd] Anomaly in [.terms
Message-ID: <1298316714.27061.25.camel@punchbuggy>

 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



[Rd] Anomaly in [.terms
Terry Therneau