Learn R Programming

CPHshape (version 1.0.1)

find.shapeMLE: Compute the MLE of a shape-constrained hazard function

Description

Compute the maximum likelihood estimator (MLE) of a shape-constrained hazard function under IID sampling. We assume that the data are continuous and allow for right censoring. The function 'find.shapeMLE' allows for four different shape constraints: increasing, decreasing, unimodal, and u-shaped.

Usage

find.shapeMLE(x, delta=rep(1, length(x)), type = "increasing", plot = FALSE)

Arguments

x
vector of length n containing the data
delta
logical vector containing the (right) censoring information. If delta_i=1 then the observation was not censored. The default is delta_i=1 for all i, that is, assuming that no observations were censored.
type
string indicating type of shape constraint. Options are "increasing", "decreasing", "unimodal", and "ushaped".
plot
logical, if TRUE, the graphical representation of the MLE is shown

Value

h.range
endpoints for the values of the hazard MLE
h.val
values of the hazard MLE in between the endpoints
phi
the criterion function Phi (negative log-likelihood) evaluated at the MLE
H
the cumulative hazard MLE evaluated at the data points
mode
location of the mode (for unimodal) or antimode (for u-shaped). Note that the antimode is not unique, and the midpoint of all possible values is returned.
type
string indicating type of shape constraint used

References

Hui, R. and Jankowski, H. (2012). Maximum likelihood estimation of a shape-constrained hazard in the proportional hazard model. Technical Report. http://www.math.yorku.ca/~hkj/

Examples

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

# compute MLE of increasing hazard
mle	<-	find.shapeMLE(x, type="increasing")


# plot the fitted hazard
plot(mle)
rug(x)

# add true hazard to the plot
h.true	<-	function(x) 1/(1-x)
plot(h.true, col="red", add=TRUE)

Run the code above in your browser using DataLab