Learn R Programming

CPHshape (version 1.0.1)

find.shapeCPH: Compute the MLE of the effect parameters and shape-constrained baseline in the Cox model

Description

Compute the maximum likelihood estimator (MLE) of the shape-constrained hazard baseline and the effect parameters in the Cox proportional hazards model 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.shapeCPH(x, z, delta, type="increasing", beta0=rep(1, length(as.matrix(z)[1,])), max.loop=250, eps=1e-5, eps.beta=1e-5, print=FALSE)

Arguments

x
vector of length n containing the data
z
matrix of size n x p containing the covariate values
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, no observations were censored.
type
string indicating type of shape constraint. Options are "increasing", "decreasing", "unimodal", and "ushaped".
beta0
vector of length p containing the starting value of beta for the algorithm. The default is all elements equal to one.
max.loop
maximum number of iterations. The default is 250.
eps
precision for stopping criterion. The default is 1e-05.
eps.beta
precision for second stopping criterion. The default is 1e-05.
print
logical, if TRUE, output from each iteration of the algorithm is shown. The default is FALSE.

Value

beta
MLE of the effect parameters
h.range
endpoints for the values of the hazard MLE
h.val
values of the hazard MLE
phi
the criterion function Phi 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/ Mykytyn, S. and Santner, T. (1981) Maximum likelihood estimation of the survival function based on censored data under hazard rate assumptions. Comm. Statist. A - Theory and Methods 10 (14): 1369-1387.

Examples

Run this code
n	<-	200
beta1	<-	1
beta2	<-	2
z1	<-	rbinom(n,1,0.5)
z2	<-	runif(n,-1,1)
w	<-	exp(beta1*z1+beta2*z2)
x	<-	rexp(n, rate=0.3*w)
delta	<-	1*(x<=2.5)
x	<-	pmin(x,2.5)

# compute MLE
mle	<-	find.shapeCPH(x, cbind(z1,z2) , delta, print=TRUE, type="decreasing")

# estimates of the effect parameter
mle$beta

# plot resulting estimate of baseline hazard

plot(mle)
abline(h=0.3, col="red") # add true baseline
rug(x)

Run the code above in your browser using DataLab