delicatessen.estimating_equations.survival.ee_exponential_model
- ee_exponential_model(theta, t, delta)
Estimating equation for an exponential model. Let \(T_i\) indicate the time of the event and \(C_i\) indicate the time to right censoring. Therefore, the observable data consists of \(t_i = \min(T_i, C_i)\) and \(\Delta_i = I(t_i = T_i)\). The estimating equation is
\[\sum_{i=1}^n \left\{ \frac{\Delta_i}{\lambda} - t_i \right\} = 0\]Here, \(\theta\) is a single parameter that corresponds to the scale parameter for the exponential distribution. The hazard from the exponential model is parameterized as the following
\[h(t) = \lambda\]- Parameters
theta (ndarray, list, vector) – Theta in the case of the exponential model consists of a single value. Furthermore, the parameter will be non-negative. Therefore, an initial value like the
[1, ]
should be provided.t (ndarray, list, vector) – 1-dimensional vector of n observed times.
delta (ndarray, list, vector) – 1-dimensional vector of n event indicators, where 1 indicates an event and 0 indicates right censoring.
- Returns
Returns a 1-by-n NumPy array evaluated for the input
theta
- Return type
array
Examples
Construction of a estimating equation(s) with
ee_exponential_model
should be done similar to the following>>> import numpy as np >>> import pandas as pd >>> from delicatessen import MEstimator >>> from delicatessen.estimating_equations import ee_exponential_model
Some generic survival data to estimate an exponential survival model
>>> n = 100 >>> data = pd.DataFrame() >>> data['C'] = np.random.weibull(a=1, size=n) >>> data['C'] = np.where(data['C'] > 5, 5, data['C']) >>> data['T'] = 0.8*np.random.weibull(a=1.0, size=n) >>> data['delta'] = np.where(data['T'] < data['C'], 1, 0) >>> data['t'] = np.where(data['delta'] == 1, data['T'], data['C'])
Defining psi, or the stacked estimating equations
>>> def psi(theta): >>> return ee_exponential_model(theta=theta, >>> t=data['t'], delta=data['delta'])
Calling the M-estimator
>>> estr = MEstimator(stacked_equations=psi, init=[1.]) >>> estr.estimate(solver='lm')
Inspecting the parameter estimates, variance, and confidence intervals
>>> estr.theta >>> estr.variance >>> estr.confidence_intervals()
Inspecting parameter the specific parameter estimates
>>> estr.theta[0] # lambda (scale)
References
Collett D. (2015). Modelling survival data in medical research. CRC press.