Learn R Programming

nphPower (version 1.1.0)

plotHazSurv: Graphic Display of Hazard and Survival Function

Description

Plot the hazard and survival function of the of control group (from weibull or loglogistic distribution) and treatment group (derived from an arbitrary hazard ratio function)

Usage

plotHazSurv(
  bsl_dist = c("weibull", "loglogistic"),
  param = c(1.2, 0.03),
  fun_list,
  end,
  tit = c("Hazard Function", "Survival Function"),
  pos = c(1, 2),
  hlegend.loc = "bottomleft",
  slegend.loc = "topright"
)

Value

graphics of hazard and survival functions

Arguments

bsl_dist

a text must be one of ("weibull", "loglogistic") distribution, specified for the control group

param

a vector of length 2, specifying the shape and rate (1/scale) parameter of the bsl_dist distribution, Default: c(1.2, 0.03)

fun_list

a list of hazard ratio functions comparing treatment group and control group

end

a value specifying the duration of the curve

tit

a vector specifying the titles of each graph, Default: c("Hazard Function", "Survival Function")

pos

a graphic parameter in the form of c(nr,nc). Subsequent figures will be drawn in an nr-by-nc array, Default: c(1, 2)

hlegend.loc

a text indicating the position of legend for the hazard plot. Default: "bottomleft"

slegend.loc

a text indicating the position of legend for the survival plot. Default: "topright"

Examples

Run this code
# proportional hazards
plotHazSurv(
 bsl_dist=c("weibull")
 ,param=c(1.2,1/30)
 ,fun_list=list(function(x){x^0*0.7})
 ,40
 ,tit= c("Hazard Function","Survival Function")
 ,pos=c(1,2)
)
# crossing hazards
plotHazSurv(
 bsl_dist=c("weibull")
 ,param=c(1.2,1/30)
 ,fun_list=list(function(x){1.3*(x<10)+(x>=10)*0.7})
 ,40
 ,tit= c("Hazard Function","Survival Function")
 ,pos=c(1,2)
)

Run the code above in your browser using DataLab