find.hazard: Calculate the hazard function

Description Usage Arguments Value Author(s) See Also Examples

View source: R/find.hazard.R

Description

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

Usage

1
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

A number giving the value of the estimated hazard at t.

Author(s)

Rihong Hui and Hanna Jankowski <hkj@mathstat.yorku.ca>

See Also

find.shapeCPH find.shapeMLE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 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)

Example output

[1] 1.177677
[1] 1.177677

CPHshape documentation built on May 30, 2017, 4:32 a.m.