1 들어가며 — 13-0 의 적분 분해를 깊이로
Ch.13 Overview (13-0) 에서 § 13.2 의 적분 분해 trick (식 13.9) 의 큰 그림을 제시했다. 본 sub-post 는 § 13.2 + § 13.2.1 + § 13.2.2 의 수학적 도출 + 추정 알고리즘.
“§ 13.2 = Linear (식 13.1) 와 Nonlinear 의 결정적 차이 — Nonlinear 는 closed form 적분 없음, numerical integration 필수. §13.2.1 Probit 깊이: 식 (13.2) 의 3-level matrix representation, 식 (13.3) latent variable \(y_{ijk} = \upsilon_{0i} + z'\upsilon_{ij} + x'\beta + \varepsilon\), 식 (13.4) \(P = \Phi(z)\), 식 (13.5) conditional likelihood (independence given random effects). Cholesky reparameterization (식 13.7) + \(\gamma = 0, \sigma_\varepsilon = 1\) identification. 결정적 trick — 식 (13.8-13.9) 의 적분 분해 (cluster \(\theta_{(3)}\) 외부 + subject \(\theta_{(2)}\) 내부 = \(r + 1\) 차원). 식 (13.11-13.13) score 의 chain rule + Gibbons-Bock (1987) scoring + Stroud-Sechrest Gauss-Hermite. §13.2.2 Logistic = 식 (13.14-13.15) 의 단순 대체 (\(\Phi \to \Psi\), \(\phi \to \Psi(1-\Psi)\)), \(\sigma_\varepsilon^2 = \pi^2/3\), tail probability 의 rare events 응용.”
2 § 13.2 — Linear vs Nonlinear 의 결정적 차이
2.1 Nonlinear 의 적분 어려움
“The primary difference between linear and nonlinear mixed-effects models is that in the nonlinear case, evaluation of the likelihood requires an \(r\)-dimensional integration over the joint distribution of the level-two and level-three random effects. This integration can either be performed numerically using fixed-point or adaptive quadrature (e.g., Gauss-Hermite quadrature) or using some form of Monte Carlo simulation method (e.g., Markov Chain Monte Carlo-MCMC).”
Linear 3-level (§ 13.1):
- Conjugate prior (normal-normal) → 적분이 closed form.
- \(h(y_i) = \int f(y_i \mid \upsilon^*) g(\upsilon^*) d\upsilon^*\) = explicit normal density.
- → EM + Fisher scoring 직접 적용.
Nonlinear 3-level (§ 13.2):
- 적분 안에 \(\Phi(z)\) 또는 \(\Psi(z)\) — nonlinear function.
- Closed form 없음.
- → Numerical integration 필요.
두 가지 numerical 방법:
- Gauss-Hermite quadrature (frequentist 표준):
- 정규 분포 가정에 최적화.
- 적분 = \(\sum_q f(B_q) A(B_q)\).
- 차원 폭발 위험 (\(Q^{\text{dim}}\)).
- MCMC (Bayesian):
- 사후 분포에서 표본 추출.
- 차원 무관 (다만 표본 크기에 따라 정확도).
- Gibbs sampler, NUTS 등.
적분 차원의 결정적 중요성:
- Naive 3-level 적분 차원 = \(n_i \times r + 1\) — cluster size 와 random effects 수에 비례.
- Cluster size 큼 + multiple random effects → 차원 폭발.
- 식 (13.9) 의 분해가 차원 절약의 핵심 trick.
3 § 13.2.1 — Three-Level Probit 의 정확한 도출
3.1 식 (13.2) — 3-Level Matrix Representation
Cluster \(i\) 의 latent response vector \(y_i\) (\(N_i \times 1\)):
\[ y_i = X_i \beta + Z_i \upsilon^* + \varepsilon_i \tag{13.2} \]
Block 구조 (13-1 의 § 13.1 에서 다룸):
\[ Z_i = \begin{bmatrix} 1 & Z_{i1} & 0 & \cdots & 0 \\ 1 & 0 & Z_{i2} & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & 0 & 0 & \cdots & Z_{i n_i} \end{bmatrix} \]
표기:
- \(\upsilon_{0i} \sim \mathcal{N}(0, \sigma_{(3)}^2)\) — cluster random effect.
- \(\upsilon_{ij} \sim \mathcal{N}_r(0, \Sigma_{(2)})\) — subject random effects.
- \(\varepsilon_i \sim \mathcal{N}(0, \sigma_\varepsilon^2 I)\) — observation residual.
§ 13.2.1 의 핵심: Probit 모형의 binary 응답이 latent variable \(y_{ijk}\) 의 threshold function:
\[ \mathrm{y}_{ijk} = 1 \iff y_{ijk} > \gamma \]
Probit 의 \(\gamma = 0\) 표준 가정 (identification):
- 잠재 변수의 origin 식별 불가능 → 임의 fixed 가능.
- \(\gamma = 0\) 이 가장 흔한 선택.
\(\sigma_\varepsilon = 1\) 표준 가정 (identification):
- 잠재 변수의 scale 식별 불가능 → 임의 fixed.
- \(\sigma_\varepsilon = 1\) (probit) 또는 \(\sigma_\varepsilon = \pi/\sqrt{3}\) (logistic).
→ § 9.4 (Bock 1975) 의 threshold concept 의 3-level 일반화.
3-level 의 새로운 점:
- Latent variable 이 cluster + subject + observation 세 수준의 변동 합.
- 식 (13.2) 의 matrix 가 이 hierarchical 구조 표현.
- → 정규 mixed-effects (식 13.1) 와 같은 framework, 응답이 binary 라는 차이.
3.2 식 (13.3-13.4) — Latent Variable + Conditional Probability
Subject \(j\) in cluster \(i\) at occasion \(k\) 의 latent response:
\[ y_{ijk} = \upsilon_{0i} + z_{ijk}^\top \upsilon_{ij} + x_{ijk}^\top \beta + \varepsilon_{ijk} \tag{13.3} \]
표기:
- \(\upsilon_{0i}\): cluster random intercept.
- \(z_{ijk}^\top \upsilon_{ij}\): subject random effects (intercept, trend 등).
- \(x_{ijk}^\top \beta\): fixed effects.
- \(\varepsilon_{ijk}\): residual.
\(\upsilon^* = (\upsilon_{0i}, \upsilon_{ij})\) 조건부:
\[ P(\mathrm{y}_{ijk} = 1 \mid \upsilon^*) = \Phi[-(\gamma - z_{ijk})/\sigma_\varepsilon] = \Phi(z_{ijk}) \tag{13.4} \]
with \(z_{ijk} = \upsilon_{0i} + z_{ijk}^\top \upsilon_{ij} + x_{ijk}^\top \beta\) (after \(\gamma = 0, \sigma_\varepsilon = 1\)).
식 (13.4) 의 도출:
\[ P(\mathrm{y}_{ijk} = 1 \mid \upsilon^*) = P(y_{ijk} > 0 \mid \upsilon^*) = \int_0^\infty f(y_{ijk} \mid \upsilon^*) dy_{ijk} \]
\(y_{ijk} \mid \upsilon^* \sim \mathcal{N}(z_{ijk}, \sigma_\varepsilon^2)\) 로부터:
\[ P(\mathrm{y}_{ijk} = 1 \mid \upsilon^*) = 1 - \Phi(-z_{ijk}/\sigma_\varepsilon) = \Phi(z_{ijk}/\sigma_\varepsilon) \]
\(\sigma_\varepsilon = 1\) 가정으로:
\[ P(\mathrm{y}_{ijk} = 1 \mid \upsilon^*) = \Phi(z_{ijk}) \]
§ 9.4 (이항) 의 식 (9.10) 와 정확히 같은 형태 — 단지 \(z_{ijk}\) 가 3-level random effects 포함.
§ 9 의 식 (9.10): \(z = x'\beta + \sigma_v \theta_i\) (2-level, 단일 random effect).
§ 13.2.1 의 식 (13.4): \(z = \upsilon_{0i} + z'\upsilon_{ij} + x'\beta\) (3-level, multiple random effects).
→ Framework 동일, 차원 확장.
3.3 식 (13.5-13.6) — Conditional Likelihood + Marginal
같은 cluster 의 모든 응답이 random effects 조건부 독립:
\[ \ell(\mathrm{y}_i \mid \upsilon^*) = \prod_{j=1}^{n_i} \prod_{k=1}^{n_{ij}} [\Phi(z_{ijk})]^{\mathrm{y}_{ijk}} [1 - \Phi(z_{ijk})]^{1 - \mathrm{y}_{ijk}} \tag{13.5} \]
중요: independence 가 cluster 안의 모든 환자, 모든 시점 에 적용 — random effects \(\upsilon^* = (\upsilon_{0i}, \upsilon_{i1}, \upsilon_{i2}, \ldots, \upsilon_{i n_i})\) 조건부.
\[ h(y_i) = \int_{\upsilon^*} \ell(y_i \mid \upsilon^*) g(\upsilon^*) d\upsilon^* \tag{13.6} \]
\(g(\upsilon^*)\) = \(\upsilon^*\) 의 prior (다변량 정규).
적분 차원: \(\dim(\upsilon^*) = (n_i \times r) + 1\).
식 (13.6) 의 차원:
| 시나리오 | \(r\) | \(n_i\) | \(\dim(\upsilon^*)\) | \(Q^{\text{dim}}\) (\(Q=5\)) |
|---|---|---|---|---|
| 작은 cluster | 1 | 5 | 6 | 15,625 |
| 중간 cluster | 2 | 10 | 21 | \(\sim 10^{14}\) |
| 큰 cluster | 1 | 100 | 101 | \(\sim 10^{70}\) |
→ Naive 적분 (식 13.6) 은 실용 불가능.
해결 — 식 (13.9) 의 분해:
- Cluster random effect \(\theta_{(3)}\) 만 외부 적분 (1 차원).
- Subject random effects \(\theta_{(2)}\) 가 conditional 독립 → 각 subject 별로 별도 \(r\) 차원 적분.
- 총 차원 = \(r + 1\) (subject 와 cluster 합).
→ 다음 절의 핵심.
3.4 Cholesky Reparameterization — 식 (13.7)
\(\upsilon^* = T^* \theta^*\) where \(T^* T^{*\top} = \Sigma_{\upsilon^*}\) (Cholesky).
\(\theta^*\) = 표준화 random effects, \(\theta^* \sim \mathcal{N}(0, I)\).
Reparameterized model:
\[ z_{ijk} = \sigma_{(3)} \theta_{0i} + z_{ijk}^\top T \theta_{ij} + x_{ijk}^\top \beta \tag{13.7} \]
표기:
- \(\theta_{0i} = \upsilon_{0i} / \sigma_{(3)}\) — 표준화 cluster effect.
- \(\theta_{ij} = T^{-1} \upsilon_{ij}\) — 표준화 subject effects.
- \(T\) = Cholesky of \(\Sigma_{(2)}\) (\(r \times r\)).
- \(\sigma_{(3)}\) = scalar (cluster intercept SD).
§ 9.5.2 (식 9.24) 의 Cholesky reparameterization 의 3-level 확장:
2-level (§ 9):
\[ z_{ij} = x'\beta + z'T\theta_i, \quad \theta_i \sim \mathcal{N}_r(0, I) \]
3-level (§ 13.2.1):
\[ z_{ijk} = \sigma_{(3)} \theta_{0i} + z'T\theta_{ij} + x'\beta, \quad \theta_{0i} \sim \mathcal{N}(0, 1), \theta_{ij} \sim \mathcal{N}_r(0, I) \]
차이:
- Cluster random effect 추가: \(\sigma_{(3)} \theta_{0i}\) 항.
- Subject random effects: 같은 \(T\) matrix (모든 subject 동질).
Cholesky 의 가치 (§ 9.5.2 와 동일):
- 양정치 자동 보장: \(TT^\top\) 가 항상 양반정치.
- Boundary 안정: 분산 0 가까이에서 안정 추정.
- Gauss-Hermite quadrature 친화: 표준 정규 노드 사용.
3-level 의 추가 가치:
- \(\theta_{0i}\) (cluster) 와 \(\theta_{ij}\) (subject) 가 독립 — 분리 적분 가능 (식 13.9).
- Block-diagonal Cholesky 구조.
3.5 식 (13.8-13.9) — 적분 분해의 결정적 Trick
\[ h(y_i) = \int_{\theta^*} \ell(y_i \mid \theta^*) g(\theta^*) d\theta^* \tag{13.8} \]
with $g(^*) = $ multivariate standard normal.
문제: \(\dim(\theta^*) = (n_i \times r) + 1\) — 여전히 차원 폭발.
저자 본문 인용:
“conditional on the cluster-effect \(\theta_{(3)}\), the responses from the \(n_i\) subjects in cluster \(i\) are independent, therefore the marginal probability can be rewritten as …”
\[ h(\mathrm{y}_i) = \int_{\theta_{(3)}} \left\{ \prod_{j=1}^{n_i} \int_{\theta_{(2)}} \left( \prod_{k=1}^{n_{ij}} [\Phi(z_{ijk})]^{1-\mathrm{y}_{ijk}} [1 - \Phi(z_{ijk})]^{\mathrm{y}_{ijk}} \right) g(\theta_{(2)}) d\theta_{(2)} \right\} g(\theta_{(3)}) d\theta_{(3)} \tag{13.9} \]
적분 차원: \(r + 1\) (subject \(r\) 개 + cluster 1 개).
핵심 관찰 — Conditional independence:
- \(\theta_{(3)}\) (cluster effect) 가 fixed → subject 들이 conditional 독립.
- → Joint integral 이 외부 (cluster) + 내부 (subject) 로 factorize.
Step-by-step 도출:
Marginal 표기 (식 13.8):
\[ h(y_i) = \int_{\theta^*} \ell(y_i \mid \theta^*) g(\theta^*) d\theta^* \]
\(\theta^*\) 분해 — \(\theta^* = (\theta_{(3)}, \theta_{i1}, \theta_{i2}, \ldots, \theta_{i n_i})\):
\[ \ell(y_i \mid \theta^*) = \prod_{j=1}^{n_i} \ell_{ij}(\theta_{(3)}, \theta_{ij}) \]
where \(\ell_{ij}\) = subject \(j\) 의 conditional likelihood.
Independence 가정 — \(g(\theta^*) = g(\theta_{(3)}) \prod_j g(\theta_{ij})\).
식 (13.6) 에 대입:
\[ h(y_i) = \int_{\theta_{(3)}} g(\theta_{(3)}) \prod_{j=1}^{n_i} \left[\int_{\theta_{ij}} \ell_{ij}(\theta_{(3)}, \theta_{ij}) g(\theta_{ij}) d\theta_{ij}\right] d\theta_{(3)} \]
정리 → 식 (13.9).
계산 효율:
| 시나리오 | Naive (식 13.6) | 분해 (식 13.9) | 비율 |
|---|---|---|---|
| \(r=1, n_i=5, Q=5\) | \(5^6 = 15,625\) | \(5 \times 5 \times 5 = 125\) | 125x |
| \(r=2, n_i=10, Q=5\) | \(5^{21} \approx 5 \times 10^{14}\) | \(5 \times 5^2 \times 10 = 250\) | \(\sim 10^{12}\)x |
→ 3-level GLMM 의 추정 가능성이 식 (13.9) 에 전적으로 의존.
저자의 권고:
“the integration is of dimensionality \(r + 1\) and is tractable as long as the number of level two random effects is no greater than three or four. In longitudinal studies, we typically have one or two random effects at level two (e.g., a random intercept and/or trend for each individual) and one random effect at level three (e.g., a random cluster effect).”
→ 실무에서 보통 \(r = 1, 2\) + 1 cluster effect — 적분 가능.
3.6 식 (13.10-13.13) — Score Chain Rule
\[ \log L = \sum_{i=1}^N \log h(y_i) \tag{13.10} \]
모수 vector \(\eta = (\beta, v(T), \sigma_{(3)})\) 에 대한 score:
\[ \frac{\partial \log L}{\partial \eta} = \sum_i \frac{1}{h(y_i)} \int_{\theta_{(3)}} \ell_i(\theta_{(3)}) \left\{ \sum_j \frac{1}{h(y_{ij})} \int_{\theta_{(2)}} \sum_k \frac{y_{ijk} - \Phi(z_{ijk})}{\Phi(z_{ijk})[1 - \Phi(z_{ijk})]} \ell_{ij}(\theta) \phi(z_{ijk}) \frac{\partial z_{ijk}}{\partial \eta} g(\theta_{(2)}) d\theta_{(2)} \right\} g(\theta_{(3)}) d\theta_{(3)} \tag{13.11} \]
Subject-level conditional likelihood (식 13.12):
\[ \ell_{ij}(\theta) = \prod_{k=1}^{n_{ij}} [\Phi(z_{ijk})]^{1-y_{ijk}} [1 - \Phi(z_{ijk})]^{y_{ijk}} \]
Cluster-level marginal likelihood (식 13.13):
\[ \ell_i(\theta_{(3)}) = \prod_{j=1}^{n_i} \int_{\theta_{(2)}} \ell_{ij}(\theta) g(\theta_{(2)}) d\theta_{(2)} = \prod_{j=1}^{n_i} h(y_{ij}) \]
\[ \frac{\partial z_{ijk}}{\partial \beta} = x_{ijk}, \quad \frac{\partial z_{ijk}}{\partial \sigma_{(3)}} = \theta_{(3)}, \quad \frac{\partial z_{ijk}}{\partial v(T)} = J_r (\theta_{(2)} \otimes z_{ijk}) \]
\(J_r\) = Magnus (1988) elimination matrix (§ 9.6.2 와 동일).
\(\frac{y_{ijk} - \Phi(z_{ijk})}{\Phi(z_{ijk})[1 - \Phi(z_{ijk})]}\):
- 분자: 잔차 \(y - \Phi(z)\).
- 분모: probit 분산 \(\Phi(1-\Phi)\).
- 비율: standardized residual.
→ § 9.6 식 (9.44) 와 같은 형태.
\(\phi(z_{ijk})\) 항:
- Probit 의 pdf (chain rule from \(\Phi'\)).
- Score 의 weight.
적분 두 단계:
- 외부 적분 (\(\theta_{(3)}\)): cluster level — 1 차원.
- 내부 적분 (\(\theta_{(2)}\)): subject level — \(r\) 차원, 각 subject 별 별도.
→ 식 (13.9) 의 분해가 score 에도 적용.
모수별 미분:
- \(\beta\): \(x_{ijk}\) — fixed effects covariate.
- \(\sigma_{(3)}\): \(\theta_{(3)}\) — cluster random effect (외부 적분 변수).
- \(v(T)\): \(J_r (\theta_{(2)} \otimes z_{ijk})\) — § 9.6.2 식 (9.54) 의 3-level 확장.
Fisher scoring (저자 본문 인용):
“As in the 2-level case described by Gibbons and Bock [1987] and Gibbons et al. [1994] the method of scoring can be used to provide (marginal) MLEs and numerical integration on the transformed \(\theta\) space can be performed [Stroud and Sechrest, 1966].”
→ § 9.6 식 (9.47) 의 Fisher scoring + Gauss-Hermite 의 3-level 확장.
3.7 Random Effects 분포 Robustness
저자 본문 인용:
“An advantage of numerical integration is that alternative distributions for the random effects can be considered. Thus, for example, we can compare parameter estimates for a normal versus rectangular prior to determine the degree to which our estimates are robust to deviation from the assumed normality of the distribution for the random effects.”
§ 11.2 의 § 11.2.2 (10-2 의 § 10.2.2 의 평행) 에서 본 것과 같은 robustness check:
- Normal random effects: 표준 가정.
- Uniform random effects: skewness 위반 가정 검증.
검증 절차:
- Normal 적합 → fixed effects 추정.
- Uniform 적합 → 같은 fixed effects 추정.
- 두 결과 비교:
- 비슷 → 정규 가정 robust.
- 다름 → outlier 또는 분포 가정 검토.
Hedeker MIXOR/MIXNO/MIXPREG: normal + uniform 옵션 직접 지원.
현대 표준 — Bayesian flexibility:
brms의prior옵션으로 normal, t, cauchy 등.- Posterior predictive checks 로 분포 적합도.
- 작은 표본에서 robust prior 효과적.
3-level 의 추가 고려:
- 두 random effects 분포 모두 검증 (\(\theta_{(3)}\), \(\theta_{(2)}\)).
- 보통 둘 다 정규 가정 (관행).
4 § 13.2.2 — Three-Level Logistic Regression
4.1 식 (13.14-13.15) — 단순 변형
“In the previous discussion we have focused on a 3-level mixed-effects probit regression model, however, many researchers are more familiar with the logistic regression model. Fortunately, modification of the response function and associated likelihood equations is trivial.”
Probit → Logistic 의 두 변경:
식 (13.14) — Response function (cdf):
\[ \Phi(z_{ijk}) \to \Psi(z_{ijk}) = \frac{1}{1 + \exp[-z_{ijk}]} \]
식 (13.15) — Density (pdf):
\[ \phi(z_{ijk}) \to \Psi(z_{ijk})(1 - \Psi(z_{ijk})) \]
§ 9.5.5 의 logistic cdf-pdf 관계 (\(\psi = \Psi(1-\Psi)\)) 의 결정적 가치:
Score 의 단순화 (식 9.44 의 분자/분모 약분): \[ \frac{y - \Psi(z)}{\Psi(z)(1-\Psi(z))} \cdot \Psi(z)(1-\Psi(z)) = y - \Psi(z) \] → “잔차 × 공변량” 형태로 reduce.
계산 효율: \(\Psi(z) = 1/(1 + e^{-z})\) 만 계산 → pdf 자동 산출.
수치 안정: erf 같은 외부 함수 호출 불필요.
Probit vs Logistic 의 차이:
| 항목 | Probit | Logistic |
|---|---|---|
| Response function | \(\Phi(z)\) | \(\Psi(z)\) |
| Density | \(\phi(z)\) (standard normal) | \(\Psi(1-\Psi)\) |
| Latent residual variance (\(\sigma_\varepsilon^2\)) | 1 | \(\pi^2/3 \approx 3.29\) |
| Cdf-pdf 관계 | \(\phi\) 별도 계산 | \(\Psi(1-\Psi)\) 직접 |
| Cluster ICC 분모 | \(\sigma^2_\text{rand} + 1\) | \(\sigma^2_\text{rand} + \pi^2/3\) |
| 응용 | Family/genetic studies (tetrachoric) | 일반 임상 (OR 해석) |
| Tail probability | 가벼움 | 두꺼움 |
저자 본문의 logistic 권고:
“Application of the logistic response function is attractive in many cases in which the response probability is small because the logistic distribution has greater tail probability than the normal distribution.”
→ Rare events (낮은 확률) 에서 logistic 가 더 안정.
임상 예시:
- 자살 (rare event): logistic 권고.
- 흔한 outcome (예: 50% 비율): probit 또는 logistic 둘 다.
- 가족 연구: probit (tetrachoric correlation).
Logistic 잠재 잔차의 분산:
- 표준 logistic 분포 분산 = \(\pi^2/3 \approx 3.29\).
- Probit 의 1 보다 ~3.29 배.
ICC 분모 차이:
- Probit cluster ICC: \(\widehat\sigma_\gamma^2 / (\widehat\sigma_\gamma^2 + \widehat\sigma_\upsilon^2 + 1)\).
- Logistic cluster ICC: \(\widehat\sigma_\gamma^2 / (\widehat\sigma_\gamma^2 + \widehat\sigma_\upsilon^2 + \pi^2/3)\).
→ 같은 random effects 추정 기에서 logistic 의 ICC 가 작아 보임.
비교 시 표준화 환산 필요:
- Probit \(\sigma\) vs Logistic \(\sigma\) 의 \(\pi/\sqrt{3} \approx 1.81\) 배 차이.
- 같은 잠재 분산 척도로 환산 후 비교.
§ 9.5.5 의 식 (9.12) 와 동일 — \(\beta_L \approx 1.81 \beta_P\).
4.2 Tail Probability 의 임상적 의미
시각적 비교:
- Logistic: 꼬리가 normal 보다 약간 두꺼움 (kurtosis = 4.2 > 3).
- 꼬리 확률 차이: \(z = 3\) 에서 \(\Psi(3) = 0.953\) vs \(\Phi(3) = 0.999\).
Rare events 응용:
- 자살, 사고, 희귀 질환 등 — extreme value 의 정확한 모형화 중요.
- Logistic 의 두꺼운 꼬리가 extreme outcome 더 잘 처리.
예시 — 자살 prediction:
- \(z = 3\) 환자: 매우 위험.
- Probit 예측: \(\Phi(3) = 99.9\%\) — 거의 확실 자살.
- Logistic 예측: \(\Psi(3) = 95.3\%\) — 매우 위험 but 절대적이지 않음.
→ 임상에서는 logistic 의 보수적 예측이 더 적합 (false positive 회피).
Family studies / Genetic 응용:
- Tetrachoric/polychoric correlation (§ 9.5.5).
- 정규 잠재 변수 가정 자연.
- → probit 권고.
3-level 의 두 cluster ICC:
- Cluster ICC + Subject ICC 가 logistic vs probit 에서 다른 값.
- 그러나 잠재 분산 척도 환산 후 같은 임상 정보.
- 보고 시 link 함수 명시 필수.
5 응용 분야
| 분야 | 3-level 구조 | Probit vs Logistic |
|---|---|---|
| Multi-center 임상시험 | Center × Patient × Visit | Logistic (OR 해석) |
| 학교 효과 (이항) | School × Student × Test | Logistic (교육 표준) |
| Twin studies | Twin pair × Twin × Outcome | Probit (tetrachoric) |
| 가족 연구 | Family × Member × Outcome | Probit (genetic) |
| 종양 (rare) | Hospital × Patient × Outcome | Logistic (rare events) |
| 회사 효과 | Company × Employee × Performance | Logistic |
| Cross-classified | Region × District × Patient | Logistic (interpretation) |
6 코드 예시
6.1 Step 1: 3-Level Probit 시뮬레이션
library(lme4)
library(mvtnorm)
# 3-level binary 시뮬레이션 (probit)
set.seed(2026)
n_clusters <- 20
n_subjects_per_cluster <- 10
n_times_per_subject <- 5
# 모수
beta_0 <- 0.0
beta_time <- 0.3
beta_x <- 0.5
sigma_cluster <- 0.5 # cluster intercept SD (level 3)
sigma_subject_int <- 0.4 # subject intercept SD (level 2)
sigma_subject_slope <- 0.2 # subject slope SD (level 2)
# Cluster random effects
cluster_effects <- rnorm(n_clusters, 0, sigma_cluster)
df <- data.frame()
subject_id <- 0
for (i in 1:n_clusters) {
for (j in 1:n_subjects_per_cluster) {
subject_id <- subject_id + 1
# Subject random effects (intercept + slope)
subj_effects <- mvtnorm::rmvnorm(1,
mean = c(0, 0),
sigma = matrix(c(sigma_subject_int^2, 0,
0, sigma_subject_slope^2), 2))
v0 <- subj_effects[1]
v1 <- subj_effects[2]
for (k in 1:n_times_per_subject) {
time <- k - 1
x <- rnorm(1)
# 식 (13.3) — latent variable
eta <- cluster_effects[i] + v0 + v1 * time +
beta_0 + beta_time * time + beta_x * x
# Probit (식 13.4)
y_latent <- eta + rnorm(1, 0, 1) # sigma_eps = 1
y_binary <- as.numeric(y_latent > 0) # gamma = 0
df <- rbind(df, data.frame(
cluster = i, subject = subject_id,
time = time, x = x, y = y_binary
))
}
}
}
cat("전체 관측:", nrow(df), "\n")
cat("Subjects:", length(unique(df$subject)), "\n")
cat("Clusters:", length(unique(df$cluster)), "\n")
cat("응답 비율:", mean(df$y), "\n")3-level probit 의 latent variable 시뮬레이션:
- 식 (13.3) 의 잠재 변수 직접 생성.
- \(\gamma = 0\) threshold 으로 binary 응답.
- \(\sigma_\varepsilon = 1\) (probit 표준).
검증 포인트:
- Cluster effect (SD 0.5), subject effects (SD 0.4, 0.2).
- 응답 비율 ~ 50% (절편 0).
6.2 Step 2: 3-Level Probit 적합 (R glmer)
# R 의 glmer 는 probit 직접 지원
fit_3level_probit <- glmer(y ~ time + x + (1 + time | subject) + (1 | cluster),
data = df,
family = binomial(link = "probit"),
control = glmerControl(optimizer = "bobyqa"))
summary(fit_3level_probit)
# Fixed effects 추정값 비교
cat("\n추정값 (진짜 vs 추정):\n")
cat(" beta_time (진짜 0.3):", round(fixef(fit_3level_probit)["time"], 3), "\n")
cat(" beta_x (진짜 0.5):", round(fixef(fit_3level_probit)["x"], 3), "\n")
# Variance components
varcomp <- VarCorr(fit_3level_probit)
cat("\nRandom effects:\n")
cat(" Cluster SD (진짜 0.5):",
round(sqrt(as.numeric(varcomp$cluster)), 3), "\n")
cat(" Subject intercept SD (진짜 0.4):",
round(attr(varcomp$subject, "stddev")[1], 3), "\n")
cat(" Subject slope SD (진짜 0.2):",
round(attr(varcomp$subject, "stddev")[2], 3), "\n")
# 두 ICC 계산 (probit, sigma_eps = 1)
sigma_c <- as.numeric(varcomp$cluster)
sigma_s_int <- attr(varcomp$subject, "stddev")[1]^2
icc_cluster <- sigma_c / (sigma_c + sigma_s_int + 1)
icc_subject <- (sigma_c + sigma_s_int) / (sigma_c + sigma_s_int + 1)
cat("\nICC (probit, sigma_eps² = 1):\n")
cat(" Cluster ICC:", round(icc_cluster, 3), "\n")
cat(" Subject ICC (within cluster):", round(icc_subject, 3), "\n")glmer 의 3-Level Probit
Syntax — (1 + time | subject) + (1 | cluster):
- 첫 항: subject 별 random intercept + slope.
- 둘째 항: cluster 별 random intercept.
- → 식 (13.3) 의 정확한 모형.
Family — binomial(link = "probit"):
- Probit link 직접 지원.
- 결과 해석이 latent variable framework 자연.
ICC 계산:
- Probit: 분모 \(\sigma_\text{rand}^2 + 1\).
- Cluster ICC: cluster variance / total.
- Subject ICC (조건부): cluster + subject / total.
Convergence issue:
- 3-level + 다중 random effects → 수렴 어려움 가능.
optimizer = "bobyqa"또는Nelder_Mead시도.- nAGQ = 1 (Laplace) 만 가능 (다중 random effects 제약).
6.3 Step 3: 3-Level Logistic 적합 + Probit 비교
# 3-Level Logistic
fit_3level_logit <- glmer(y ~ time + x + (1 + time | subject) + (1 | cluster),
data = df,
family = binomial(link = "logit"),
control = glmerControl(optimizer = "bobyqa"))
summary(fit_3level_logit)
# Probit vs Logistic 비교
cat("\nFixed effects 비교 (Probit vs Logistic):\n")
print(round(rbind(
Probit = fixef(fit_3level_probit),
Logistic = fixef(fit_3level_logit)
), 3))
# Logistic 의 1.81 배 scale 비교 (식 9.12)
cat("\nLogistic / Probit 비율 (이론: ~1.81):\n")
print(round(fixef(fit_3level_logit) / fixef(fit_3level_probit), 2))
# Logistic ICC (분모 sigma_rand² + pi²/3)
varcomp_logit <- VarCorr(fit_3level_logit)
sigma_c_logit <- as.numeric(varcomp_logit$cluster)
sigma_s_int_logit <- attr(varcomp_logit$subject, "stddev")[1]^2
icc_cluster_logit <- sigma_c_logit / (sigma_c_logit + sigma_s_int_logit + pi^2/3)
icc_subject_logit <- (sigma_c_logit + sigma_s_int_logit) /
(sigma_c_logit + sigma_s_int_logit + pi^2/3)
cat("\nICC 비교:\n")
cat(" Probit cluster ICC:", round(icc_cluster, 3), "\n")
cat(" Logistic cluster ICC:", round(icc_cluster_logit, 3),
"(분모 차이로 작아 보임)\n")Fixed effects 비율 (이론: 1.81):
- Logistic estimate ≈ 1.81 × Probit estimate.
- 식 (9.12) 의 직접 검증.
ICC 차이:
- Probit ICC > Logistic ICC (분모 차이 때문).
- 같은 random effects 추정에서 다른 ICC 척도.
- 임상적 비교 시 표준화 환산 필요.
언제 어느 link 사용:
- 일반 연구: Logistic (OR 해석 친숙).
- Family/genetic: Probit (tetrachoric correlation).
- Rare events: Logistic (두꺼운 꼬리).
- Bayesian: 둘 다 가능.
6.4 Step 4: 적분 분해의 효과 검증
# Naive vs 분해 적분의 차원 비교 (시뮬레이션)
calculate_integration_dim <- function(n_subjects, r_random) {
naive_dim <- n_subjects * r_random + 1
decomposed_dim <- r_random + 1
cat("Subjects per cluster:", n_subjects, ", Random effects:", r_random, "\n")
cat(" Naive dim (식 13.6):", naive_dim, "\n")
cat(" Decomposed dim (식 13.9):", decomposed_dim, "\n")
cat(" 속도 향상 (Q=5):",
format(5^naive_dim / 5^decomposed_dim, big.mark = ",", scientific = TRUE),
"배\n\n")
}
# 본 시뮬레이션의 cluster
calculate_integration_dim(n_subjects = 10, r_random = 2)
# 본 NIMH 의 가장 큰 cluster (center 2: 22 subjects)
calculate_integration_dim(n_subjects = 22, r_random = 2)
# 큰 cluster scenario
calculate_integration_dim(n_subjects = 50, r_random = 1)본 시뮬레이션 (\(n_i = 10, r = 2\)):
- Naive: \(5^{21} \approx 5 \times 10^{14}\) 점.
- 분해: \(5^3 = 125\) 점.
- 속도 향상: \(4 \times 10^{12}\) 배.
→ 분해 없으면 추정 절대 불가능.
13-1 NIMH 의 큰 center (\(n_i = 22, r = 2\)):
- Naive: \(5^{45} \approx 3 \times 10^{31}\) 점.
- 분해: \(5^3 = 125\) 점.
- 속도 향상: \(2 \times 10^{29}\) 배.
→ 식 (13.9) 의 분해가 NIMH 분석을 가능하게 함.
일반 권고:
- \(r \leq 2, n_i \leq 100\): 분해 적분 충분.
- \(r \geq 3\): adaptive Gauss-Hermite 또는 Bayesian 우회.
- 매우 큰 cluster (\(n_i > 100\)): MCMC 권고.
현대 software:
- R
lme4::glmer: 자동 분해 + Laplace. - R
glmmTMB: 분해 + Laplace + AD. - SAS
PROC NLMIXED: adaptive Gauss-Hermite. brms: NUTS sampler — dimension 무관.
7 관련 주제
선행 지식
- Ch.13 Overview — 3-level data 의 큰 그림 + 적분 분해 trick
- § 13.1 Linear — Linear 3-level (적분 closed form)
- § 9.4 Threshold concept — Probit latent variable framework
- § 9.5.2 Cholesky — 식 (13.7) 의 토대
- § 9.5.5 Logistic vs Probit — 식 (13.14-13.15) 의 토대
- § 9.6 Marginal MLE + Gauss-Hermite — Score chain rule
후속 주제 (Ch.13 sub-posts)
- § 13.2.3 — Illustration (TVSFP study)
- § 13.2.4 — More general outcomes (ordinal, nominal, count)
- § 13.3 — Ch.13 Summary
관련 개념
- Bock (1975) — Threshold concept (probit 토대)
- Gibbons & Bock (1987) — Random intercept + trend probit (2-level 토대)
- Gibbons et al. (1994) — Mixed-effects probit 의 응용
- Hedeker & Gibbons (1994) — Logistic mixed-effects
- Magnus (1988) — Elimination matrix (식 13.13 의 toolkit)
- Stroud & Sechrest (1966) — Gauss-Hermite quadrature
- McCullagh & Nelder (1989) — GLM canonical link
- Self & Liang (1987) — Boundary LR test (variance test)
- § 12.4.1 Gauss-Hermite — § 13.2 의 Poisson 일반화