§ 10.2.3 — Discrete-Time Survival Analysis Models: Cumulative Ordinal 과 Proportional Hazards 의 만남

Failure 확률 (식 10.9) · Grouped-time PH (식 10.10) · Mixed-effects PH 모형 (식 10.11) · Ordinal vs Pooled Dichotomous 데이터 표현 (Table 10.1) · 조건부 failure 확률 (식 10.12) · 시간 가변 공변량 (식 10.13) · Complementary log-log ICC (π²/6)

Hedeker & Gibbons (2006) Ch.10 §10.2.3 의 자세한 풀이. 이산 시간 (discrete-time) 또는 그룹화 시간 (grouped-time) 생존 데이터의 분석에서, 사건 발생 시점을 ordinal 응답으로 보면 mixed-effects ordinal regression 의 직접 응용이 된다. McCullagh (1980) 의 grouped-time proportional hazards 모형 (식 10.10) 이 complementary log-log link 의 ordinal 모형과 동일 — Prentice & Gloeckler (1978) 가 보인 사실을 mixed-effects 로 확장 (Hedeker et al. 2000, Reardon et al. 2002, Muthen & Masyn 2005). 식 (10.11) 의 mixed-effects 모형은 §9.5.5 의 c-log-log 와 §10.2 의 cumulative ordinal 의 결합. 같은 데이터의 두 가지 표현 — ordinal (Y, d) 한 행 vs pooled dichotomous (시점별 행) — 의 Table 10.1 비교, 두 표현이 c-log-log link 에서 동일 결과를 주는 이유 (Lr-Matthews 1985, Engel 1993), 그러나 시간 가변 공변량 (식 10.12-10.13) 과 비례 위반 처리에서는 pooled dichotomous 가 우월한 점, 마지막으로 §10.2.3.1 의 c-log-log ICC (\(\pi^2/6\) 분모, Agresti 2002) 까지 정리한다.

Statistics
저자

Kwangmin Kim

공개

2026년 05월 06일

1 들어가며 — Survival 과 Ordinal 의 만남

Ch.10 Overview (10-0) 에서 § 10.2.3 의 핵심 — 이산 시간 비례 위험 모형이 c-log-log link 의 ordinal 모형과 동등 — 을 미리 언급했다. 본 sub-post 는 그 등가성을 정량적으로 다루고, 같은 데이터의 두 표현 방법 (ordinal vs pooled dichotomous) 을 비교한다.

두 framework 의 만남
출신 모형 응답 형태
§ 9.5.5 C-log-log link 이항 모형 \(Y \in \{0, 1\}\)
§ 10.2 Cumulative logit 순서형 모형 \(Y \in \{1, 2, \ldots, C\}\)
§ 10.2.3 Discrete-time PH 모형 \(Y = c\) (사건 시점)

핵심 관찰: 사건 발생 시점이 ordinal 응답. Cumulative ordinal 모형의 link 만 logit → c-log-log 으로 바꾸면 그것이 곧 grouped-time proportional hazards 모형.

Hedeker 책의 두 framework 가 한 자리에서 결합. Ch.9 의 c-log-log + Ch.10 의 cumulative ordinal = 이산 시간 생존 모형.

한 줄 요약

“§ 10.2.3 = 사건 발생 시점이 이산 (\(c = 1, 2, \ldots, C\)) 이면 ordinal 응답으로 다룰 수 있다. McCullagh (1980) 의 식 (10.10) — c-log-log link cumulative 모형 — 이 그룹화 시간 PH 모형과 동일 (Prentice-Gloeckler 1978). Hedeker et al. (2000) 가 mixed-effects 로 확장 (식 10.11). 같은 데이터 두 표현: ordinal (환자당 한 행, \(Y\) + \(d\)) 또는 pooled dichotomous (환자당 여러 행, 시점별 censoring/event). 두 접근이 c-log-log 에서 동일 결과 (Lr-Matthews 1985), 그러나 시간 가변 공변량과 비례 위반 처리는 pooled dichotomous 가 자연 (식 10.12-10.13). c-log-log 의 ICC 분모는 \(\pi^2/6\) (Agresti 2002) — logit 의 \(\pi^2/3\) 의 절반.”

