from _api_doc_utils import *WeibullPH
Parametric proportional hazards with flexible monotone baseline hazard
1 Where it fits
Group: Survival / event-time models
WeibullPH generalizes the exponential PH model to
\[ h_i(t \mid x_i) = \lambda_0 ho t^{ho-1} \exp(x_i'eta), \]
which nests increasing, decreasing, and constant baseline hazards depending on the shape parameter \(ho\). Like ExponentialPH, it identifies absolute hazard and survival objects.
2 Python API
Constructor: cm.WeibullPH
Use fit(x, time, event). predict_lin(x, time) returns the log hazard at a specific horizon, while predict_hazard, predict_cumulative_hazard, and predict_survival expose the absolute prediction surface. The default predict(x, time) returns survival probabilities.
print(inspect.signature(cm.WeibullPH))cls = cm.WeibullPH
display(HTML(html_table(["Public method"], public_methods(cls))))3 Minimal example
rng=np.random.default_rng(32)
x=rng.normal(size=(300,2)); rho=1.4; lam=0.03; u=rng.uniform(size=300); t_event=(( -np.log(u)) /(lam*np.exp(x@np.array([0.45,-0.25]))))**(1.0/rho); c=rng.exponential(35,size=300)
time=np.minimum(t_event,c); event=(t_event<=c).astype(float)
model=cm.WeibullPH(); model.fit(x,time,event)
print(model.predict_lin(x[:3], time[:3]))
print(model.predict_hazard(x[:3], time[:3]))
print(model.predict_cumulative_hazard(x[:3], time[:3]))
print(model.predict(x[:3], time[:3]))4 summary() contract
The table below is generated by fitting the live class in this repository and then inspecting summary(). Shapes are shown because most values are plain NumPy arrays or scalars.
rng=np.random.default_rng(132); x=rng.normal(size=(140,2)); rho=1.3; lam=0.04; u=rng.uniform(size=140); te=(( -np.log(u)) /(lam*np.exp(x@np.array([0.35,-0.15]))))**(1.0/rho); c=rng.exponential(25,size=140); time=np.minimum(te,c); event=(te<=c).astype(float)
model=cm.WeibullPH(); model.fit(x,time,event)
summary = model.summary()
display(HTML(html_table(["summary() key", "shape"], summary_shape_rows(summary))))