From therneau at mayo.edu  Mon Feb 18 15:25:36 2013
From: therneau at mayo.edu (Terry Therneau)
Date: Mon, 18 Feb 2013 08:25:36 -0600
Subject: [Rd] Small suggestion for termplot
Message-ID: <512239E0.7090303@mayo.edu>

Brian,
   I used termplot(..., plot=FALSE) recently in R-devel: works like a charm.  Thanks much 
for the update.

   Our in-house "gamterms" function, which this obviates, would also return the "constant" 
attribute from the underlying predict(..., type="terms") call.  I have occasionally found 
this useful, and so it would be a worthwhile addition to termplot.  Currently
       fit <- coxph(Surv(time, status) ~ pspline(age) + sex + ns(wt.loss), data=lung)
       zed <- termplot(fit, se=TRUE, plot=FALSE)

returns a list with components zed$age, zed$sex, zed$wt.loss.  The constant could be added 
as another element of the list or as an attribute, I don't have an opinion either way so 
have not suggested a patch.  You may have a reason for preferring one or the other.  
Clearly this is not critical for version 3.0 release.

   I sent this to you since you impliemented the plot=FALSE change, cc to the list in case 
someone else is appropriate.

   For those on the list, the recent change has three nice features:
      a. Use of predict(.., type='terms') is a nuisance because the result is in data set 
order rather than x order, a lines() call becomes a scribble.  This has reduced each term 
to the set of unique x values, in order, just what you need for a plot.
      b. In the coxph example above I use plot(zed$age$x, exp(zed$age$y), log='y') to get 
a better y-axis label.  For all the developers, this is a nice way to deflect requests for 
yet-another-plotting-option addition to termplot.
     c. Easy to overlay results from two separate fits.

Terry T.



[Rd] Small suggestion for termplot
Terry Therneau