2 § 10.2.3 — Discrete-Time Proportional Hazards 의 자리

2.1 동기 — 왜 이산 시간 생존이 ordinal 인가

이산 시간 생존 데이터의 정의

각 환자 \(ij\) (피험자 \(i\), 측정 단위 \(j\)) 의 응답:

  • 시점 \(c \in \{1, 2, \ldots, C\}\): 사건 발생 또는 censoring 발생 시점.
  • Censoring indicator \(d_{ij}\):
    • \(d_{ij} = 1\): 시점 \(c\) 에서 사건 발생 (event).
    • \(d_{ij} = 0\): 시점 \(c\) 에서 관측 종료 (censoring) — 환자가 시점 \(c\) 까지 사건 없음.

→ 응답이 “언제 사건이 일어났는가” 의 시점. 시점이 ordinal (1 → 2 → … → C) 이라 ordinal 응답으로 다룰 수 있다.

직관 — 연속 시간 PH 와의 차이

연속 시간 (continuous-time) 생존 분석:

  • 사건 시점 \(T\) 가 실수 (예: 124.7 일).
  • Cox PH 모형: \(h(t \mid x) = h_0(t) \exp(x^\top \beta)\).
  • 추정: 부분 우도 (partial likelihood, Cox 1972).

이산 시간 (discrete-time) 생존 분석:

  • 사건 시점이 시간 구간 (예: 첫 주, 둘째 주, 셋째 주, …).
  • 데이터가 그룹화되어 측정됨 — 임상시험에서 매주, 매월 follow-up 같은 경우.
  • 또는 진짜로 이산 시간 (학기말 합격 여부 등).

이산 시간 PH 모형의 link 함수가 c-log-log:

\[ \log[-\log(1 - P_{ijc})] = \gamma_c + x_{ij}^\top \beta \]

이것이 연속 시간 Cox PH 와 수학적으로 일관된 이산 버전 — Prentice & Gloeckler (1978) 이 보임. 자세한 도출은 § 9.5.5 의 c-log-log 부분 + Allison (1995).

→ 이산 시간 데이터에 logit 이나 probit 을 쓰면 비례 위험 가정이 깨진다. c-log-log 이 정답.

2.2 발전사 — Survival 과 Ordinal 의 통합

핵심 문헌

이산 시간 생존 ↔︎ 이항/순서 회귀 의 연결:

  • Allison (1982, 1995): 실용적 introduction, dichotomous 표현법.
  • D’Agostino et al. (1990): 의학 통계 응용.
  • Singer & Willett (1993, 2003): 교육 통계 응용.

Mixed-effects 확장:

  • Han & Hausman (1990): 초기 제안.
  • Ten Have & Uttal (1994), Ten Have (1996): 임상 응용.
  • Scheike & Jensen (1997): 통계적 토대.
  • Hedeker, Siddiqui & Hu (2000): c-log-log mixed PH 정립.
  • Reardon, Brennan & Buka (2002): Multilevel PH 응용.
  • Muthen & Masyn (2005): 잠재 클래스 + 생존.
직관 — 왜 이 framework 가 1990s 에 발전했는가

연속 시간 Cox PH 와 이산 시간 데이터의 불일치 문제는 오래 전부터 알려져 있었다. 그러나 이산 시간 PH 의 mixed-effects 확장은 1990s 부터 본격화 — 두 가지 발전이 합쳐졌기 때문:

  1. Mixed-effects logistic 의 정립 (Bock-Aitkin 1981 이후) — Gauss-Hermite quadrature 추정 가능.
  2. GLMM 의 link 함수 일반화 — c-log-log 도 logit, probit 과 같은 framework 위.

이 둘이 결합하면 자연스럽게 mixed-effects c-log-log = mixed-effects PH for grouped survival. Hedeker 자신이 이 분야의 핵심 기여자 (Hedeker, Siddiqui & Hu 2000).

