delicatessen.estimating_equations.survival.ee_weibull_model

ee_weibull_model(theta, t, delta)

Estimating equation for a two-parameter Weibull 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 equations are

\[\begin{split}\sum_{i=1}^n = \begin{bmatrix} \frac{\Delta_i}{\lambda} - t_i^{\gamma} \\ \frac{\Delta_i}{\gamma} + \Delta_i \log(t_i) - \lambda t_i^{\gamma} \log(t_i) \end{bmatrix} = 0\end{split}\]

Here, \(\theta\) consists of two parameters for the Weibull model: the scale (\(\lambda\)) and the shape (\(\gamma\)). The hazard from the Weibull model is parameterized as the following

\[h(t) = \lambda \gamma t^{\gamma - 1}\]
Parameters
  • theta (ndarray, list, vector) – Theta in the case of the Weibull model consists of two values. Furthermore, the parameter will be non-negative. Therefore, an initial value like the [1, ] is recommended.

  • t (ndarray, list, vector) – 1-dimensional vector of n observed times. No missing data should be included (missing data may cause unexpected behavior).

  • delta (ndarray, list, vector) – 1-dimensional vector of n event indicators, where 1 indicates an event and 0 indicates right censoring. No missing data should be included (missing data may cause unexpected behavior).

Returns

Returns a 2-by-n NumPy array evaluated for the input theta.

Return type

array

Examples

Construction of a estimating equation(s) with ee_weibull_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_weibull_model

Some generic survival data to estimate a Weibull 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=0.8, 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_weibull_model(theta=theta,
>>>                                 t=data['t'], delta=data['delta'])

Calling the M-estimator

>>> estr = MEstimator(stacked_equations=psi, init=[1., 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)
>>> estr.theta[1]     # gamma  (shape)

References

Collett D. (2015). Modelling survival data in medical research. CRC press.