plot.hazard {SemiMarkov}R Documentation

Plot method for objects of class hazard

Description

Plot method for one or several (maximum 10) objects of class hazard. Depending on the hazard rate chosen in the function hazard, the function plots either the hazard rates of sojourn times or the semi-Markov process hazard rate for each considered transition (one plot for each transition).

Usage

## S3 method for class 'hazard'
plot(x, x2 = NULL, x3 = NULL, x4 = NULL, x5 = NULL, x6 = NULL, x7 = NULL, 
      x8 = NULL, x9 = NULL, x10 = NULL, transitions = NULL, names = NULL, 
      legend = TRUE, legend.pos = NULL, cex = NULL, colors = NULL,
	  xlab = "Time", ylab = "Hazard function", lwd = 3, type = "p", ...)

Arguments

x

Object of class hazard. At least one hazard object is needed.

x2

Object of class hazard. Default is NULL.

x3

Object of class hazard. Default is NULL.

x4

Object of class hazard. Default is NULL.

x5

Object of class hazard. Default is NULL.

x6

Object of class hazard. Default is NULL.

x7

Object of class hazard. Default is NULL.

x8

Object of class hazard. Default is NULL.

x9

Object of class hazard. Default is NULL.

x10

Object of class hazard. A maximum of ten hazard objects is possible. Default is NULL.

transitions

A character vector giving the transitions to be plotted. Default is NULL which means that all the possible transitions are displayed.

names

Names of the hazard rates. Default is NULL which means that the names used in the semiMarkov object are applied.

legend

A logical value specifying if a legend should be added. Default is TRUE.

legend.pos

A vector giving the legend position.

cex

character expansion factor relative to current par("cex").

colors

A vector of colours for the hazard rates.

xlab

x-axis label. Default is Time.

ylab

y-axis label. Default is Hazard function.

lwd

Thickness of lines or points.

type

Type of graph. Default are points p.

...

Further arguments for plot.

Value

No value returned.

Author(s)

Agnieszka Listwon-Krol

See Also

hazard, semiMarkov

Examples




## Asthma control data
data(asthma)

## Definition of the model:  states, names, possible transtions 
# and waiting times distributions
states_1 <- c("1","2","3")
mtrans_1 <- matrix(FALSE, nrow = 3, ncol = 3)
mtrans_1[1, 2:3] <- c("E","E")
mtrans_1[2, c(1,3)] <- c("E","E")
mtrans_1[3, c(1,2)] <- c("W","E")
fit <- semiMarkov(data = asthma, states = states_1, mtrans = mtrans_1)
lambda<-hazard (fit, type = "lambda")

plot(lambda, names = c("lambda"),legend=FALSE)
plot(lambda, transitions = c("13","31"), names = c("lambda"),
legend.pos=c(2,0.09,2,0.4))

## semi-Markov model in each stratum of Severity
fit0 <- semiMarkov(data = asthma[asthma$Severity==0,],
        states = states_1, mtrans = mtrans_1)
fit1 <- semiMarkov(data = asthma[asthma$Severity==1,],
        states = states_1, mtrans = mtrans_1)
lambda0<-hazard (fit0, type = "lambda",s=0,t=5,Length=1000)
lambda1<-hazard (fit1, type = "lambda",s=0,t=5,Length=1000)
plot(lambda0,lambda1, names = c("lambda0", "lambda1"),
legend.pos=c(4,0.18,4,0.8,4,0.2,4,0.09,4,0.7,4,0.21))

## semi-Markov model with covariate "BMI"
fitcov <- semiMarkov(data = asthma, cov = as.data.frame(asthma$BMI),
        states = states_1, mtrans = mtrans_1)
lambda0<-hazard (fitcov, type = "lambda",cov = c(0))
lambda1<-hazard (fitcov, type = "lambda",cov = c(1))
plot(lambda0,lambda1, names = c("lambda0", "lambda1"))



[Package SemiMarkov version 1.4.6 Index]