응용: 임상 follow-up (매월 측정), 학교 progression (학년 단위), 직업 이직 (annual survey) 같은 본질적으로 이산 시간 데이터.

3 식 (10.9-10.11) — Ordinal Approach

3.1 식 (10.9) — Failure 확률의 정의

Cumulative failure 확률

\(P_{ijc}\) = 시점 \(c\) 까지 사건이 일어났을 확률:

\[ P_{ijc} = \Pr[Y_{ij} \leq c] \tag{10.9} \]

여기서 \(Y_{ij}\) 는 사건 발생 시점.

생존 함수 (survivor function): \(1 - P_{ijc} = \Pr[Y_{ij} > c]\) — 시점 \(c\) 까지 사건 없이 생존할 확률.

직관 — Ordinal 의 cumulative 확률과 동일

식 (10.9) 의 \(P_{ijc} = P(Y \leq c)\) 가 § 10.2 의 cumulative ordinal 확률 정의와 정확히 같다. 차이는 해석:

  • Ordinal: “응답이 \(c\) 이하의 범주에 속할 확률”.
  • Survival: “사건이 시점 \(c\) 까지 일어났을 누적 확률”.

같은 수학, 다른 의미. → 두 framework 가 통합되는 자연스러운 출발점.

3.2 식 (10.10) — McCullagh (1980) 의 Grouped-Time PH

식 (10.10) — Single-level 모형

\[ \log[-\log(1 - P_{ijc})] = \gamma_c + x_{ij}^\top \beta \tag{10.10} \]

C-log-log link function. 직접 풀면:

\[ P_{ijc} = 1 - \exp(-\exp(\gamma_c + x_{ij}^\top \beta)) \]

여기서:

  • \(x_{ij}\): 시간 무관 공변량 (level-1 또는 level-2). 시간에 따라 변하지 않는 값.
  • \(\gamma_c\): 절단점 — log of integrated baseline hazard (when \(x = 0\)).
  • \(\beta\): 회귀 계수. 양의 값 = 위험 ↑ = 사건 빨리 발생 (\(Y\) 작은 값).
직관 — c-log-log 가 왜 PH 모형인가

연속 시간 Cox PH:

\[ h(t \mid x) = h_0(t) \exp(x^\top \beta) \]

이산 시간으로 그룹화:

  • 시점 \(c\) 의 hazard \(\lambda_c(x) = P(Y = c \mid Y \geq c, x)\).
  • 비례 위험 가정: \(\lambda_c(x) / \lambda_c(0) = \exp(x^\top \beta)\) (시점 \(c\) 무관).

이를 survival function 으로 표현하면 (Prentice-Gloeckler 1978):

\[ S(c \mid x) = 1 - P_{ijc} = [S(c \mid 0)]^{\exp(x^\top \beta)} \]

양변에 \(\log[-\log(\cdot)]\) 적용:

\[ \log[-\log S(c \mid x)] = \log[-\log S(c \mid 0)] + x^\top \beta = \gamma_c + x^\top \beta \]

→ 식 (10.10) 도출. c-log-log link 가 비례 위험 가정을 자연스럽게 표현.

logit 이나 probit 을 쓰면 비례 가정이 깨진다 — 이산 시간 PH 의 정확한 표현이 c-log-log 의 자리.

부호 관행: 식 (10.10) 은 식 (10.6) 의 + 부호 (생존분석 관행). 식 (10.1) 의 - 부호 (의학 관행) 와 반대. 양의 \(\beta\) = 사건 빨리 발생 = lower \(Y\).

추가 성질 — Allison (1982) 의 invariance

식 (10.10) 의 \(\beta\) 계수의 두 가지 중요한 성질:

  1. 연속 시간 PH 와 동일: 그룹화로 인한 정보 손실 없이 같은 \(\beta\).
  2. Interval length 에 invariant: 시간 구간을 다시 정의 (예: 매주 → 매월) 해도 \(\beta\) 계수가 변하지 않음.

