

restovec(rmutil)                             R Documentation

_C_r_e_a_t_e _a _r_e_s_p_o_n_s_e _o_b_j_e_c_t

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

     `restovec' produces an object of class, response, from
     a list of vectors of event histories or of two or more
     column matrices with times, response values, and possi-
     bly binomial totals, nesting categories, censor indica-
     tors, and/or units of measurement, for each individual,
     or a matrix or dataframe of response values.

     Such objects can be printed and plotted. NAs are
     removed with `rmna' (where necessary, incoordination
     with the appropriate covariates).

     Methods are available for extracting the response, the
     numbers of observations per individual, the times, the
     weights, and the nesting variable: `response', `nobs',
     `times', `weights', and `nesting'. The response and or
     the times may be transformed using `transform(z,
     y=fcn1(y), times=fcn2(times))' where fcn1 and fcn2 are
     transformations. When the response is transformed, the
     Jacobian is automatically calculated.

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

     restovec(response, times=NULL, nest=NULL, coordinates=NULL,
             censor=NULL, totals=NULL, weights=NULL, delta=NULL, type=NULL)

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

response: A matrix or dataframe of response values, a list
          of vectors of event histories, or a list of one or
          more column matrices, for each individual, with
          response values in the first column and times in
          the second, possibly followed by columns with
          nesting categories, binomial totals, censoring
          indicators, and/or units of measurement. For inde-
          pendent responses with one observation per indi-
          vidual or for a single time series, one vector may
          be supplied (in the latter case, the times must be
          given even if equally spaced).

   times: When response is a matrix, a vector of possibly
          unequally spaced times when they are the same for
          all individuals or a matrix of times. Not neces-
          sary if equally spaced, except if a vector con-
          taining a single time series is supplied (if not
          given in this case, it considers the responses to
          be independent, not a time series). For clustered
          data with no time ordering, set to FALSE.

    nest: When `response' is a matrix, a vector of length
          equal to the number of responses per individual
          indicating which responses belong to which nesting
          category. Values must be consecutive increasing
          integers. This is the second level of nesting,
          with the individual being the first level.

coordinates: When `response' is a vector, a two-column
          matrix giving the coordinates for spatial data.

  censor: A vector of the same length as the number of indi-
          viduals containing a binary indicator, with a one
          indicating that the last time period in the series
          terminated with an event and zero that it was cen-
          sored, or, when response is matrix, a matrix of
          the same size.  For event history data, even with
          no censoring, an appropriate vector of ones must
          be supplied.

  totals: If the response is a matrix of binomial counts, a
          corresponding vector (one total or one per indi-
          vidual) or matrix of totals.

 weights: A vector, matrix, or list of vectors of frequen-
          cies or weights, of the same dimensions as the
          response.

   delta: The unit of measurement (if not equal to unity), a
          scalar or a vector. If the response has been
          transformed, this should contain the numerical
          values of the Jacobian. When the `transform'
          method is applied to the response, this is auto-
          matically updated.

    type: The type of measurement: nominal, ordinal, dis-
          crete, duration, continuous, or unknown. This
          becomes an attribute of the `response' object.

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

     Returns an object of class, response, containing a vec-
     tor with the responses (z$y), a corresponding vector of
     times (z$times) if applicable, a vector giving the num-
     ber of observations per individual (z$nobs, set to a
     scalar 1 if observations are independent), and possibly
     binomial totals (z$n), nesting (clustering, z$nest),
     censoring (z$censor), weights (z$wt), and unit of mea-
     surement information (z$delta).

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

     J.K. Lindsey

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

     `read.list', `rmna', `tcctomat', `transform', `tvc-
     tomat'.

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

     y <- matrix(rnorm(20),ncol=5)
     # times assumed to be 1:5
     restovec(y)
     #unequally-spaced times
     tt <- c(1,3,6,10,15)
     print(resp <- restovec(y,times=tt))
     response(resp)
     response(resp, nind=2:3)
     times(resp)
     nobs(resp)
     weights(resp)
     nesting(resp)
     # because individuals are the only nesting, this is the same as
     covind(resp)
     # binomial
     y <- matrix(rpois(20,5),ncol=5)
     # responses summarized as relative frequencies
     print(respb <- restovec(y,totals=y+matrix(rpois(20,5),ncol=5),times=tt))
     response(respb)
     # censored data
     y <- matrix(rweibull(20,2,5),ncol=5)
     print(respc <- restovec(y,censor=matrix(rbinom(20,1,0.9),ncol=5),times=tt))
     # if there is no censoring, censor indicator is not printed
     response(respc)
     # nesting clustered within individuals
     nest <- c(1,1,2,2,2)
     print(respn <- restovec(y,censor=matrix(rbinom(20,1,0.9),ncol=5),
             times=tt,nest=nest))
     response(respn)
     times(respn)
     nesting(respn)

