mvna (version 2.0.1)

mvna: Nelson-Aalen estimator in multistate models

Description

This function computes the multivariate Nelson-Aalen estimator of the cumulative transition hazards in multistate models, that is, for each possible transition, it computes an estimate of the cumulative hazard.

Usage

mvna(data, state.names, tra, cens.name)

Arguments

data

A data.frame of the form data.frame(id,from,to,time) or (id,from,to,entry,exit)

id:

patient id

from:

the state from where the transition occurs

to:

the state to which a transition occurs

time:

time when a transition occurs

entry:

entry time in a state

exit:

exit time from a state

This data.frame is transition-oriented, i.e. it contains one row per transition, and possibly several rows per patient. Specifying an entry and exit time permits to take into account left-truncation.

state.names

A vector of character giving the states names.

tra

A quadratic matrix of logical values describing the possible transitions within the multistate model.

cens.name

A character giving the code for censored observations in the column to of data. If there is no censored observations in your data, put NULL.

Value

Returns a list named after the possible transitions, e.g. if we define a multistate model with two possible transitions: from state 0 to state 1, and from state 0 to state 2, the returned list will have two parts named "0 1" and "0 2". Each part contains a data.frame with columns:

na

Nelson-Aalen estimates at each transition times.

var.aalen

Variance estimator given in eq. (4.1.6) of Andersen et al. (1993).

var.greenwood

Variance estimator given in eq. (4.1.7) of Andersen et al. (1993).

time

The transition times.

The list also contains:
time

All the event times.

n.risk

A matrix giving the number at individual at risk in the transient states just before an event.

n.event

An array which gives the number of transitions at each event times.

n.cens

A matrix giving the number a censored observations at each event times.

state.names

The same as in the function call.

cens.name

The same as in the function call.

trans

A data frame, with columns from and to, that gives the possible transitions.

Details

This functions computes the Nelson-Aalen estimator as described in Anderson et al. (1993), along with the two variance estimators described in eq. (4.1.6) and (4.1.7) of Andersen et al. (1993) at each transition time.

References

Andersen, P.K., Borgan, O., Gill, R.D. and Keiding, N. (1993). Statistical models based on counting processes. Springer Series in Statistics. New York, NY: Springer.

Beyersmann J, Allignol A, Schumacher M: Competing Risks and Multistate Models with R (Use R!), Springer Verlag, 2012 (Use R!)

Klein, J.P. Small sample moments of some estimators of the variance of the Kaplan-Meier and Nelson-Aalen estimators. Scandinavian Journal of Statistics, 18:333--340, 1991.

See Also

sir.adm,sir.cont

Examples

Run this code
# NOT RUN {
data(sir.cont)

# Modification for patients entering and leaving a state
# at the same date
sir.cont <- sir.cont[order(sir.cont$id, sir.cont$time), ]
for (i in 2:nrow(sir.cont)) {
  if (sir.cont$id[i]==sir.cont$id[i-1]) {
    if (sir.cont$time[i]==sir.cont$time[i-1]) {
      sir.cont$time[i-1] <- sir.cont$time[i-1] - 0.5
    }
  }
}

# Matrix of logical giving the possible transitions
tra <- matrix(ncol=3,nrow=3,FALSE)
tra[1, 2:3] <- TRUE
tra[2, c(1, 3)] <- TRUE

# Computation of the Nelson-Aalen estimates
na <- mvna(sir.cont,c("0","1","2"),tra,"cens")

# plot
if (require(lattice))
xyplot(na)

### example with left-truncation
data(abortion)

# Data set modification in order to be used by mvna
names(abortion) <- c("id", "entry", "exit", "from", "to")
abortion$to <- abortion$to + 1

## computation of the matrix giving the possible transitions
tra <- matrix(FALSE, nrow = 5, ncol = 5)
tra[1:2, 3:5] <- TRUE

na.abortion <- mvna(abortion, as.character(0:4), tra, NULL)

plot(na.abortion, tr.choice = c("0 4", "1 4"),
     curvlab = c("Control", "Exposed"),
     bty = "n", legend.pos = "topleft")
# }

Run the code above in your browser using DataCamp Workspace