Survival Analysis Overview; Event History
import statsmodels.api as sm
import statsmodels.formula.api as smf
sm.SurvfuncRight#(time, status, entry=None, title=None, freq_weights=None, exog=None, bw_factor=1.0)
sm.PHReg#(endog, exog, status=None, entry=None, strata=None, offset=None, ties='breslow', missing='drop')
smf.phreg#(formula, data, status=None, entry=None, strata=None, offset=None, subset=None, ties='breslow', missing='drop')
Probability Distribution
from scipy import stats
# poisson
# exponential
stats.expon.rvs(scale=5, size=300) # sampling: mean = scale, var = scale**2
stats.expon.pdf(0, scale=1) # probability density: pdf = lambda * exp(-lambda * x), scale = 1 / lambda
stats.expon.cdf(1, scale=1) # cumulative distribution: cdf
stats.expon.ppf(.5, scale=1) # percent point function: cdf^(-1): quantile function
# beta
# weibull
$${\displaystyle \begin{aligned} \text{Survival Function, Curve} && S(t) &= P(T > t) \\ \text{Hazard Rate} && \lambda (t) &= \lim_{\Delta t \rightarrow 0} \frac{P(t \le T < t + \Delta t \mid T \ge t)}{\Delta t}\\ \text{Cumulative Hazard} && \Lambda (t) &= \int_{0}^{t} \lambda (u) \; du \\ \end{aligned} }$$
# lifelines
Non-Parametric: Kaplan-Meier
Parametric Survival Function Estimation
Reference
'quantitative analysis > statistics' 카테고리의 다른 글
Elasticity, Equilibrium and Stability (0) | 2023.09.08 |
---|---|
Causal Discovery (0) | 2023.08.11 |
Bayesian Estimation (0) | 2023.05.31 |
Panel Analysis (4) | 2023.05.20 |
Correlation and Covariance Analysis (0) | 2023.05.08 |