

gettvc(rmutil)                               R Documentation

_F_i_n_d _t_h_e _m_o_s_t _r_e_c_e_n_t _v_a_l_u_e _o_f _a _t_i_m_e_-_v_a_r_y_i_n_g _c_o_v_a_r_i_a_t_e
_b_e_f_o_r_e _e_a_c_h _o_b_s_e_r_v_e_d _r_e_s_p_o_n_s_e _a_n_d _p_o_s_s_i_b_l_y _a_d_d _t_h_e_m _t_o _a
_l_i_s_t _o_f _o_t_h_e_r _t_i_m_e_-_v_a_r_y_i_n_g _c_o_v_a_r_i_a_t_e_s_.

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

     `gettvc' compares the times of response observations
     with those of time-varying covariates to find the most
     recent observed time-varying covariate for each
     response. These are either placed in a new object of
     class, tvcov, added to an already existing list of
     matrices containing other time-varying covariates and a
     new object of class, tvcov, created, or added to an
     existing object of class, tvcov.

_U_s_a_g_e_:

     gettvc(response, times=NULL, tvcov=NULL, tvctimes=NULL,
             oldtvcov=NULL, ties=TRUE)

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

response: A list of two column matrices with response values
          and times for each individual, one matrix or
          dataframe of response values, or an object of
          class, response (created by `restovec').

   times: When `response' is a matrix, a vector of possibly
          unequally spaced times for the response, when they
          are the same for all individuals or a matrix of
          times. Not necessary if equally spaced.

   tvcov: A list of two column matrices with time-varying
          covariate values and corresponding times for each
          individual or one matrix or dataframe of such
          covariate values. Times need not be the same as
          for responses.

tvctimes: When the time-varying covariate is a matrix, a
          vector of possibly unequally spaced times for the
          covariate, when they are the same for all individ-
          uals or a matrix of times. Not necessary if
          equally spaced.

oldtvcov: A list of matrices with time-varying covariate
          values, observed at the event times in `response',
          for each individual, or an object of class, tvcov.
          If not provided, a new object is created.

    ties: If TRUE, when the response and covariate times are
          identical, the response depends on that new value
          (as in observational studies); if FALSE, only the
          next response depends on that value (for example,
          if the covariate is a new treatment just applied
          at that time).

_V_a_l_u_e_:

     An object of class, tvcov, is returned containing the
     new time-varying covariate and, possibly, those in
     `oldtvcov'.

_A_u_t_h_o_r_(_s_)_:

     J.K. Lindsey and D.F. Heitjan

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

     `carma', `elliptic', `gar', `kalcount', `kalseries',
     `kalsurv', `read.list', `restovec', `tvctomat'.

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

     y <- matrix(rnorm(20), ncol=5)
     resp <- restovec(y, times=c(1,3,6,10,15))
     z <- matrix(rpois(20,5),ncol=5)
     z
     # create a new time-varying covariate object for the response
     newtvc <- gettvc(resp, tvcov=z, tvctimes=c(1,2,5,12,14))
     covariates(newtvc)
     # add another time-varying covariate to the object
     z2 <- matrix(rpois(20,5),ncol=5)
     z2
     newtvc2 <- gettvc(resp, tvcov=z2, tvctimes=c(0,4,5,12,16), oldtvc=newtvc)
     covariates(newtvc2)

