clos                package:changeLOS                R Documentation

_C_h_a_n_g_e _i_n _L_O_S

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

     estimates the expected change in length of stay (LOS) associated
     with an intermediate event (IE). In order to account for the
     timing of events (an IE can only have an effect once it has
     occurred), a multi-state model is used. The data are stratified
     into `cases' (the IE has occurred) and `controls' (the IE has _not
     yet_ occurred) on a daywise basis. (`Daywise' if time is in days.)
     The expected change in LOS is estimated for each day and a
     weighted average is computed.

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

     clos(model, observ, aw=FALSE)

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

   model: an object of the class 'msmodel' which describes the
          multi-state model 

  observ: a data.frame of the form data.frame( id, from, to, time, oid
          ) (see also 'prepare.los.data'):

          _i_d id (patient id, admision id)

          _f_r_o_m the state from where a transition occurs

          _t_o the state to which a transition occurs

          _t_i_m_e the time a transition occurs

          _o_i_d the observation id          

      aw: locical, with (TRUE) or without(FALSE) alternative weighting

_D_e_t_a_i_l_s:

     'clos' is based on `approach B' in Schulgen and Schumacher (1996),
     however with some modifications: We use a multi-state model with
     four states. All individuals start in an initial state. They may
     pass through the intermediate state. LOS is determined by reaching
     one of two competing, absorbing states. In clinical research these
     latter two states are typically `discharge' and `death',
     respectively. The IE is often interpreted as a complication.
     Backward transitions are not possible. Schulgen and Schumacher
     (1996) modelled a second intermediate state, motivated by their
     application. However, this model has some individuals `drop out'
     in the sense that they become neither `case' nor `control'. In
     addition, 'clos' computes an weighted average, where the weights
     are given by the weighting time distribution in the intial state.
     Schulgen and Schumacher (1996) used a conditional version of it,
     given one reaches the IE. In the case of no censoring, the former
     weights have every individual contribute to the weighting, whereas
     the latter has not. One can interpret the conditional weighting in
     Schulgen and Schumacher (1996) as assuming a patient's viewpoint
     who experiences the IE (and analogously for patients uninfected,
     with weights given one is directly discharged/dies without prior
     IE.) Finally, 'clos' treats the daywise comparison as being zero
     if there are not both patients with and without IE on that day.
     See also Beyersmann et al. (2005) for a non-technical explanation
     of these methods.

     See the examples for special features:

        *  bootstrapping

        *  use of the alternative weight

        *  distinguishing between patients discharged and patients
           deceased    

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

     An object of class c('clos'). The object is a list of 

cLOS      : change in LOS

trans     : an object of class 'trans'

e.given.1 : estimates E(LOS|X_s = intermediate event) for all observed
          transition times s, where X_s denotes the state by time s

e.given.0 : estimates E(LOS|X_s = initial state)  for all observed
          transition times s, where X_s denotes the state by time s

    phi2: weighted average of the difference between phi2.case and
          phi2.control, this quantity can be interpreted as the
          contribution to the expected change in LOS at time s by
          patients infected at time s who eventually discharge 

phi2.case: estimates E(LOS *1*(X_LOS = discharge)|X_s = intermediate
          event), where *1* denotes the indicator function

phi2.control: P(X_LOS = discharge|X_s = intermediate event) E(LOS|X_s =
          initial state)

    phi3: weighted average of the difference between phi3.case and
          phi3.control, this quantity can be interpreted as the
          contribution to the expected change in LOS at time s by
          patients infected at time s who eventually die 

phi3.case: estimates E(LOS *1*(X_LOS = death)|X_s = intermediate
          event), where *1* denotes the indicator function

phi3.control: P(X_LOS = death|X_s = intermediate event) E(LOS|X_s =
          initial state)

 empty.1: event times with the group `intermediate, but no terminal
          event yet' being empty

 empty.0: event times with the group `no intermediate or terminal event
          yet' being empty

 weights: weights for the weighted average 

 w.times: time points corresponding to the weights

 called : how the function was called

patients: total number of observed patients

patients.discharge: number of patients being discharged

patients.death: number of patients who die

patients.cens: number of patients being censored, i. e. for whom
          neither discharge or death was observed

   cases: number of patients who experienced the IE

cases.discharge: number of patients who experienced the IE being
          discharged

cases.death: number of patients who experienced the IE and died

cases.cens: number of patients who experienced the IE and were censored

_V_a_l_u_e '_a_l_t_e_r_n_a_t_i_v_e _w_e_i_g_h_t_i_n_g':

     When aw=TRUE an object of class c('clos','closa'). The object is a
     list like above with the following extra items:

_w_e_i_g_h_t_s._1 weights corresponding to the conditional weighting time in
     the intial state given one reaches the IE.

_w_e_i_g_h_t_s._2_3 weights corresponding to the conditional weighting time in
     the intial state given one _does not_ reach the IE.

_g_i_v_e_n._1 change in LOS corresponding to the alternative weights
     'weights.1'

_g_i_v_e_n._2_3 change in LOS corresponding to the alternative weights
     'weights.2'

_N_o_t_e:

     required packages: survival

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

     Jan Beyersmann jan@fdm.uni-freiburg.de Matthias Wangler
     mw@imbi.uni-freiburg.de

_R_e_f_e_r_e_n_c_e_s:

     G Schulgen and M Schumacher (1996). Estimation of prolongation of
     hospital stay attributable to nosocomial infections.  _Lifetime
     Data Analysis_ 2, 219-240.

     J Beyersmann, P Gastmeier, H Grundmann, S B{\"a}rwolff, C Geffers,
     M Behnke, H R{\"u}den, and M Schumacher (2005): Assessment of
     prolongation of intensive care unit stay due to nosocomial
     infections, using multistate models. _Accepted for Infection
     Control and Hospital Epidemiology_

     A reference on multi-state models:

     P Andersen and N Keiding (2002). Multi-state models for event
     history analysis. _Statistical Methods in Medical Research_ 11,
     91-115

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

     'survival', exampleclos

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

     ## run clos
     data(los.data)
     my.observ <- prepare.los.data(x=los.data)
     tra <- matrix(FALSE,4,4)
     diag(tra) <- TRUE
     tra[1,] <- TRUE
     tra[2,3:4] <- TRUE
     my.model <- msmodel(c("0","1","2","3"),tra,cens.name="cens")
     los <- clos(model=my.model,observ=my.observ)
     summary(los)
     plot(los)

     ## expected change in LOS due to an IE
     phi <- los$e.given.1 - los$e.given.0

     ## distinguishing between patients discharged
     phi2 <- los$phi2.case - los$phi2.control
     ## and patients deceased
     phi3 <- los$phi3.case - los$phi3.control 

     ## we have phi = phi2 + phi3
     all(round(phi, digits=10) == round(phi2+phi3, digits=10),na.rm=TRUE)

     ## compute bootstrap SE with function boot() from library boot

     ## first we need a statistic, which boot takes as an argument
     "clos.for.bstrap" <- function(data, index, mod){
       my.observ <- prepare.los.data(x=data[index,])
       return(clos(model=mod,observ=my.observ)$cLOS)
     }

     ## our estimate is
     clos.for.bstrap(data=los.data, index=1:length(los.data[,1]), mod=my.model)

     ## now bootstrap 
     library(boot)
     nb <- 20 ## nb <- 2000
     los.bootstrap <- boot(los.data, clos.for.bstrap, nb, mod=my.model)
     sqrt(var(los.bootstrap$t))

     ## compute change in LOS `by hand'; also works for alternative weights

     ## first, get pure event times
     my.evtimes <- sort(unique(my.observ$time[my.observ$to !="cens"]))
     ## compute daywise difference between expected LOS
     my.diffs <- los$e.given.1 - los$e.given.0
     ## restrict to those days when a transition out of the initial state was observed
     my.diffs <- my.diffs[is.element(my.evtimes, los$w.times)]
     ## compute weighted average, but don't sum up over
     ## days where one of the groups (no) IE (yet) experienced was empty.
     sum((my.diffs * los$weights)[!(is.element(los$w.times, c(los$empty.0, los$empty.1)))])