이 두 성질이 c-log-log link 의 결정적 우위. logit 으로 같은 데이터를 적합하면:

  • 회귀 계수가 연속 시간 Cox 와 다름.
  • Interval length 에 의존 — 시간 구간을 다시 만들면 결과 변함.
  • 그러나 모든 시간 구간이 같은 길이일 때만 일관된 해석 가능 (Allison 1982).

→ 이산 시간 생존 분석에는 c-log-log 사용 권고. logit 은 편의를 위해 쓸 수 있지만 해석에 주의.

3.3 식 (10.11) — Mixed-Effects 확장

식 (10.11) — Random effects 추가

\[ \log[-\log(1 - P_{ijc})] = \gamma_c + x_{ij}^\top \beta + z_{ij}^\top T \theta_i \tag{10.11} \]

기존 single-level 모형 (식 10.10) 에 random effects \(z_{ij}^\top T \theta_i\) 추가.

\(\theta_i \sim \mathcal{N}_r(0, I)\), \(T\) 는 Cholesky factor.

Mixed-effects ordinal regression with c-log-log response function.

직관 — 두 framework 의 통합 결과

식 (10.11) 의 의미:

  • 응답 형태: ordinal (\(Y = c\) for 사건 발생 시점).
  • Link 함수: c-log-log (PH 가정).
  • 분포: ordinal mixed-effects (cumulative).
  • Random effects: 환자 이질성 (잠재 frailty 같은 것).

§ 10.2 의 cumulative framework + § 9.5.5 의 c-log-log link + § 9.5.2 의 random effects 의 결합.

추정 (§ 10.2.4 다음 sub-post) 도 같은 toolkit:

  • Marginal MLE (식 10.11 의 우도를 random effects 로 적분).
  • Gauss-Hermite quadrature.
  • Cholesky factor \(T\) 의 Fisher scoring.

새로 배울 게 거의 없다 — 이전 두 chapter 의 framework 가 자동 적용.

Frailty model 과의 관계: 연속 시간 frailty PH 모형 (Vaupel et al. 1979, Hougaard 1995) 의 이산 버전이 식 (10.11). \(\theta_i\) 가 환자별 frailty (관측되지 않은 위험 성향) 의 표현.

4 두 데이터 표현 — Ordinal vs Pooled Dichotomous

4.1 Table 10.1 — 같은 데이터의 두 표현

3 시점 사례의 비교
결과 Ordinal: \(Y\) Ordinal: \(d\) (event) Dichotomous: \(Y_1\) Dichotomous: \(Y_2\) Dichotomous: \(Y_3\)
Censor at T1 1 0 1 (생존)
Event at T1 1 1 0 (사건)
Censor at T2 2 0 1 (생존) 1 (생존)
Event at T2 2 1 1 (생존) 0 (사건)
Censor at T3 3 0 1 (생존) 1 (생존) 1 (생존)
Event at T3 3 1 1 (생존) 1 (생존) 0 (사건)
직관 — 두 표현의 차이

Ordinal 표현: 환자당 한 행.

  • 응답 = 사건 발생 시점 \(Y \in \{1, 2, 3\}\).
  • 추가 변수 = censoring indicator \(d \in \{0, 1\}\).
  • 데이터 셋 크기: 환자 수 만큼.

Pooled dichotomous 표현 (Cupples et al. 1985): 환자당 여러 행 (관측된 시점 수만큼).

  • 각 시점마다 별도 record.
  • 응답 = 그 시점에 생존 여부 (1) 또는 사건 발생 (0).
  • 사건 발생 후의 시점은 record 없음 — risk set 에서 제외.
  • 데이터 셋 크기: \(\sum_{ij} Y_{ij}\) — 모든 환자가 모든 시점 관측되었으면 환자 수 × 시점 수.

→ Ordinal 은 간결, dichotomous 는 유연.

왜 다른 표현이 필요한가: 시간 가변 공변량 처리. 다음 절에서 자세히.

