[R] grouping scat1d/rug and plotting to 2 axes

Frank E Harrell Jr f.harrell at vanderbilt.edu
Mon Aug 27 23:27:30 CEST 2007


Mike wrote:
> Hi,
> 
> I'm wondering if anybody can offer a bit of  guidance on how to add a 
> couple of features to a plot. 
> 
> I'm using Frank Harrell's Design library to model some survival data in 
> R (2.3.1, windows platform).  I'm fairly comfortable with the survival 
> modeling in Design, but am still at a frustratingly low level of 
> competence when it comes to creating anything beyond simple plots in R.
> 
> A simplified version of the model is:
> 
> fit <- cph(Surv(survtime,deceased) ~ rcs(smw,4), 
> data=survdata,x=T,y=T,surv=T )
> 
> And the basic plot is:
> 
> plot(fit,smw=NA, fun=function(x) 1/(1+exp(-x)))

or plot(fit, smw=NA, fun=plogis).  But what does the logistic model have 
to do with the Cox model you fitted?  You can instead do plot(fit, 
smw=NA, time=1) to plot estimated 1-year survival prob.

> 
> I know that if I add
> 
> scat1d(smw)
> 
> I get a nice jittered rug plot of all values of the predictor smw on the 
> top axis.
> 
> What I'd like to do, however, is to plot on bottom axis the values of 
> smw for only those participants who are alive, and then on the top axis, 
> plot the values of smw for those who are deceased.  I'd appreciate any 
> tips as to how I might approach this.

That isn't so well defined because of variable follow-up time.  I would 
not get very much out of such a plot.

Frank

> 
> Thanks,
> 
> Mike Babyak
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list