The type double function is imsls_d_nonparam_hazard_rate.
Required Arguments
intn_observations (Input) Number of observations.
float t[] (Input) An array of n_observations containing the failure times. If optional argument IMSLS_CENSOR_CODES is used, the values of t may be treated as exact failure times, as right-censored times, or a combination of exact and right censored times. By default, all times in t are assumed to be exact failure times.
int n_hazard (Input) Number of grid points at which to compute the hazard. The function computes the hazard rates over the range given by: hazard_min + j * hazard_increment, for j = 0, ..., n_hazard- 1.
floathazard_min (Input) First grid value.
floathazard_increment (Input) Increment between grid values.
Return Value
Pointer to an array of length n_hazard containing the estimated hazard rates.
Synopsis with Optional Arguments
#include<imsls.h>
float*imsls_f_nonparam_hazard_rate(intn_observations, floatt[], int n_hazard, floathazard_min, floathazard_increment,
IMSLS_PRINT_LEVEL, int iprint (Input) Printing option.
iprint
Action
0
No printing is performed.
1
The grid estimates and the optimized estimates are printed for each value of k.
Default: iprint = 0.
IMSLS_CENSOR_CODES, intcensor_codes[] (Input) censor_codes is an array of length n_observations containing the censoring codes for each time in t. If censor_codes[i]=0 the failure time t[i] is treated as an exact time of failure. Otherwise it is treated as a right-censored time; that is, the exact time of failure is greater than t[i].
Default: All failure times are treated as exact times of failure with no censoring.
IMSLS_WEIGHT_OPTION, intiwto (Input) Weight option. If iwto = 1, then is used for the i‑th smallest observation. Otherwise, is used.
Default: iwto = 0.
IMSLS_SORT_OPTION, intisort (Input) Sorting option. If isort = 1, then the event times are not automatically sorted by the function. Otherwise, sorting is performed with exact failure times following tied right-censored times. Default: isort = 0.
IMSLS_K_GRID, intn_k, intk_min, intk_increment (Input) Finds the optimal value of k over the range given by: kmin + (j- 1) ×k_increment, for j = 1, ..., n_k. Where n_k is the number of values of k to be considered. k_min is the minimum value for parameter k. k_increment is the increment between successive values of parameter k. Parameter k is the number of nearest neighbors to be used in computing the k-th nearest neighbor distance.
Default: k_min is the smallest possible value of k,k_increment =2, and n_k will be at most 10 points.
IMSLS_BETA_GRID, intn_beta_grid, floatbeta_start, floatbeta_increment (Input) For n_beta_grid > 0, a user-defined grid is used. This grid is defined as beta_start + (j ‑ 1)*beta_increment, for j = 1, …, n_beta_grid. beta_start is the first value to be used in the user-defined grid and beta_increment is the increment between successive grid values of beta.
Default: The values in the initial beta search are given as follows:
Let β* = - 8, - 4, - 2, - 1, - 0.5,0.5,1, and 2, and
For each value of β, vml is computed at the optimizing β. The maximizing β is used to initiate the iterations. If the initial β* is determined from the search to be less than -6, then it is presumed that β is infinite, and an analytic estimate of α based upon infinite β is used. Infinite β corresponds to a flat hazard rate.
IMSLS_N_MISSING, int*nmiss (Output) Number of missing (NaN, not a number) failure times in t.
IMSLS_ALPHA, float*alpha (Output) Optimal estimate for the parameter α.
IMSLS_BETA, float*beta (Output) Optimal estimate for the parameter β.
IMSLS_CRITERION, float*vml (Output) Optimum value of the criterion function.
IMSLS_K, int*k (Output) Optimal estimate for the parameter k.
IMSLS_SORTED_EVENT_TIMES, float**event_times (Output) Address of a pointer to an array of length n_observations containing the times of occurrence of the events, sorted from smallest to largest.
IMSLS_SORTED_EVENT_TIMES_USER, floatevent_times[] (Output) Storage for event_times is provided by the user. See IMSLS_SORTED_EVENT_TIMES.
IMSLS_SORTED_CENSOR_CODES, int**isorted_censor (Output) Address of a pointer to an array of length n_observations containing the sorted censor codes. Censor codes are sorted corresponding to the events event_times[i], with censored observations preceding tied failures.
IMSLS_SORTED_CENSOR_CODES_USER, intisorted_censor[] (Output) Storage for isorted_censor is provided by the user. See IMSLS_SORTED_CENSOR_CODE.
IMSLS_RETURN_USER, floathaz[] (Output) If specified, haz is a user supplied array of length n_hazard containing the estimated hazard rates.
Description
Function imsls_f_nonparam_hazard_rate is an implementation of the methods discussed by Tanner and Wong (1984) for estimating the hazard rate in survival or reliability data with right censoring. It uses the biweight kernel,
and a modified likelihood to obtain data-based estimates of the smoothing parameters α, β, and k needed in the estimation of the hazard rate. For kernel K(x), define the “smoothed” kernel Ks(x-x(j)) as follows:
where djk is the distance to the k-th nearest failure from x(j), and x(j) is the j-th ordered observation (from smallest to largest). For given α and β, the hazard at point x is then
where N = n_observations, δi is the i-th observation’s censor code (1 = censored, 0 = failed), and wi is the i-th ordered observation’s weight, which may be chosen as either 1/(N‑i + 1), or ln(1 + 1/(N‑i + 1)). Let
The likelihood is given by
where ∏ denotes product. Since the likelihood leads to degenerate estimates, Tanner and Wong (1984) suggest the use of a modified likelihood. The modification consists of deleting observation xi in the calculation of h(xi) and H(xi) when the likelihood term for xi is computed using the usual optimization techniques. α and β for given k can then be estimated.
Estimates for α and β are computed as follows: for given β, a closed form solution is available for α. The problem is thus reduced to the estimation of β.
A grid search for β is first performed. Experience indicates that if the initial estimate of β from this grid search is greater than, say, e6 ,then the modified likelihood is degenerate because the hazard rate does not change with time. In this situation, β should be taken to be infinite, and an estimate of α corresponding to infinite β should be directly computed. When the estimate of β from the grid search is less than e6, a secant algorithm is used to optimize the modified likelihood. The secant algorithm iteration stops when the change in β from one iteration to the next is less than 10−5. Alternatively, the iterations may cease when the value of β becomes greater than e6, at which point an infinite β with a degenerate likelihood is assumed.
To find the optimum value of the likelihood with respect to k, a user-specified grid of k-values is used. For each grid value, the modified likelihood is optimized with respect to α and β. That grid point, which leads to the smallest likelihood, is taken to be the optimal k.
Programming Notes
1. If sorting of the data is performed by imsls_f_nonparam_hazard_rate, then the sorted array will be such that all censored observations at a given time precede all failures at that time. To specify an arbitrary pattern of censored/failed observations at a given time point, the isort = 1 option must be used. In this case, it is assumed that the times have already been sorted from smallest to largest.
2. The smallest value of k must be greater than the largest number of tied failures since djk must be positive for all j. (Censored observations are not counted.) Similarly, the largest value of k must be less than the total number of failures. If the grid specified for k includes values outside the allowable range, then a warning error is issued; but k is still optimized over the allowable grid values.
3. The secant algorithm iterates on the transformed parameter β* = exp(-β). This assures a positive β, and it also seems to lead to a more desirable grid search. All results returned to the user are in the original parameterization, however.
4. Since local minimums have been observed in the modified likelihood, it is recommended that more than one grid of initial values for α and β be used.
5. Function imsls_f_nonparam_hazard_rate assumes that the hazard grid points are new data points.
Example
The following example is taken from Tanner and Wong (1984). The data are from Stablein, Carter, and Novak (1981) and involve the survival times of individuals with nonresectable gastric carcinoma. Only individuals treated with both radiation and chemotherapy are used. For each value of k from 18 to 22 with increment of 2, the default grid search for β is performed. Using the optimal value of β in the grid, the optimal parameter estimates of α and β are computed for each value of k. The final solution is the parameter estimates for the value of k which optimizes the modified likelihood (vml). Because the iprint = 1 is in effect, imsls_f_nonparam_hazard_rate prints all of the results in the output.