4.2 식 (10.12-10.13) — Pooled Dichotomous Approach

식 (10.12) — 조건부 failure 확률

조건부로 표현된 hazard:

\[ p_{ijc} = \Pr[Y_{ij} = c \mid Y_{ij} \geq c] \tag{10.12} \]

“시점 \(c\) 까지 생존한 상태에서, 그 시점에 사건 발생할 확률” — 정확히 hazard 의 이산 버전.

\(1 - p_{ijc}\): 시점 \(c\) 까지 생존한 상태에서, 그 시점 너머 생존할 확률.

식 (10.13) — Pooled dichotomous 의 PH 모형

\[ \log[-\log(1 - p_{ijc})] = x_{ijc}^\top \beta + z_{ij}^\top T \theta_i \tag{10.13} \]

핵심 차이: \(x\)\(c\) 첨자를 가짐 (\(x_{ijc}\)). 즉 시간 가변 공변량 직접 표현.

\(x\) 의 첫 원소는 보통 시점 dummy code (시점 1, 2, …, C 표시).

직관 — 시간 가변 공변량의 자연 처리

식 (10.13) 의 \(x_{ijc}\) 가 갖는 의미:

  • \(x_{ijc}^{(1)}\): 시점 dummy (예: \(\text{week}_1, \text{week}_2, \text{week}_3\)). \(\gamma_c\) 의 역할 흡수.
  • \(x_{ijc}^{(2)}\): 시간 가변 처치 (예: 약물 dose 가 매주 변함).
  • \(x_{ijc}^{(3)}\): 시점-처치 interaction (비례 위반 검정용).

이런 처리가 식 (10.11) 의 ordinal approach 에는 어렵다 — 응답이 한 행에 한 번이라 시간 가변 공변량의 매 시점 값을 하나의 record 에 표현하기 곤란.

두 접근법의 사용 기준:

상황 권고 접근 이유
시간 무관 공변량만 Ordinal 데이터 간결, 같은 결과
시간 가변 공변량 Pooled dichotomous 자연 처리
비례 가정 검정 (시점 × 공변량 interaction) Pooled dichotomous 시점 dummy 와의 interaction 직접
많은 시점 (예: 50+ 시점) Ordinal Dichotomous 데이터 셋 크기 폭발
적은 시점 (예: 2-5 시점) Pooled dichotomous 데이터 크기 부담 작음
두 접근법의 등가성 (Lr-Matthews 1985, Engel 1993)

c-log-log link 에서 식 (10.11) 의 ordinal 모형과 식 (10.13) 의 pooled dichotomous 모형이 시간 무관 공변량의 회귀 계수에 대해 동일한 결과 를 준다.

증명의 핵심: c-log-log link 의 수학적 성질 — cumulative failure 확률과 conditional hazard 가 단순한 곱으로 분해 가능 (생존 함수의 product representation).

\[ 1 - P_{ijc} = \prod_{k=1}^c (1 - p_{ijk}) \]

→ Cumulative survival = product of conditional survival. 이 분해가 c-log-log link 에서 회귀 모형으로 표현될 때 같은 \(\beta\) 가 두 접근에 등장.

Logit, probit 에는 이 등가성이 성립 안 함 — 또 다른 c-log-log 의 특별한 성질.

4.3 두 접근법의 비교 — 실무 권고

사용 결정 트리
시간 가변 공변량이 있는가?
├─ 예 → Pooled dichotomous (식 10.13)
└─ 아니오 → 비례 가정 검정이 필요한가?
            ├─ 예 → Pooled dichotomous (시점 dummy interaction 용이)
            └─ 아니오 → 시점 수가 많은가 (50+)?
                       ├─ 예 → Ordinal (식 10.11) (데이터 효율)
                       └─ 아니오 → 두 접근 모두 가능 (선호 따름)

