Learn R Programming

CPHshape (version 1.0.1)

find.hazard: Calculate the hazard function

Description

This function calculates the hazard function at location t based on input resulting from either find.shapeCPH or find.shapeMLE.

Usage

find.hazard(t, h.val, h.ranges, type, mode)

Arguments

t
time at which to evaluate the hazard (must be univariate)
h.val
vector specifying changes of values in the hazard baseline MLE (output from e.g. find.shapeCPH)
h.ranges
vector specifying locations of changes in values in the hazard baseline MLE (output from e.g. find.shapeCPH)
type
type of shape constrained used (also given as output from e.g. find.shapeCPH)
mode
location of mode or antimode (also given as output from e.g. find.shapeCPH). Not required for the increasing or decreasing shapes.

Value

See Also

find.shapeCPH find.shapeMLE

Examples

Run this code
# random sample from the uniform density
n	<-	100
x	<-	runif(n)

# compute MLE of increasing hazard and evaluate fitted hazard at t=0.2
mle	<-	find.shapeMLE(x, type="increasing")
find.hazard(0.2, mle$h.val, mle$h.range, type=mle$type)


# compute MLE of unimodal hazard and evaluate fitted hazard at t=0.2
mle	<-	find.shapeMLE(x, type="unimodal")
find.hazard(0.2, mle$h.val, mle$h.range, type=mle$type, mode=mle$mode)

Run the code above in your browser using DataLab