survkit                package:event                R Documentation

_W_e_i_b_u_l_l _a_n_d _C_o_x _M_o_d_e_l_s _w_i_t_h _R_a_n_d_o_m _E_f_f_e_c_t_s

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

     'survfit' was written in Fortran by Dr. V. Ducrocq (INRA, France:
     vincent.ducrocq@dga.jouy.inra.fr) and Dr. J. Soelkner (Vienna:
     soelkner@mail.boku.ac.at) to fit Weibull and Cox proportional
     hazards models with random effects for very large data sets. This
     is a cut-down version adapted to R. The full Survival Kit,
     including the manual, can be obtained from
     http://www.boku.ac.at/nuwi/popgen.

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

     survkit(times, censor=NULL, ccov=NULL, tvcov=NULL,
             strata=NULL, id=NULL, model="Weibull", baseline=FALSE,
             residuals=FALSE, survival=NULL, svalues=NULL, valrho=NULL,
             constraints=NULL, impose=NULL, dist=NULL, random=NULL,
             estimate=NULL, moments=FALSE, rule=NULL, pedigree=NULL,
             integrate=NULL, jointmode=FALSE, within=NULL, converge=1.e-8,
             iterlim=100)

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

   times: Vector of times (events, right-censoring, change in
          time-varying covariate, left-truncation).

  censor: Corresponding vector of censoring indicators. 1: event; 0:
          censored; -1: change of time-varying covariate; -2:
          left-truncation time.

    ccov: Model formula for time-constant covariates. These may have
          one value per individual or one per time. Because of the way
          factor variables are handled, interactions must be coded as
          new variables.

   tvcov: Model formula for time-varying covariates with one value per
          time. There can only be one change-point per individual.
          Again, interactions must be coded as new variables.

  strata: A factor variable specifying stratification. With the Weibull
          model, different intercepts and power parameters are
          calculated for each stratum. For the Cox model, a different
          baseline curve is fitted.

      id: A variable giving individual identification numbers (starting
          at one). If not supplied, all times are assumed to refer to
          different individuals.

   model: Weibull or Cox model, or Kaplan-Meier estimates.

baseline: If TRUE, the baseline values are calculated for the Cox
          model.

residuals: If TRUE, calculate residuals (only for Cox model).

survival: Calculate values of the survival function at 'quantiles',or
          at 'equal'ly-spaced, 'specific', or 'all' observed times.

 svalues: A vector of quantile values (between 0 and 100), spacing and
          maximum for equally-spaced, or specific times for 'survival'.

  valrho: A fixed value of the Weibull power parameter if it is not to
          be estimated.

constraints: By default, the category of each factor variable with the
          'largest' number of events is taken as baseline. Other
          options are 'none' which gives values around the mean and
          'find'. See also, 'impose'.

  impose: A list of a vector of variable names and a corresponding
          vector of their baseline category numbers. Any factor
          variables not given will have their first category as
          baseline.

    dist: The distribution of the random effect: loggamma, normal, or
          multivariate (normal).

  random: A factor variable specifying the random effect.

estimate: One fixed value for the mode of the variance of the random
          effect or three values if the mode is to be estimated: lower
          and upper bounds, and precision.

 moments: Estimate the first three moments of the random effect as well
          as the mode.

    rule: For the multivariate normal random effect, the genetic
          relationships: 'usual', 'mgs' (sire or father model), or
          'sire.dam' (father and mother).

pedigree: A matrix with four columns required for the multivariate
          normal random effect, containing the individual id, the sex,
          the father's category, and the mother's category.

integrate: A factor variable to integrate out as the log-gamma random
          effect in a Weibull model. (Not available for the Cox model.)

jointmode: If TRUE, the log-gamma variance parameter is estimated
          simultaneously with the other parameters using the
          information in 'estimate'. Otherwise, a fixed value, given in
          'estimate' is assumed.

  within: A second factor variable (within the 'integrate' variable) to
          integrate out.

converge: The convergence criterion, by default 1.e-8.

 iterlim: Maximum number of iterations.

_A_u_t_h_o_r(_s):

     V. Ducrocq, J. Soelkner, and J.K. Lindsey

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

     'coxre', 'kalsurv'.

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

     # y <- trunc(rweibull(20,2,20))
     y <- c(6,22,43,16,7,6,15,35,10,9,18,34,7,13,10,17,14,19,11,13)
     # cens <- rbinom(20,1,0.9)
     cens <- c(1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1)
     id <- gl(2,10)
     # x <- rnorm(20)
     x <- c(1.82881379,1.06606868,0.70877744,-0.09932880,-0.60626148,-0.75371046,
       0.23884069,0.51199483,-0.73060095,-0.93222151,2.27947539,-0.73855454,
      -0.36412735,-0.89122114,-0.05025962,-0.10001587,1.11460865,-1.87315971,
      -0.11280052,-1.6880509)
     # Kaplan-Meier estimates
     survkit(y, censor=cens, model="Kaplan")
     # null Weibull model
     survkit(y, censor=cens)
     # one time-constant covariate
     survkit(y, censor=cens, ccov=~x)
     # stratify
     survkit(y, censor=cens, ccov=~x, strata=id)
     # estimate a normal random effect
     survkit(y, censor=cens, ccov=~x, random=id, dist="normal",
             estimate=c(0.1,10,0.01), moments=TRUE)
     # try a fixed value for the normal random effect
     survkit(y, censor=cens, ccov=~x, random=id, dist="normal",
             estimate=1.3)
     # estimate a log-gamma random effect
     survkit(y, censor=cens, ccov=~x, random=id, dist="loggamma",
             estimate=c(0.1,10,0.01))
     # estimate a log-gamma random effect by integrating it out
     survkit(y, censor=cens, ccov=~x, dist="loggamma", estimate=1.4,
             integ=id, jointmode=TRUE)
     # try a fixed value of the log-gamma random effect, integrating it out
     survkit(y, censor=cens, ccov=~x, dist="loggamma", estimate=1,
             integ=id)
     #
     # Cox model with one time-constant covariate
     print(z <- survkit(y, censor=cens, ccov=~x, model="Cox", residuals=TRUE,
             baseline=TRUE))
     residuals(z)
     baseline(z)
     # obtain the quantiles
     print(z <- survkit(y, censor=cens, ccov=~x, model="Cox",
             survival="quantiles", svalues=seq(10,90,by=10)))
     survival(z)
     # estimate a log-gamma random effect
     survkit(y, censor=cens, ccov=~x, model="Cox", random=id,
             dist="loggamma", estimate=c(0.1,10,0.01))