소프트웨어 지원:

  • Ordinal approach: R ordinal::clm(link = "cloglog"), SAS PROC LOGISTIC link=cloglog.
  • Pooled dichotomous: R glm(family = binomial(link = "cloglog")), R survival::coxph (간접).
  • Mixed-effects pooled: R lme4::glmer(family = binomial(link = "cloglog")), Stata mecloglog.
  • Mixed-effects ordinal c-log-log: 직접 지원 부족 — Hedeker MIXOR 또는 brms.

실무 빈도: 의학 종단 연구에서는 보통 시간 가변 공변량 (약물 dose 변경, 추가 처치 등) 이 있어 pooled dichotomous 가 더 흔함. Ordinal approach 는 시간 구간이 매우 많거나 (50+) 단순한 시간 무관 분석 사례에서.

6 응용 분야

분야 사건 시점 단위 권고 link
임상 follow-up 재발, 사망 매월 C-log-log
학교 progression 진학, 자퇴 학년 C-log-log
직업 이직 회사 떠남 매년 C-log-log
디지털 헬스 약물 중단 매주 C-log-log
보험 lapse 보험 해지 매월 C-log-log
학습 성취 시험 통과 시도별 C-log-log
항암 임상 response 매주 C-log-log

→ “이산 시간 단위로 측정된 사건 시점 데이터” 면 모두 c-log-log 적용 대상.

7 코드 예시

7.1 Step 1: Discrete-time Survival 데이터 시뮬레이션

import numpy as np
import pandas as pd


def simulate_discrete_survival(n: int, n_times: int, beta: float,
                                gamma: list, sigma_v: float,
                                seed: int = 2026) -> pd.DataFrame:
    """식 (10.11) 로부터 discrete-time PH 데이터 생성.

    각 환자가 사건 발생 시점 또는 censoring 시점 한 개를 가짐.
    """
    rng = np.random.default_rng(seed)

    # 환자 수준 변수
    x = rng.binomial(1, 0.5, size=n)  # 이항 공변량 (예: 처치 그룹)
    upsilon = rng.normal(0, sigma_v, size=n)

    # 각 환자의 사건 발생 시점 결정
    Y = np.zeros(n, dtype=int)
    d = np.zeros(n, dtype=int)

    for i in range(n):
        # 매 시점별 conditional hazard
        survived = True
        for c in range(1, n_times + 1):
            # P(failure at c | survived through c-1) — c-log-log
            eta = gamma[c-1] + beta * x[i] + upsilon[i]
            hazard = 1 - np.exp(-np.exp(eta))

            if rng.random() < hazard:
                Y[i] = c
                d[i] = 1
                survived = False
                break

        if survived:
            Y[i] = n_times
            d[i] = 0  # censored at last time

    return pd.DataFrame({"subject": np.arange(n), "x": x, "Y": Y, "d": d,
                          "upsilon": upsilon})


# 시뮬레이션 — 4 시점, 처치 효과 -0.5 (위험 ↓)
gamma = [-3.0, -2.5, -2.0, -1.5]  # 시점별 baseline log-cumulative-hazard
df = simulate_discrete_survival(n=500, n_times=4, beta=-0.5,
                                  gamma=gamma, sigma_v=0.8)

# 결과
print(f"전체: N = {len(df)}")
print(f"\n그룹별 사건 발생 비율:")
print(df.groupby("x").apply(lambda g: pd.Series({
    "n": len(g), "events": g["d"].sum(),
    "median_Y": g["Y"].median()
})))
시뮬레이션의 검증

처치 그룹 (\(x = 1\), \(\beta = -0.5\) → hazard ↓) 의 효과:

  • 사건 발생 비율이 placebo 보다 낮아야 함.
  • 사건 발생 시점의 median 이 placebo 보다 늦어야 함 (위험 ↓ → 사건 늦게).

위 코드의 출력에서 이 패턴 확인 가능.

7.2 Step 2: Ordinal vs Pooled Dichotomous 데이터 변환

