This happens when you have not strat variables in the model.
------------------------------ Frank E Harrell Jr Professor and Chairman School of Medicine Department of *Biostatistics* *Vanderbilt University* On Thu, Jun 2, 2016 at 10:55 AM, Steve Lianoglou <lianoglou.st...@gene.com> wrote: > Hello foks, > > I'm trying to plot the number of patients at-risk by setting the > `n.risk` parameter to `TRUE` in the rms::survplot function, however it > looks as if the numbers presented in the rows for each category are > just summing up the total number of patients at risk in all groups for > each timepoint -- which is to say that the numbers are equal in each > category down the rows, and they don't seem to be the numbers specific > to each group. > > You can reproduce the observed behavior by simply running the code in > the Examples section of ?survplot, which I'll paste below for > convenience. > > Is the error between the chair and the keyboard, here, or is this perhaps > a bug? > > =========== code =========== > library(rms) > n <- 1000 > set.seed(731) > age <- 50 + 12*rnorm(n) > label(age) <- "Age" > sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4))) > cens <- 15*runif(n) > h <- .02*exp(.04*(age-50)+.8*(sex=='Female')) > dt <- -log(runif(n))/h > label(dt) <- 'Follow-up Time' > e <- ifelse(dt <= cens,1,0) > dt <- pmin(dt, cens) > units(dt) <- "Year" > dd <- datadist(age, sex) > options(datadist='dd') > S <- Surv(dt,e) > > f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE) > survplot(f, sex, n.risk=TRUE) > =========== > > I'm using the latest version of rms (4.5-0) running on R 3.3.0-patched. > > === Output o sessionInfo() === > R version 3.3.0 Patched (2016-05-26 r70671) > Platform: x86_64-apple-darwin13.4.0 (64-bit) > Running under: OS X 10.11.4 (El Capitan) > > locale: > [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] rms_4.5-0 SparseM_1.7 Hmisc_3.17-4 ggplot2_2.1.0 > [5] Formula_1.2-1 survival_2.39-4 lattice_0.20-33 > > loaded via a namespace (and not attached): > [1] Rcpp_0.12.5 cluster_2.0.4 MASS_7.3-45 > [4] splines_3.3.0 munsell_0.4.3 colorspace_1.2-6 > [7] multcomp_1.4-5 plyr_1.8.3 nnet_7.3-12 > [10] grid_3.3.0 data.table_1.9.6 gtable_0.2.0 > [13] nlme_3.1-128 quantreg_5.24 TH.data_1.0-7 > [16] latticeExtra_0.6-28 MatrixModels_0.4-1 polspline_1.1.12 > [19] Matrix_1.2-6 gridExtra_2.2.1 RColorBrewer_1.1-2 > [22] codetools_0.2-14 acepack_1.3-3.3 rpart_4.1-10 > [25] sandwich_2.3-4 scales_0.4.0 mvtnorm_1.0-5 > [28] foreign_0.8-66 chron_2.3-47 zoo_1.7-13 > =========================== > > > Thanks, > -steve > > > -- > Steve Lianoglou > Computational Biologist > Genentech > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.