Calculates Kaplan-Meier type hazard estimates.
kphaz.fit(time,status,strata,q=1,method="nelson")
A vector of time values; all values must be greater than or equal to zero. Missing values (NAs) are not allowed.
A vector of status values. The values are 0 for censored or 1 for uncensored (dead). Missing values (NAs) are not allowed. Must have the same length as time.
An optional vector that will be used to divide the subjects into disjoint groups. Each group generates a hazard curve. If missing, all subjects are assumed to be in the same strata. Missing values (NAs) are allowed.
Number of failure times combined for estimatingthe hazard at their midpoint. Default is 1.
Type of hazard estimation made. Must be one of "nelson" or "product-limit". The default is "nelson".
A list representing the results of the hazard estimation, with the following components:
A vector containing the times at which hazard estimations were made.
A vector containing the hazard estimate at each time.
A vector containing variance estimates for each hazard estimate.
A vector which divides the hazard estimate into disjoint groups. This vector is returned only if 'strata' is defined when 'kphaz.fit' is called.
Let $$t[1] < t[2] < \cdots < t[m]$$ denote the m "distinct" death times.
1. Estimate the cumulative hazard, H[t[j]], and the variance of the cumulative hazard, Var(H[t[j]]), at each of the m distinct death times according to the method selected.
a. For the "nelson" method: $$H[t[j]] = sum(t[i] <= t[j]) status[i]/(n-i+1)$$ $$Var(H[t[j]]) = \sum(t[i] <= t[j]) status[i]/((n-i+1)^2)$$
b. For the "product-limit" metod: $$H[t[j]] = sum(t[i] <= t[j]) -log(1 - status[i]/(n-i+1))$$ $$Var(H[t[j]]) = sum(t[i] <= t[j]) status[i]/((n-i+1)*(n-i))$$
2. For k=1,…,(m-q), define the hazard estimate and variance at time[k] = (t[q+j]+t[j])/2 to be $$haz[time[k]] = (H[t[q+j]]-H[t[j]])/(t[q+j]-t[j])$$ $$var[time[k]] = (Var(H[t[q+j]])-Var(H[t[j]]))/ (t[q+j]-t[j])^2$$
Note that if the final time is a death time rather than a censoring time, the "product-limit" estimate will be Inf for the final hazard and variance estimates.
Jarjoura, David (1988). Smoothing Hazard Rates with Cubic Splines. Commun. Statist. -Simula. 17(2), 377-392.
# NOT RUN {
time <- 1:10
status <- rep(1,10)
kphaz.fit(time,status)
# }
Run the code above in your browser using DataLab