def to_pooled_dichotomous(df_ordinal: pd.DataFrame) -> pd.DataFrame:
    """Ordinal (Y, d) 표현을 pooled dichotomous (시점별 행) 로 변환.

    Table 10.1 의 변환.
    """
    rows = []
    for _, row in df_ordinal.iterrows():
        Y, d, x, subject = row["Y"], row["d"], row["x"], row["subject"]
        for c in range(1, int(Y) + 1):
            if c < Y:
                # 시점 c 에서 생존 (사건 안 일어남)
                event = 0  # survival = 1, but in c-log-log we model failure
            elif c == Y:
                if d == 1:
                    event = 1  # 시점 c 에서 사건 발생
                else:
                    event = 0  # 시점 c 에서 censoring (마지막 record)
            rows.append({"subject": subject, "time": c, "x": x,
                         "event": event,
                         "censored": (c == Y) and (d == 0)})
    return pd.DataFrame(rows)


df_dich = to_pooled_dichotomous(df)

print(f"Ordinal: {len(df)} 행 (환자 수)")
print(f"Pooled dichotomous: {len(df_dich)} 행 (환자 × 관측 시점)")
print(f"\n첫 5 환자의 ordinal 표현:")
print(df.head())
print(f"\n첫 환자의 pooled dichotomous 표현:")
print(df_dich[df_dich["subject"] == df.iloc[0]["subject"]])
변환의 검증
  • 사건 발생 환자: \(Y\) 만큼 record (마지막 record 의 event = 1).
  • Censoring 환자: \(Y\) 만큼 record (마지막 record 의 event = 0, censored = True).
  • 데이터 셋 총 크기: \(\sum_i Y_i\).

이 변환이 Table 10.1 의 정확한 구현. R survival::survSplit 도 비슷한 변환 제공.

7.3 Step 3: Two Approach 의 적합 비교 (R)

library(survival)
library(ordinal)


# 데이터 생성 (위 Python 시뮬레이션과 같은 구조)
set.seed(2026)
n <- 500
n_times <- 4
x <- rbinom(n, 1, 0.5)
upsilon <- rnorm(n, 0, 0.8)
gamma <- c(-3.0, -2.5, -2.0, -1.5)
beta_true <- -0.5

Y <- numeric(n)
d <- numeric(n)
for (i in 1:n) {
  for (c in 1:n_times) {
    haz <- 1 - exp(-exp(gamma[c] + beta_true * x[i] + upsilon[i]))
    if (runif(1) < haz) {
      Y[i] <- c
      d[i] <- 1
      break
    }
  }
  if (Y[i] == 0) {
    Y[i] <- n_times
    d[i] <- 0
  }
}

df_ord <- data.frame(subject = 1:n, x = x, Y = factor(Y, ordered = TRUE), d = d)

# Approach 1: Ordinal c-log-log
fit_ord <- clm(Y ~ x, data = df_ord, link = "cloglog")
summary(fit_ord)

# Approach 2: Pooled dichotomous
df_pool <- do.call(rbind, lapply(1:n, function(i) {
  data.frame(
    subject = i,
    time = factor(1:Y[i]),
    x = x[i],
    event = c(rep(0, Y[i] - 1), if (d[i] == 1) 1 else 0)
  )
}))

fit_pool <- glm(event ~ x + time, data = df_pool,
                family = binomial(link = "cloglog"))
summary(fit_pool)

# x 의 회귀 계수가 두 모형에서 거의 같아야 함 (Lr-Matthews 1985)
cat("\nOrdinal x coefficient:    ", coef(fit_ord)[1], "\n")
cat("Pooled dichotomous x coefficient: ", coef(fit_pool)["x"], "\n")
등가성 검증

두 모형의 x 회귀 계수가 거의 같으면 (반올림 오차 내) Lr-Matthews 1985 의 등가성 확인.

차이의 원인:

  • 절단점 / 시점 dummy 의 표기가 다름.
  • 추정 알고리즘 차이 (clm 은 이산 ordinal MLE, glm 은 표준 GLM).
  • 표본의 sparse 한 시점에서 수치 불안정.

두 접근법 모두 random effects 미포함 (single-level) — Mixed-effects 확장은 다음 단계.

