hazards {elect}R Documentation

Age-dependent hazards based on a 'msm' model

Description

Graph with transition-specific hazard functions derived from an age-dependent model fitted using 'msm'

Usage

hazards(x, b.covariates, no.years, trans = NULL,
        max.haz = .5, min.haz = 0, CI = FALSE, col = NULL,
        lty = NULL, lwd = NULL, LEGEND = TRUE,
        location = "topleft", age.shift = 0)

Arguments

x

Fitted msm model with age as the Gompertz time scale

b.covariates

List with specified covariates values for the prediction (ignore intercept)

no.years

Number of years for the prediction

trans

Matrix with rows (r,s) for hazard of going from state r to state s. Default to all (r,s)-hazards that are modelled in x

max.haz

Upperbound hazard-axis

min.haz

Lowerbound hazard-axis

CI

TRUE for plotting 95% confidence bands. FALSE otherwise

col

Colour for each hazard curve. Example for two curves: col = c("red","green")

lty

Line type for each hazard curve. Example for two curves: lty = c(1,2)

lwd

Width of line for each hazard curve. Example for two curves: lwd = c(2,2)

LEGEND

TRUE for adding a legend. FALSE otherwise

location

Location for legend. Default to "topleft". See help file for legend for furhter details

age.shift

Value to shift the age scale in the graph. Useful when age in the model is on a shifted scale. Default to 0.

Details

This function is an add-on to the functionality in the 'msm' package. A Gompertz model with age as the time scale can be fitted in 'msm' piecewise-constantly by adding age as a covariate. The function qmatrix.msm is used by hazards repeatedly to take into account the age dependence when calculating the hazards.

Author(s)

Ardo van den Hout. With thanks to Ying Lou.

References

Jackson, C.H. (2011). Multi-State Models for Panel Data: The msm Package for R., Journal of Statistical Software, 38(8), 1-29.

Examples

# Fit msm model:
Q     <- rbind(c(0,0.01,0.01), c(0,0,0.01), c(0,0,0))
model <- msm(state~age, subject = id, data = electData,
             center = FALSE, qmatrix = Q, deathexact = TRUE,
             covariates = ~age+x)
# Plot hazards on original age scale:
hazards(model, b.covariates = list(age = 0, x = 0),
        no.years = 20, max.haz = 0.25,  age.shift = -70)

[Package elect version 1.2 Index]