Eleni Rapsomaniki
2009-Feb-06 17:38 UTC
[R] Using subset in validate() in Design, what is the correct syntax?
Hi I am trying to understand how to get the validate() function in Design to work with the subset option. I tried this: ovarian.cph=cph(Surv(futime, fustat) ~ age+factor(ecog.ps)+strat(rx), time.inc=1000, x=T, y=T, data=ovarian) validate(ovarian.cph) #fine when no subset is used, but the following two don't work:> validate(ovarian.cph, subset=ovarian$ecog.ps==2)Error in order(c(1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, : argument lengths differ> validate(ovarian.cph, subset=ovarian[ovarian$ecog.ps==2,])Error in predab.resample(fit, method = method, fit = cox.fit, measure = discrim, : length of subset does not match # rows used in fit Any suggestions? Also, is it possible to use the subset option with calibrate as well? It would be good to be able to plot the cox fit vs. the KM fit for different age groups for example. Many many thanks! Eleni
Frank E Harrell Jr
2009-Feb-06 18:27 UTC
[R] Using subset in validate() in Design, what is the correct syntax?
Eleni Rapsomaniki wrote:> Hi > > I am trying to understand how to get the validate() function in Design > to work with the subset option. I tried this: > > ovarian.cph=cph(Surv(futime, fustat) ~ age+factor(ecog.ps)+strat(rx), > time.inc=1000, x=T, y=T, data=ovarian) > > validate(ovarian.cph) > #fine when no subset is used, but the following two don't work: > >> validate(ovarian.cph, subset=ovarian$ecog.ps==2) > Error in order(c(1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, : > argument lengths differ >> validate(ovarian.cph, subset=ovarian[ovarian$ecog.ps==2,])As stated in the documentation for predab.resample, subset should be a logical or integer vector specifying how to subset the data.> Error in predab.resample(fit, method = method, fit = cox.fit, measure = > discrim, : > length of subset does not match # rows used in fit > > Any suggestions? > Also, is it possible to use the subset option with calibrate as well? ItYes; predab.resample still does the work. Frank> would be good to be able to plot the cox fit vs. the KM fit for > different age groups for example. > > Many many thanks! > Eleni >-- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University