1 들어가며 — Ch.7 시리즈의 마무리
| 편 | 주제 |
|---|---|
| Ch.7 Overview | 9 절 조망 |
| § 7.1~7.2 | One-Sample |
| § 7.3~7.4 | K-Sample + Trend |
| § 7.5~7.6 | Stratified + Matched + Renyi |
| § 7.9 (본 편) | 15 Exercises 풀이 + Ch.7 마무리 |
“Ch.7 의 15 exercises 는 § 7.1~7.8 의 모든 도구를 다양한 데이터에 통합 적용 — one-sample 2 (Ex 7.1·7.2) + K-sample 4 (Ex 7.3~7.6) + trend 1 (Ex 7.7) + stratified+multiple 4 (Ex 7.8~7.11) + alternative tests 3 (Ex 7.12·7.13·7.14) + fixed-time 1 (Ex 7.15). 각 문제의 핵심: (a) 적절한 검정 선택 → (b) weight 결정 → (c) 식 적용 (식 7.2.4, 7.3.6, 7.4.2, 7.5.4, 7.5.7, 7.6.3, 7.7.x) → (d) 임상 해석. Ch.7 시리즈 마무리 + Ch.8 (Cox PH) 으로의 자연 연결.”
2 15 문제 분류표
| Ex | 데이터 | 도구 | 절 |
|---|---|---|---|
| 7.1 | Rheumatoid arthritis 40명 vs 1989 US mortality | One-sample log-rank | 7.2 |
| 7.2 | Autologous BMT vs Exp λ=0.045 (단측) | One-sample 단측 + early weight | 7.2 |
| 7.3 | Burn 2 군 (chlorhexidine vs routine) | Log-rank·Gehan·Tarone-Ware | 7.3 |
| 7.4 | Tongue ploidy 2 군 (early difference) | Log-rank + Gehan | 7.3 |
| 7.5 | Larynx 4 stage K=4 | Log-rank omnibus | 7.3 |
| 7.6 | HIV triple drug 2 군 | Log-rank | 7.3 |
| 7.7 | BNCT rats 3 군 (ordered) | Pairwise + Trend test | 7.3·7.4 |
| 7.8 | BMT aGVHD 3 군 + left truncation | Stratified | 7.5 |
| 7.9 | Kidney transplant race × sex 4 군 | Global + stratified | 7.5 |
| 7.10 | Larynx pairwise + Bonferroni | Multiple comparison | 7.3 |
| 7.11 | Larynx pre/post-1975 | Stratified | 7.5 |
| 7.12 | Ex 3·4 의 Renyi | Renyi (log-rank/Gehan) | 7.6 |
| 7.13 | Breast cancer 4 검정 | Log-rank + Renyi + CvM + W_KM | 7.6·7.7 |
| 7.14 | Ex 7.7 BNCT 의 alternatives | Renyi + CvM + W_KM | 7.6·7.7 |
| 7.15 | BMT 3 군 1 년 시점 | Fixed-time + Bonferroni | 7.8 |
3 Group A — One-Sample Tests (§ 7.2)
3.1 Ex 7.1 — Rheumatoid Arthritis 40명
40 명 rheumatoid arthritis 환자 (1~18 년 추적):
- 9 deaths: female (66, 74), (60, 76), … + male (50, 59), (60, 66), …
- 31 survivors: \(L_j\) + \(T_j\) pair.
참조: 1989 US all-cause mortality (Klein Table 2.1, sex-specific).
Step 1: 각 환자 \(j\) 의 sex 별 \(H_0(L_j)\) + \(H_0(T_j)\) — 1989 US life table.
Step 2: 차이 \(H_0(T_j) - H_0(L_j)\) 합산 → \(E\).
Step 3: \(O = 9\).
Step 4: \(\chi^2 = (O - E)^2 / E\).
예상 결과:
- Rheumatoid arthritis 의 SMR 약 2~3 (전형적 임상 결과).
- \(E \approx 3 \sim 5\) → \(O - E \approx 5 \sim 6\) → \(\chi^2 \approx 6 \sim 9\) → \(p < 0.01\).
→ Rheumatoid arthritis 환자의 사망률 일반인 대비 유의 증가.
§ 7.1~7.2 deep-dive 의 Iowa psychiatric (β≈25) 보다 약한 효과지만 동일 framework.
3.2 Ex 7.2 — Autologous BMT vs Exp λ=0.045
Klein § 1.4 Table 1.4 의 autologous BMT (Klein Ex 6.5 의 reference).
참조: \(h_0(t) = 0.045\) (constant Exponential).
가설:
- \(H_0\): \(h(t) = 0.045\).
- \(H_A\): \(h(t) > 0.045\) (autologous 가 chemo 보다 위험 큼) — 단측.
식 7.2.4 with \(h_0 = 0.045\) 일정:
\[ H_0(t) = 0.045 t \]
\[ E = \sum_j [H_0(T_j) - H_0(L_j)] = 0.045 \cdot \sum_j (T_j - L_j) = 0.045 \cdot (\text{total person-time}) \]
→ \(E\) 가 person-time 의 단순 함수.
단측 검정: \(Z = (O - E)/\sqrt{E}\), \(p = P(Z > Z_{\text{obs}})\).
Early weight (FH \(p=1, q=0\)):
\[ W(t) = Y(t) S_0(t) = Y(t) e^{-0.045 t} \]
→ 초기 (\(t\) 작을 때 \(S_0\) 크고 \(Y\) 큼) 강조.
예상 결과: BMT 의 초기 사망률이 chemotherapy 보다 높으면 early weight 가 검정력 강함.
4 Group B — K-Sample Tests (§ 7.3)
4.1 Ex 7.3 — Burn 2 군 (3 Weight)
154 명 burn unit 환자: chlorhexidine 84 + routine bathing 70.
문제:
- Log-rank (\(W=1\)).
- Gehan (\(W=Y_i\)).
- Tarone-Ware (\(W=\sqrt{Y_i}\)).
양측 0.05.
식 7.3.7 (두 군) 적용 with 3 weight.
예상 결과:
- Chlorhexidine 군이 infection 늦음 (실험 가설).
- 세 weight 모두 유의 (PH 가까움 시 일관) 또는 차이 (PH 위반 시 weight 별 다른 결론).
→ 세 weight 결과 일관성 점검. 일관 → robust 결론. 다르면 → PH 위반 의심.
4.2 Ex 7.4 — Tongue Ploidy 2 군 (Early Difference)
80 명 tongue cancer: aneuploid 52 + diploid 28.
문제:
- Log-rank.
- 초기 차이 강조 — Gehan (\(W=Y_i\)) 또는 FH \(p=1, q=0\).
표준 log-rank.
초기 가중:
- Gehan: 큰 위험집합 (초기) 가중.
- FH \(p=1, q=0\): \(W = \widehat{S}(t_{i-1})\) — 큰 \(S\) (초기) 가중.
임상 의도: aneuploid 의 초기 hazard 가 diploid 보다 큰 가설 (DNA ploidy 가 종양 공격성 지표) → 초기 차이 강조 검정력 강함.
예상 결과: 두 weight 모두 유의 (또는 다른 결론 가능). FH 가 log-rank 보다 더 작은 \(p\) 면 초기 차이 검출.
4.3 Ex 7.5·7.6 — Larynx 4 stage + HIV 2 그룹
§ 7.3·7.4 deep-dive 의 Klein Example 7.6 와 동일.
- 식 7.3.6 의 K=4 χ² with 3 df.
- Trend test 와 비교: trend Z=3.72 (방향성), omnibus χ² ≈ 14 (방향성 무시).
→ Trend 가 더 강력 (ordered alternative 활용).
AZT+ddC (n=17) vs AZT+ddC+saquinavir (n=17). 시간 = CD4 count 회복.
Log-rank 식 7.3.7 적용. 둘 다 작은 표본 — 검정력 약하지만 큰 효과면 검출 가능.
임상 함의: triple drug 가 효과 있으면 작은 sample 에도 검출. 효과 없거나 약하면 비유의.
5 Group C — Trend Test (§ 7.4)
5.1 Ex 7.7 — BNCT 3 군 (Ordered)
F98 glioma rats 30 마리:
- Untreated 10.
- Radiated 10.
- Radiated + BPA 10.
Hazard 순서 가설 (a priori):
\[ h_{\text{untreated}} > h_{\text{radiated}} > h_{\text{radiated+BPA}} \]
(즉 hazard 가 감소하는 ordered alternative).
(a) 3 군 KM plot + 시각적 비교:
- Untreated: 가장 빨리 사망 (median ~25 일).
- Radiated: 약간 개선 (~30 일).
- Radiated+BPA: 가장 좋음 (~36 일).
(b) 3 pairwise log-rank:
- Untreated vs Radiated.
- Radiated vs Radiated+BPA.
- Untreated vs Radiated+BPA.
→ 다중 검정 → Bonferroni \(\alpha/3 = 0.0167\) 권장.
(c) Trend test (식 7.4.2):
점수 \(a_j = 1, 2, 3\) (또는 hazard 감소 가정 시 \(-1, -2, -3\) 으로 부호).
식 7.4.2 적용 → 단일 z-test.
예상 결과:
- Trend test: \(|Z| > 3\) 가능 (강한 ordered effect).
- Pairwise: 인접 군은 약함, 양 끝 (untreated vs BPA) 강함.
→ Trend test 가 ordered 가정 활용으로 가장 강력.
6 Group D — Stratified + Multiple Comparison (§ 7.5)
6.1 Ex 7.8 — BMT aGVHD (Left Truncation)
137 명 BMT (3 군: ALL + AML low + AML high).
3 단계 검정:
- aGVHD 발생률 3 군 검정 (acute graft-versus-host).
- Relapse 3 군 검정.
- aGVHD 후 relapse 3 군 검정 — left truncation at aGVHD time.
임상 가설: aGVHD 가 graft-vs-leukemia (antileukemic) effect → aGVHD 발생자가 relapse 적음.
표준 식 7.3.6 — aGVHD 시점이 사건.
표준 — relapse 시점이 사건.
Left-truncation 처리:
- 표본: aGVHD 발생한 환자만.
- Entry time $L_j = $ aGVHD time.
- Event time $T_j = $ relapse time (또는 censored).
- 식 7.3.3 의 \(Y_{ij}\): \(L_j < t \leq T_j\) 인 개체.
→ § 4.6 의 좌절단 framework 그대로 적용.
예상 결과:
- aGVHD 발생률 일정 (3 군 차이 약함).
- Relapse 3 군 차이 큼 (low risk 좋음).
- aGVHD 발생자 한정 시 relapse 차이 약함 (graft-vs-leukemia 가 평탄화).
→ aGVHD 의 antileukemic effect 가 통계적 검정.
6.2 Ex 7.9 — Kidney Transplant 4 군
863 명 kidney transplant: Black female, Black male, White female, White male (4 군 = race × sex).
문제:
- 4 군 global 검정.
- Sex 별 race 검정 (Black female vs White female, Black male vs White male).
- Stratified by sex — race 차이 (Black vs White, sex 보정).
식 7.3.6 K=4 omnibus.
두 개 별도 두 군 검정 (식 7.3.7).
Stratified by sex (식 7.5.4):
- Strata 1: female (Black vs White).
- Strata 2: male (Black vs White).
- \(Z_{\text{strat}} = (Z_{1F} + Z_{1M})/\sqrt{\sigma_{11F} + \sigma_{11M}}\).
기대 결과:
- Black 이 White 보다 mortality 높을 가능성 (역사적 disparity).
- Stratified 가 sex 보정으로 race effect 정량화.
→ Public health 의 race-specific intervention 의 통계적 근거.
6.3 Ex 7.10 — Larynx Pairwise + Bonferroni
Klein Example 7.6 (larynx 4 stage) 의 인접 pairwise:
- Stage 1 vs Stage 2.
- Stage 2 vs Stage 3.
- Stage 3 vs Stage 4.
다중 검정 보정: Bonferroni → 각 검정 α/3 = 0.0167.
Klein 의 단축 형태:
\[ \frac{Z_j(\tau) - Z_{j+1}(\tau)}{\sqrt{\widehat{\sigma}_{jj} + \widehat{\sigma}_{j+1,j+1} - 2 \widehat{\sigma}_{j,j+1}}} \]
→ Full \(Z(\tau)\) 벡터 + 공분산 행렬 활용 (다시 계산 불필요).
Klein Example 7.6 의 결과:
\[ Z(10.7) = (-7.566, -3.012, 2.916, 7.662) \]
\[ \widehat{\Sigma} = \begin{pmatrix} 12.07 & -4.45 & -6.25 & -1.38 \\ -4.45 & 7.87 & -2.76 & -0.66 \\ -6.25 & -2.76 & 9.93 & -0.92 \\ -1.38 & -0.66 & -0.92 & 2.96 \end{pmatrix} \]
Pair 1 vs 2:
\[ Z_1 - Z_2 = -7.566 - (-3.012) = -4.554 \]
분산 = \(12.07 + 7.87 - 2 \cdot (-4.45) = 28.84\) → \(\sqrt{} = 5.37\).
\(Z_{12} = -4.554/5.37 = -0.85\) → \(|Z| < 1.96\) → 비유의.
Pair 2 vs 3:
\(Z_2 - Z_3 = -3.012 - 2.916 = -5.928\). 분산 = \(7.87 + 9.93 - 2 \cdot (-2.76) = 23.32\) → \(\sqrt{} = 4.83\). \(Z_{23} = -5.928/4.83 = -1.23\) → 비유의.
Pair 3 vs 4:
\(Z_3 - Z_4 = 2.916 - 7.662 = -4.746\). 분산 = \(9.93 + 2.96 - 2 \cdot (-0.92) = 14.73\) → \(\sqrt{} = 3.84\). \(Z_{34} = -4.746/3.84 = -1.24\) → 비유의.
Bonferroni 임계값: \(|Z| > Z_{0.0167/2} \approx 2.39\) → 3 인접 pair 모두 비유의.
→ 인접 stage 차이는 약함. 그러나 trend test 는 강력 (\(Z = 3.72\), Klein Example 7.6) — ordered alternative 가 인접 pair 의 신호를 누적해 검출.
6.4 Ex 7.11 — Larynx Pre/Post-1975 Stratification
Larynx cancer 데이터 (1970~1978) 의 시간 trend confounding 보정:
- Strata: pre-1975 vs post-1975 (치료법 변화 가능).
- 4 stage 차이 + sex 보정.
식 7.5.3 (K-sample stratified):
- Pre-1975 strata: \(Z_{js, \text{pre}}\) 와 \(\widehat{\Sigma}_{\text{pre}}\).
- Post-1975 strata: \(Z_{js, \text{post}}\) 와 \(\widehat{\Sigma}_{\text{post}}\).
- Pooling: \(Z_{j \cdot} = Z_{j, \text{pre}} + Z_{j, \text{post}}\), \(\widehat{\Sigma}_\cdot = \widehat{\Sigma}_{\text{pre}} + \widehat{\Sigma}_{\text{post}}\).
- χ² with K-1 df.
별도 strata 검정: 각 strata 별 K=4 χ² 도 보고.
기대 결과: 전체 trend 와 stratified 가 일관 → 시간 confounding 무시 가능. 차이 크면 → 시간 trend 의 영향.
7 Group E — Alternative Tests (§ 7.6·7.7)
7.1 Ex 7.12 — Renyi Versions
- Ex 7.3 burn 2 군의 Renyi log-rank (식 7.6.3):
- \(W = 1\) 의 sequential 누적 \(Z(t_i)\).
- \(\sup |Z(t)|/\sigma(\tau)\).
- Brownian motion sup 분포 (Klein Appendix C.5).
- Ex 7.4 tongue ploidy 의 Renyi Gehan:
- \(W = Y_i\) 의 sequential 누적.
- 동일 procedure.
비교 — log-rank vs Renyi:
- PH 가까움 + 약한 censoring: 거의 동일.
- PH 위반 (crossing): Renyi 강력.
- Heavy censoring: Renyi advantage 약함.
→ 두 결과 모두 보고 → robust 결론.
7.2 Ex 7.13 — Breast Cancer 4 검정
Breast cancer 의 lymph node 분류:
- SLM (standard light microscopy) negative.
- IH (immunohistochemistry) negative.
가설: IH 가 micrometastasis 검출 → IH negative 가 진정한 negative → 더 좋은 생존.
4 검정:
- Log-rank.
- Renyi log-rank.
- Cramer-von Mises Q1, Q2.
- Pepe-Fleming W_KM.
작은 표본 (n = 9 IH+ + 36 IH-) — 다양 검정의 결과 비교가 의미.
- Log-rank: PH 가정 시 최적.
- Renyi: crossing hazards 시 강력.
- CvM Q1: PH 가까움 시 효율적.
- CvM Q2: crossing 시 강력.
- W_KM: censoring 패턴 다른 두 군 시 robust.
일관 결론: 모두 유의 또는 비유의 → robust.
비일관: 각 검정의 가정 점검 필요.
7.3 Ex 7.14 — BNCT Renyi/CvM/W_KM
Ex 7.7 BNCT 3 군 → 두 군씩 6 pair 또는 K=3 omnibus.
- Renyi log-rank.
- CvM.
- W_KM.
기대: PH 가깝고 monotone effect → log-rank·Renyi·CvM 모두 유의 (BPA 우월).
비교: trend test (Ex 7.7c) 와 alternative 검정 일관성.
8 Group F — Fixed-Time Test (§ 7.8)
8.1 Ex 7.15 — BMT 1 년 시점
Klein § 1.3 BMT 3 군의 1 년 시점 \(S_j(365)\) 비교.
- Overall 3 군 비교.
- Bonferroni 3 pairwise.
각 군의 \(\widehat{S}_j(365)\) + Greenwood 분산:
- ALL: \(\widehat{S}(365) = 0.55\) (Klein Example 4.2).
- AML low: \(\widehat{S}(365) = 0.78\).
- AML high: \(\widehat{S}(365) = 0.38\).
(a) Overall — wald 형 χ²:
\[ \chi^2 = \sum_j \left(\frac{\widehat{S}_j(365) - \bar{S}}{\sqrt{V[\widehat{S}_j]}}\right)^2 \sim \chi^2_{K-1} \]
(또는 다른 fixed-time formulation).
(b) Pairwise:
- ALL vs AML low: \(Z = (0.55 - 0.78)/\sqrt{V_{ALL} + V_{low}}\).
- ALL vs AML high: \(Z = (0.55 - 0.38)/\sqrt{V_{ALL} + V_{high}}\).
- AML low vs high: \(Z = (0.78 - 0.38)/\sqrt{V_{low} + V_{high}}\).
Bonferroni: \(\alpha/3 = 0.0167\), \(|Z| > 2.39\) 기각.
기대:
- AML low vs high: 매우 큰 차이 → 유의.
- AML low vs ALL: 중간 차이 → 가능성 있음.
- ALL vs AML high: 작은 차이 → 비유의 가능.
→ 임상 위험 layer 분류 의 통계적 근거.
9 Ch.7 시리즈 통합 7 가지 교훈
NA framework 의 통일 — § 7.1~7.8 모든 검정이 “관측 - 기대” 가중 합. § 7.2 one-sample → § 7.3 K-sample → § 7.4 trend → § 7.5 stratified·matched → § 7.6 Renyi → § 7.7 alternative → § 7.8 fixed-time. 동일 출발점.
6 weight 가족 (§ 7.3) — log-rank·Gehan·Tarone-Ware·Peto-Peto·Andersen·Fleming-Harrington. PH 가정 + 시점 강조 의도에 따라 선택.
Crossing hazards 의 cancel-out 함정 — Klein Example 7.2 dialysis log-rank 비유의 vs FH p=0,q=1 매우 유의. Klein 7.5 BMT auto/allo. Klein 7.9 GITSG. PH 위반 의심 시 다양 검정 + Renyi/CvM 권장.
Trend test (§ 7.4) — Ordered alternative 시 단일 z-test 로 강력 (Klein 7.6 larynx Z=3.72). Pairwise (Ex 7.10 인접 비유의) 와 비교 시 검정력 강함.
Stratified (§ 7.5) — Covariate 보정. 동일 방향 시 강력, reversed effect 시 cancel out (Klein 7.7 BMT). 별도 strata 보고 권장.
Matched pairs (§ 7.5 식 7.5.7) — Censored sign test (\(Z = (D_1-D_2)/\sqrt{D_1+D_2}\)). 6-MP Klein 7.8: \(Z=3.27, p=0.001\). 작은 표본 + 강한 검정력.
Multiple comparison + Bonferroni (Ex 7.10·7.15) — K 개 pairwise 시 \(\alpha/K\) 임계값. Family-wise error rate 보정. 작은 표본 시 매우 보수적 — alternative: Holm, BH.
10 Ch.8 예고 — Cox Proportional Hazards Model
Ch.7 의 한계:
- 군 간 검정만 — “유의 차이 있다” 답하지만 효과 크기 모름.
- Continuous covariate 처리 안 됨 (예: 연속 연령).
- 다중 covariate (sex + age + treatment) 조합 어려움.
Ch.8 의 Cox PH:
\[ h(t \mid Z) = h_0(t) \exp(\beta^T Z) \]
- \(\beta\): covariate 효과 크기 (점추정 + CI).
- Continuous + categorical 모두 처리.
- 다중 covariate 동시 모형.
Ch.7 와 Ch.8 의 자연 연결:
- Cox PH 의 partial likelihood 의 score test at \(\beta = 0\) = log-rank 검정 (Ch.7 § 7.3).
- 즉 Ch.7 의 log-rank 가 Cox PH 의 특수 경우.
Ch.8 의 5 절:
| 절 | 주제 |
|---|---|
| 8.1 | Introduction + 식 8.1.1·2·3 |
| 8.2 | Coding covariates |
| 8.3 | Partial likelihood (구별 사건시간) |
| 8.4 | Tied event times (Breslow·Efron·Exact) |
| 8.5 | Local tests (LR · Wald · Score) |
| 8.6 | Discretizing continuous |
| 8.7 | Model building |
| 8.8 | Survival function estimation |
→ Ch.7 의 검정 framework 가 Ch.8 의 회귀의 기반. 자연스러운 확장.
11 응용 분야 (Ch.7 통합)
| 분야 | 주요 검정 | 예시 |
|---|---|---|
| 임상시험 표준 | Log-rank | Phase III |
| 면역치료 (delayed) | FH p<q | Pembrolizumab |
| 만성 질환 cohort | Log-rank + stratified | Framingham |
| 인구통계 standardized | One-sample log-rank | SMR |
| Matched cohort | 식 7.5.7 sign | Twin study |
| Multi-center | Stratified by center | Phase III multi-site |
| Crossing hazards | Renyi / CvM / W_KM | BMT auto vs allo |
| Multiple comparisons | Bonferroni · Holm · BH | 다군 약물 비교 |
| Single time-point | Fixed-time | 1·5 년 OS 보고 |
12 코드 예시
12.1 Ex 7.7 — Trend Test (R coin)
library(coin)
library(survival)
# F98 glioma rats 30 마리
times <- c(20, 21, 23, 24, 24, 26, 26, 27, 28, 30, # untreated
26, 28, 29, 29, 30, 30, 31, 31, 32, 35, # radiated
31, 32, 34, 35, 36, 38, 38, 39, 42, 42) # radiated+BPA
events <- c(rep(1, 9), 1, # untreated 10 사건
rep(1, 9), 0, # radiated 9 사건 + 1 censored
rep(1, 8), 0, 0) # BPA 8 사건 + 2 censored
group <- factor(c(rep(1, 10), rep(2, 10), rep(3, 10)),
levels = c(1, 2, 3),
labels = c("Untreated", "Radiated", "BPA"),
ordered = TRUE)
# Trend test (Jonckheere-Terpstra censored 일반화)
result <- logrank_trend_test(Surv(times, events) ~ group,
data = data.frame(times, events, group),
scores = list(group = c(1, 2, 3)))
print(result)
# 강력한 유의 결과 예상12.2 Ex 7.10 — Pairwise + Bonferroni (R)
library(survival)
# Klein Example 7.6 — larynx pairwise
# (실제 데이터 로드)
larynx <- read.csv("larynx_data.csv") # 가상
# 인접 pairwise
for (i in 1:3) {
sub <- subset(larynx, stage %in% c(i, i+1))
fit <- survdiff(Surv(time, event) ~ stage, data = sub)
p <- 1 - pchisq(fit$chisq, df = 1)
cat(sprintf("Stage %d vs %d: chi² = %.2f, p = %.4f, Bonferroni = %.4f\n",
i, i+1, fit$chisq, p, p * 3))
}12.3 Ex 7.13 — 4 검정 비교 (Python lifelines + 직접)
from lifelines.statistics import logrank_test
import numpy as np
# Breast cancer SLM vs IH (Klein § 1.5)
times_slm = np.array([...])
events_slm = np.array([...])
times_ih = np.array([...])
events_ih = np.array([...])
# (a) Log-rank
result_lr = logrank_test(times_slm, times_ih,
events_slm, events_ih)
print(f"Log-rank: chi² = {result_lr.test_statistic:.2f}, p = {result_lr.p_value:.4f}")
# (b) Renyi — 직접 구현 (07-3 deep-dive 의 코드)
# (c) CvM Q1, Q2 — 직접 구현 (식 7.7.3·4)
# (d) W_KM — 직접 구현 (식 7.7.6·8)12.4 Ex 7.15 — Fixed-Time + Bonferroni
from lifelines import KaplanMeierFitter
from scipy.stats import norm
def fixed_time_pairwise(times1, events1, times2, events2, t0, alpha=0.05/3):
"""식 7.8.1 — Fixed-time z-test with Greenwood variance"""
kmf1 = KaplanMeierFitter().fit(times1, events1)
kmf2 = KaplanMeierFitter().fit(times2, events2)
S1_t0 = float(kmf1.predict(t0))
S2_t0 = float(kmf2.predict(t0))
# Greenwood variance 직접 계산 (lifelines 의 confidence_interval 활용 가능)
V1 = ... # 식 4.2.2
V2 = ...
Z = (S1_t0 - S2_t0) / np.sqrt(V1 + V2)
p = 2 * (1 - norm.cdf(abs(Z)))
significant = p < alpha
return Z, p, significant
# BMT 3 군 1 년 시점
# ALL vs AML low, ALL vs AML high, AML low vs AML high13 관련 주제
선행 지식
- Ch.7 Overview
- § 7.1~7.2 — One-Sample
- § 7.3~7.4 — K-Sample + Trend
- § 7.5~7.6 — Stratified + Renyi
- § 1.3 — BMT (Ex 7.8·7.15 출처)
- § 1.5 — Breast Cancer (Ex 7.13)
- § 1.6 — Burn (Ex 7.3·7.12)
- § 1.7 — Kidney Transplant (Ex 7.9)
- § 1.8 — Larynx (Ex 7.5·7.10·7.11)
- § 1.11 — Tongue (Ex 7.4)
후속 주제
- Ch.8 — Cox Proportional Hazards Model (score test = log-rank)
- Ch.9 — Cox Refinements (time-varying coefficients · stratified Cox · multistate)
- Ch.10 — Aalen Additive (additive 회귀)
관련 개념
- Bonferroni vs Holm vs BH multiple comparison
- Family-wise error rate vs FDR
- Pitman efficiency 비교 (Schumacher 1984)
- Cox PH 의 score test = log-rank — Ch.8 의 핵심 연결