groupkm                package:Design                R Documentation

_K_a_p_l_a_n-_M_e_i_e_r _E_s_t_i_m_a_t_e_s _v_s. _a _C_o_n_t_i_n_u_o_u_s _V_a_r_i_a_b_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     Function to divide 'x' (e.g. age, or predicted survival at time
     'u' created by 'survest') into 'g' quantile groups, get
     Kaplan-Meier estimates at time 'u' (a scaler), and to return a
     matrix with columns 'x'=mean 'x' in quantile, 'n'=number of
     subjects, 'events'=no. events, and  'KM'=K-M survival at time 'u',
     'std.err' = s.e. of log-log K-M.  Confidence intervals are based
     on  log-log S(t). Instead of supplying 'g', the user can supply
     the minimum number of subjects to have in the quantile group ('m',
     default=50). If 'cuts' is given (e.g.
     'cuts=c(0,.1,.2,...,.9,.1)'), it overrides 'm' and 'g'. Calls
     Therneau's 'survfit.km' to get Kaplan-Meiers estimates and
     standard errors.

_U_s_a_g_e:

     groupkm(x, Srv, m=50, g, cuts, u, 
             pl=FALSE, loglog=FALSE, conf.int=.95, xlab, ylab,
             lty=1, add=FALSE, cex.subtitle=.7, ...)

_A_r_g_u_m_e_n_t_s:

       x: variable to stratify

     Srv: a "Surv" object - n x 2 matrix containing survival time and
          event/censoring 1/0 indicator.  Units of measurement come
          from the "units" attribute of the survival time variable. 
          "Day" is the default. 

       m: desired minimum number of observations in a group 

       g: number of quantile groups 

    cuts: actual cuts in 'x', e.g. 'c(0,1,2)' to use [0,1), [1,2]. 

       u: time for which to estimate survival 

      pl: TRUE to plot results 

  loglog: set to 'TRUE' to plot 'log(-log(survival))' instead of
          survival 

conf.int: defaults to '.95' for 0.95 confidence bars.  Set to 'FALSE'
          to suppress bars. 

    xlab: if 'pl=TRUE', is x-axis label.  Default is 'label(x)' or name
          of calling argument 

    ylab: if 'pl=TRUE', is y-axis label.  Default is constructed from
          'u' and time 'units' attribute. 

     lty: line time for primary line connecting estimates 

     add: set to 'TRUE' if adding to an existing plot 

cex.subtitle: character size for subtitle. Default is '.7'.  Use
          'FALSE' to suppress subtitle. 

     ...: plotting parameters to pass to the plot and errbar functions 

_V_a_l_u_e:

     matrix with columns named 'x' (mean predictor value in interval),
     'n' (sample size in interval), 'events' (number of events in
     interval), 'KM' (Kaplan-Meier estimate), 'std.err' (standard error
     of log-log 'KM')

_S_e_e _A_l_s_o:

     'survfit.km', 'errbar', 'cut2', 'Surv', 'units'

_E_x_a_m_p_l_e_s:

     n <- 1000
     set.seed(731)
     age <- 50 + 12*rnorm(n)
     cens <- 15*runif(n)
     h <- .02*exp(.04*(age-50))
     d.time <- -log(runif(n))/h
     label(d.time) <- 'Follow-up Time'
     e <- ifelse(d.time <= cens,1,0)
     d.time <- pmin(d.time, cens)
     units(d.time) <- "Year"
     groupkm(age, Surv(d.time, e), g=10, u=5, pl=TRUE)
     #Plot 5-year K-M survival estimates and 0.95 confidence bars by 
     #decile of age.  If omit g=10, will have >= 50 obs./group.

