hazards {elect} | R Documentation |
Graph with transition-specific hazard functions derived from an age-dependent model fitted using 'msm'
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)
x |
Fitted |
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 |
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: |
lty |
Line type for each hazard curve. Example for two curves: |
lwd |
Width of line for each hazard curve. Example for two curves: |
LEGEND |
TRUE for adding a legend. FALSE otherwise |
location |
Location for legend. Default to |
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. |
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.
Ardo van den Hout. With thanks to Ying Lou.
Jackson, C.H. (2011). Multi-State Models for Panel Data: The msm Package for R., Journal of Statistical Software, 38(8), 1-29.
# 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)