7.4 Step 4: Mixed-effects c-log-log PH (R)

library(lme4)


# Pooled dichotomous + random intercept (식 10.11 / 10.13 의 mixed)
fit_mixed <- glmer(event ~ x + time + (1 | subject),
                   data = df_pool,
                   family = binomial(link = "cloglog"))
summary(fit_mixed)

# c-log-log 의 ICC 계산 (식 §10.2.3.1)
sigma2_v <- as.numeric(VarCorr(fit_mixed)$subject)
icc_cloglog <- sigma2_v / (sigma2_v + pi^2 / 6)
cat("\nC-log-log ICC = sigma_v^2 / (sigma_v^2 + pi^2/6) = ",
    round(icc_cloglog, 3), "\n")

# 비교: 같은 모형을 logit 으로 적합 (잘못된 link 의 효과)
fit_logit <- glmer(event ~ x + time + (1 | subject),
                   data = df_pool,
                   family = binomial(link = "logit"))
sigma2_v_logit <- as.numeric(VarCorr(fit_logit)$subject)
icc_logit <- sigma2_v_logit / (sigma2_v_logit + pi^2 / 3)
cat("Logit ICC = sigma_v^2 / (sigma_v^2 + pi^2/3) = ",
    round(icc_logit, 3), "\n")

# 회귀 계수 비교
cat("\n회귀 계수 (cloglog vs logit):\n")
cat("  cloglog x: ", round(fixef(fit_mixed)["x"], 3), "\n")
cat("  logit x:   ", round(fixef(fit_logit)["x"], 3), "\n")
cat("  진짜 beta: ", beta_true, "\n")
C-log-log vs Logit 의 결과 비교

c-log-log 가 정확한 link (시뮬레이션이 c-log-log 로 생성됨) → 회귀 계수가 진짜 \(\beta\) 에 가까움. ICC 분모는 \(\pi^2/6\).

Logit 으로 적합하면:

  • 회귀 계수가 약간 다름 — 분포 형태 차이 (\(\sqrt{2}\) 정도 inflated).
  • ICC 분모가 \(\pi^2/3\) — 같은 \(\sigma_v^2\) 에서 ICC 가 c-log-log 보다 작음.
  • Interval length 변경에 민감 (Allison 1982).

결론: 이산 시간 생존 데이터에는 c-log-log link 우선. Logit 은 편의를 위한 근사로 사용 가능하나 해석에 주의.

Mixed-effects 의 추가 수익:

  • 환자 frailty \(\theta_i\) 의 정량화.
  • 일부 환자가 일관되게 빠른 사건 (또는 늦은 사건) 발생 패턴 식별.
  • ICC 가 frailty 의 강도를 표현.

8 관련 주제

선행 지식

후속 주제 (Ch.10 sub-posts)

  • § 10.2.4 — Estimation (cumulative ordinal 의 marginal MLE 세부)
  • § 10.3 — NIMH 4 범주 ordinal 분석 (Ch.9 이항 분석과 비교)
  • § 10.4 — 노숙자 보건서비스 (section 8 certificate 의 비례 위반)

관련 개념

  • McCullagh (1980) — Grouped-time PH 모형
  • Prentice & Gloeckler (1978) — 그룹화 시간 PH 모형 원전
  • Allison (1982, 1995) — Discrete-time survival 의 표준 introduction
  • Singer & Willett (1993, 2003) — 교육 통계 응용
  • Hedeker, Siddiqui & Hu (2000) — Mixed-effects c-log-log PH
  • Reardon, Brennan & Buka (2002) — Multilevel PH 응용
  • Cupples et al. (1985) — Pooling of repeated observations 명명
  • Lr & Matthews (1985), Engel (1993) — 두 접근법의 등가성
  • Vaupel et al. (1979) — Frailty 모형 원전
  • Ch.9 GEE — Marginal 대안 (subject-specific frailty 와 비교)
  • Statistics survival series — 연속 시간 생존 분석

Subscribe

Enjoy this blog? Get notified of new posts by email: