gettvc                package: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

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

     'gettvc' finds the most recent value of a time-varying covariate
     before each observed response and possibly adds them to a list of
     other time-varying covariates. It 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'.

     If there are response observation times before the first covariate
     time, the covariate for these times is set to zero.

_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 individuals 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)

