검정 평가 방법 — 합집합-교집합·교집합-합집합 검정의 크기

Sizes of Union-Intersection and Intersection-Union Tests: 복합 검정 크기의 상한과 정확한 값

합집합-교집합 검정(UIT)과 교집합-합집합 검정(IUT)의 크기(size)를 제어하는 세 가지 핵심 정리(8.3.21, 8.3.23, 8.3.24)를 완전한 증명과 직관으로 설명한다. UIT의 보수적 검정력 손실, IUT의 보수성, 정확한 크기 조건까지 체계적으로 다룬다.

Statistics
저자

Kwangmin Kim

공개

2026년 04월 09일

1 개요

158번 포스트에서 UIT와 IUT의 구성 원리를 배웠다. 이 포스트에서는 구성된 검정의 크기(size)를 어떻게 제어하는가를 다룬다.

UIT와 IUT의 크기를 직접 계산하기 어려운 경우가 많다. 이때 상한(upper bound) 을 이용해 보수적으로 level \(\alpha\) 를 보장하는 것이 현실적 접근이다. Casella & Berger (2002, Ch.8) §8.3.3의 세 정리가 이 문제를 해결한다.

정리 대상 결론
Theorem 8.3.21 UIT (LRT 기반) 크기 \(\leq\) 전체 LRT 크기
Theorem 8.3.23 IUT (임의 기반) 크기 \(\leq \sup_\gamma \alpha_\gamma\)
Theorem 8.3.24 IUT 정확한 크기 = \(\alpha\) 의 조건

2 왜 크기 제어가 어려운가

2.1 UIT의 어려움

UIT 기각 영역: \(R_{\text{UIT}} = \bigcup_{\gamma \in \Gamma} R_\gamma\)

\[P_\theta(X \in R_{\text{UIT}}) = P_\theta\left(\bigcup_\gamma \{X \in R_\gamma\}\right)\]

합집합의 확률을 정확히 계산하려면 각 \(R_\gamma\) 간의 상호 의존성(joint distribution)을 알아야 한다. \(\Gamma\) 가 무한 집합이면 계산이 불가능에 가깝다.

2.2 IUT의 어려움

IUT 기각 영역: \(R_{\text{IUT}} = \bigcap_{\gamma \in \Gamma} R_\gamma\)

\[P_\theta(X \in R_{\text{IUT}}) = P_\theta\left(\bigcap_\gamma \{X \in R_\gamma\}\right)\]

교집합의 확률도 각 \(R_\gamma\) 의 결합분포를 알아야 계산 가능하다. 특히 서로 다른 측정값들(예: 강도와 난연성)이 상관되어 있으면 결합분포를 모델링하기 어렵다.

해결 전략: 정확한 계산 대신 상한(upper bound) 으로 보수적 level 보장.


3 UIT의 크기: Theorem 8.3.21

3.1 설정

\(\Theta_0 = \bigcap_{\gamma \in \Gamma} \Theta_\gamma\) 이고:

  • \(\lambda(\mathbf{x})\): \(H_0: \theta \in \Theta_0\) vs \(H_1: \theta \in \Theta_0^c\) 에 대한 전체 LRT 통계량
  • \(\lambda_\gamma(\mathbf{x})\): \(H_{0\gamma}: \theta \in \Theta_\gamma\) vs \(H_{1\gamma}: \theta \in \Theta_\gamma^c\) 에 대한 하위 LRT 통계량
  • \(T(\mathbf{x}) = \inf_{\gamma \in \Gamma} \lambda_\gamma(\mathbf{x})\): UIT 통계량

UIT 기각 영역: \(\{T(\mathbf{x}) < c\}\) (작은 \(\lambda_\gamma\) 가 있으면 기각)

Theorem 8.3.21 (UIT 크기 상한)
  1. \(T(\mathbf{x}) \geq \lambda(\mathbf{x})\) for every \(\mathbf{x}\)

  2. \(\beta_T(\theta) \leq \beta_\lambda(\theta)\) for every \(\theta \in \Theta\) (UIT 검정력 \(\leq\) LRT 검정력)

  3. LRT가 level \(\alpha\) 이면 UIT도 level \(\alpha\) 이다

3.2 증명: 핵심 부등식 \(T(\mathbf{x}) \geq \lambda(\mathbf{x})\) 의 이유

LRT 통계량의 정의:

\[\lambda(\mathbf{x}) = \frac{\sup_{\theta \in \Theta_0} L(\theta|\mathbf{x})}{\sup_{\theta \in \Theta} L(\theta|\mathbf{x})}, \quad \lambda_\gamma(\mathbf{x}) = \frac{\sup_{\theta \in \Theta_\gamma} L(\theta|\mathbf{x})}{\sup_{\theta \in \Theta} L(\theta|\mathbf{x})}\]

\(\Theta_0 = \bigcap_\gamma \Theta_\gamma \subset \Theta_\gamma\) 이므로:

\[\sup_{\theta \in \Theta_0} L(\theta|\mathbf{x}) \leq \sup_{\theta \in \Theta_\gamma} L(\theta|\mathbf{x}) \quad \forall \gamma\]

따라서 \(\lambda(\mathbf{x}) \leq \lambda_\gamma(\mathbf{x})\) for all \(\gamma\). 이를 모든 \(\gamma\) 에 대해 inf를 취하면:

\[\lambda(\mathbf{x}) \leq \inf_{\gamma} \lambda_\gamma(\mathbf{x}) = T(\mathbf{x})\]

직관: 전체 \(\Theta_0\) 에서 최대화한 우도는 각 하위 집합 \(\Theta_\gamma\) 에서 최대화한 것보다 작다. 집합이 커질수록 최대화가 용이하기 때문이다. 따라서 전체 LRT 통계량이 항상 하위 LRT 통계량보다 작거나 같다.

3.3 증명: (b)와 (c) 도출

(a)에 의해 \(T > \lambda\) 이므로:

\[\{T(\mathbf{x}) < c\} \subset \{\lambda(\mathbf{x}) < c\}\]

UIT 기각 영역이 LRT 기각 영역의 부분집합이다. 따라서:

\[\beta_T(\theta) = P_\theta(T < c) \leq P_\theta(\lambda < c) = \beta_\lambda(\theta)\]

이것이 (b)이다. (b)가 모든 \(\theta\) 에서 성립하므로:

\[\sup_{\theta \in \Theta_0} \beta_T(\theta) \leq \sup_{\theta \in \Theta_0} \beta_\lambda(\theta) \leq \alpha\]

LRT가 level \(\alpha\) 이면 UIT도 level \(\alpha\). 이것이 (c)이다. \(\square\)

3.4 UIT의 검정력 손실 — 직관

UIT의 기각 영역이 LRT보다 작다는 것은 UIT가 더 보수적임을 의미한다.

  • Type I Error: UIT \(\leq\) LRT (좋은 점)
  • 검정력: UIT \(\leq\) LRT (나쁜 점 — 진짜 기각해야 할 때 덜 기각)

비유: 경찰이 용의자를 체포하는 기준을 더 엄격하게 올리면 무고한 사람 체포가 줄지만(Type I Error 감소), 진짜 범인도 더 자주 놓친다(검정력 감소). UIT는 더 많은 증거(하위 검정들의 기각)를 요구하므로 기준이 높다.

3.5 예시: 정규분포 양측 t 검정 (Example 8.3.22)

\(H_0: \mu = \mu_0\) vs \(H_1: \mu \neq \mu_0\) 에서 UIT를 구성하면:

\[H_0: \{\mu \leq \mu_0\} \cap \{\mu \geq \mu_0\}\]

두 단측 LRT의 UIT:

\[\text{기각}: \frac{\bar{X} - \mu_0}{S/\sqrt{n}} \geq t_L \quad \text{또는} \quad \frac{\bar{X} - \mu_0}{S/\sqrt{n}} \leq t_U\]

대칭 설정 \(t_L = -t_U = t_{n-1, \alpha/2}\) 이면:

\[\text{기각}: \left|\frac{\bar{X} - \mu_0}{S/\sqrt{n}}\right| \geq t_{n-1, \alpha/2}\]

이것은 곧 양측 t 검정이며 동시에 전체 LRT이기도 하다. 이 경우 \(T(\mathbf{x}) = \lambda(\mathbf{x})\) 로, 검정력 손실 없이 UIT = LRT가 성립한다.

이처럼 UIT와 LRT가 일치하는 경우에는 UIT가 하위 검정의 세분화된 진단 능력을 제공하면서도 검정력 손실이 없다.


4 IUT의 크기: Theorem 8.3.23

Theorem 8.3.23 (IUT 크기 상한)

각 하위 검정 \(H_{0\gamma}: \theta \in \Theta_\gamma\) 의 기각 영역이 \(R_\gamma\) 이고 크기가 \(\alpha_\gamma\) 이면:

IUT (기각 영역 \(R = \bigcap_\gamma R_\gamma\))는 level \(\alpha = \sup_\gamma \alpha_\gamma\) 검정이다.

4.1 증명

임의의 \(\theta \in \Theta_0 = \bigcup_\gamma \Theta_\gamma\) 에 대해, \(\theta \in \Theta_\gamma\) 인 어떤 \(\gamma\) 가 존재한다:

\[P_\theta(X \in R) = P_\theta\left(X \in \bigcap_\gamma R_\gamma\right) \leq P_\theta(X \in R_\gamma) \leq \alpha_\gamma \leq \alpha\]

\(\theta \in \Theta_0\) 가 임의적이었으므로 \(\sup_{\theta \in \Theta_0} P_\theta(X \in R) \leq \alpha\). \(\square\)

4.2 증명 직관

교집합 기각 영역 \(R = \bigcap_\gamma R_\gamma\) 은 개별 \(R_\gamma\) 보다 작다:

\[R \subset R_\gamma \quad \forall \gamma\]

\(\theta \in \Theta_\gamma\) 이면 \(R_\gamma\) 에서의 Type I Error가 \(\alpha_\gamma\) 이므로, 더 작은 집합 \(R\) 에서의 Type I Error는 \(\leq \alpha_\gamma\) 이다. 모든 하위 검정의 크기가 \(\alpha\) 이면 IUT의 Type I Error는 자동으로 \(\leq \alpha\).

Theorem 8.3.23의 장점: LRT를 알 필요 없이, 각 하위 검정의 크기만 제어하면 된다. Theorem 8.3.21은 하위 검정이 LRT여야 한다는 제약이 있지만, Theorem 8.3.23은 임의의 하위 검정에 적용된다.

4.3 IUT의 보수성 (Conservativeness)

문제: IUT의 실제 크기(sup Type I Error)가 \(\alpha\) 보다 훨씬 작을 수 있다. 즉 IUT가 “지나치게 엄격”해서 진짜 대립을 충분히 잡지 못한다.

직관: 두 조건을 모두 통과해야 하므로, 두 하위 검정의 Type I Error가 독립적이라면 실제 결합 Type I Error는 \(\alpha \times \alpha = \alpha^2\) 수준으로 낮아진다. 이는 지나치게 보수적이다.

예시: \(\alpha = 0.05\) 이고 하위 검정 2개가 독립이면 IUT의 실제 Type I Error \(\approx 0.05^2 = 0.0025\). 명목 수준 0.05에 비해 너무 작다 → 검정력이 낮아짐.


5 IUT의 정확한 크기: Theorem 8.3.24

보수성을 극복하여 IUT의 크기가 정확히 \(\alpha\) 가 되는 충분조건을 제공한다.

Theorem 8.3.24 (IUT 정확한 크기)

\(H_0: \theta \in \bigcup_{j=1}^k \Theta_j\) 에서 각 \(R_j\)\(H_{0j}\) 에 대한 level \(\alpha\) 검정이라 하자.

어떤 \(i \in \{1, \ldots, k\}\) 에 대해 파라미터 수열 \(\{\theta_l\} \subset \Theta_i\) 가 존재하여:

  1. \(\lim_{l \to \infty} P_{\theta_l}(X \in R_i) = \alpha\)

  2. 모든 \(j \neq i\) 에 대해 \(\lim_{l \to \infty} P_{\theta_l}(X \in R_j) = 1\)

이면 IUT의 크기는 정확히 \(\alpha\) 이다.

5.1 증명: Bonferroni 부등식 활용

Theorem 8.3.23에 의해 \(\sup_{\theta \in \Theta_0} P_\theta(X \in R) \leq \alpha\) 가 이미 성립한다. 역방향 부등식을 보인다.

\(\theta_l \in \Theta_i \subset \Theta_0\) 이므로:

\[\sup_{\theta \in \Theta_0} P_\theta(X \in R) \geq \lim_{l \to \infty} P_{\theta_l}(X \in R) = \lim_{l \to \infty} P_{\theta_l}\left(X \in \bigcap_{j=1}^k R_j\right)\]

Bonferroni 부등식 적용 (\(P(A \cap B) \geq P(A) + P(B) - 1\)의 일반화):

\[P\left(X \in \bigcap_{j=1}^k R_j\right) \geq \sum_{j=1}^k P(X \in R_j) - (k-1)\]

\(l \to \infty\) 극한에서 조건 (i)과 (ii)를 사용:

\[\lim_{l \to \infty} P_{\theta_l}\left(X \in \bigcap_{j=1}^k R_j\right) \geq \underbrace{\alpha}_{j=i} + \underbrace{(k-1) \cdot 1}_{j \neq i} - (k-1) = \alpha\]

따라서 \(\sup_{\theta \in \Theta_0} P_\theta(X \in R) \geq \alpha\). Theorem 8.3.23의 \(\leq \alpha\) 와 결합하면 크기 \(= \alpha\). \(\square\)

5.2 조건의 직관적 해석

  • 조건 (i): \(\Theta_i\) 의 어떤 경계점에서 \(R_i\) 의 Type I Error가 정확히 \(\alpha\) 에 수렴한다 → \(i\) 번째 검정이 “병목(bottleneck)”이 된다
  • 조건 (ii): 나머지 하위 검정들은 그 경계점에서 검정력 1에 수렴한다 → 병목이 아닌 나머지 검정들은 실질적 제약을 가하지 않는다

비유: 제조 품질 검사에서 강도 검사(검정 1)와 외관 검사(검정 2) 두 가지를 통과해야 한다. 만약 특정 조건 하에서 외관은 거의 항상 통과하지만 강도만 간신히 통과한다면, 전체 합격 기준은 강도 검사 혼자 결정한다. 이 경우 IUT의 크기 = 강도 검사의 크기.


6 예시: 품질 검수 IUT (Example 8.3.25)

천 소재 합격 판정: \(\theta_1 > 50\) (인장 강도) AND \(\theta_2 > 0.95\) (난연성 통과 확률)

\(n = m = 58\), 각 검정 크기 \(\approx 0.05\):

  • \(R_1\): 인장 강도 검정 (\((\bar{X} - 50)/(S/\sqrt{n}) > 1.672\) 이면 기각)
  • \(R_2\): 난연성 검정 (\(\sum Y_i > 57\) 이면 기각)

Theorem 8.3.23 적용: 각 \(\alpha_j = 0.05\) 이므로 IUT는 level 0.05 검정.

Theorem 8.3.24 적용 (정확한 크기 확인):

파라미터 수열: \(\theta_l = (\theta_{1l}, 0.95)\), \(\theta_{1l} \to \infty\)

  • \(\theta_{1l} \to \infty\) 이면 \(P_{\theta_l}(X \in R_1) \to 1\) (인장 강도가 충분히 크면 항상 통과)
  • \(\theta_2 = 0.95\) 이면 \(P_{\theta_l}(X \in R_2) = 0.05\) (경계에서 크기 정확히 \(\alpha\))

조건 (i): \(\lim P_{\theta_l}(X \in R_2) = 0.05 = \alpha\) ✓ 조건 (ii): \(\lim P_{\theta_l}(X \in R_1) = 1\)

따라서 IUT의 크기 = 0.05 정확히. 병목은 난연성 검정이다.

중요한 관찰: 크기 계산에 \((\theta_1, \theta_2)\) 의 결합분포가 필요 없다. 인장 강도와 난연성이 측정상 상관되어 있더라도, 주변 분포(marginal distribution) 만으로 크기를 구한다. 이것이 IUT의 실용적 강점이다.


7 UIT vs IUT 크기 제어 비교

항목 UIT (Thm 8.3.21) IUT (Thm 8.3.23) IUT 정확 크기 (Thm 8.3.24)
하위 검정 조건 LRT여야 함 임의 검정 가능 임의 검정 가능
크기 상한 전체 LRT 크기 \(\sup_\gamma \alpha_\gamma\) 정확히 \(\alpha\)
결합분포 필요 불필요 불필요 불필요
보수성 중간 강할 수 있음 없음
실용성 UIT = LRT이면 최적 다변수 검정에 유용 병목 조건 확인 시

7.1 언제 어떤 정리를 쓰는가

Theorem 8.3.21: UIT가 LRT 기반으로 구성될 때 크기를 빠르게 상한으로 보장.

Theorem 8.3.23: 하위 검정이 임의의 방법으로 구성되어 있고 각 크기를 알 때 IUT를 level \(\alpha\) 로 보장. 임상시험의 다중 엔드포인트 검정에 주로 사용.

Theorem 8.3.24: IUT가 지나치게 보수적이지 않음을 검증할 때 사용. 병목 검정을 찾아 크기가 정확히 \(\alpha\) 임을 확인.


8 실무 응용: 생물 동등성 검정 (Bioequivalence)

IUT의 가장 유명한 실무 적용 사례다.

목표: 제네릭 약이 오리지널 약과 생물학적으로 동등함을 입증하려 한다.

\[H_0: \mu_T - \mu_R < \delta_L \text{ or } \mu_T - \mu_R > \delta_U \quad \text{(동등하지 않음)}\] \[H_1: \delta_L \leq \mu_T - \mu_R \leq \delta_U \quad \text{(동등함)}\]

통상 \(\delta_L = \log(0.80)\), \(\delta_U = \log(1.25)\) (±20% 기준).

이를 두 단측 검정으로 분해 (TOST: Two One-Sided Tests):

\[H_{01}: \mu_T - \mu_R \leq \delta_L \quad \text{vs} \quad H_{11}: \mu_T - \mu_R > \delta_L\] \[H_{02}: \mu_T - \mu_R \geq \delta_U \quad \text{vs} \quad H_{12}: \mu_T - \mu_R < \delta_U\]

IUT 적용: 두 검정을 모두 기각할 때만 동등성 선언.

\[R = R_1 \cap R_2 = \left\{T_1 > t_{\alpha, n-1}\right\} \cap \left\{T_2 < -t_{\alpha, n-1}\right\}\]

Theorem 8.3.23에 의해 각 검정이 size \(\alpha\) 이면 IUT는 level \(\alpha\) 검정이다.

Theorem 8.3.24의 조건도 충족: \(\delta_L\) 경계에서 \(R_1\) 의 Type I Error \(= \alpha\), \(R_2\) 의 검정력 \(\to 1\) (또는 반대).


9 코드 구현

9.1 Python: UIT vs LRT 크기 비교

import numpy as np
from scipy import stats


def simulate_uit_vs_lrt(
    n_sim: int = 20000,
    n: int = 20,
    mu0: float = 0.0,
    sigma: float = 1.0,
    alpha: float = 0.05,
    seed: int = 42,
) -> dict:
    """
    H0: mu = mu0 에서 두 단측 t 검정의 UIT와 전체 LRT(양측 t 검정)의
    Type I Error 시뮬레이션으로 비교
    theta0에서의 Type I Error가 alpha 인지 확인
    """
    rng = np.random.default_rng(seed)
    t_crit = stats.t.ppf(1 - alpha / 2, df=n - 1)  # 양측 임계값

    reject_lrt = 0   # 양측 t 검정 (LRT)
    reject_uit = 0   # 두 단측의 UIT (= 양측 t 검정 — 이 경우 동일)

    for _ in range(n_sim):
        data = rng.normal(mu0, sigma, n)
        t_stat = (np.mean(data) - mu0) / (np.std(data, ddof=1) / np.sqrt(n))

        # LRT = 양측 t 검정
        if abs(t_stat) > t_crit:
            reject_lrt += 1

        # UIT: 좌측 또는 우측 단측 기각
        t_crit_one = stats.t.ppf(1 - alpha, df=n - 1)
        if t_stat > t_crit_one or t_stat < -t_crit_one:
            reject_uit += 1

    return {
        "LRT Type I Error": reject_lrt / n_sim,
        "UIT Type I Error": reject_uit / n_sim,
        "명목 alpha": alpha,
        "참고: 이 경우 UIT = LRT (Thm 8.3.22)": True,
    }


def simulate_iut_size(
    n_sim: int = 20000,
    n: int = 30,
    m: int = 30,
    alpha: float = 0.05,
    theta1_null: float = 50.0,
    theta2_null: float = 0.95,
    sigma: float = 5.0,
    seed: int = 42,
) -> dict:
    """
    IUT 크기 시뮬레이션: 품질 검수 예제
    H0: {theta1 <= 50 or theta2 <= 0.95}
    경계점 (50, 0.95) 에서 Type I Error 측정
    """
    rng = np.random.default_rng(seed)
    t_crit = stats.t.ppf(1 - alpha, df=n - 1)

    # 경계점에서의 Type I Error
    reject_iut = 0
    reject_s_alone = 0
    reject_f_alone = 0

    for _ in range(n_sim):
        # 인장 강도: theta1 = 50 (경계)
        strength = rng.normal(theta1_null, sigma, n)
        t_stat = (np.mean(strength) - theta1_null) / (np.std(strength, ddof=1) / np.sqrt(n))
        reject_s = t_stat > t_crit

        # 난연성: theta2 = 0.95 (경계)
        flame = rng.binomial(1, theta2_null, m)
        p_val_f = stats.binom_test(int(np.sum(flame)), m, theta2_null, alternative="greater")
        reject_f = p_val_f < alpha

        if reject_s:
            reject_s_alone += 1
        if reject_f:
            reject_f_alone += 1
        if reject_s and reject_f:
            reject_iut += 1

    return {
        "인장 강도 단독 Type I Error": reject_s_alone / n_sim,
        "난연성 단독 Type I Error": reject_f_alone / n_sim,
        "IUT Type I Error": reject_iut / n_sim,
        "명목 alpha": alpha,
        "IUT 보수성 비율": (reject_iut / n_sim) / alpha,
    }


print("=== UIT vs LRT 비교 (정규 양측) ===")
result_uit = simulate_uit_vs_lrt()
for k, v in result_uit.items():
    if isinstance(v, float):
        print(f"  {k}: {v:.4f}")
    else:
        print(f"  {k}: {v}")

print()
print("=== IUT 크기 시뮬레이션 (품질 검수, 경계점) ===")
result_iut = simulate_iut_size()
for k, v in result_iut.items():
    print(f"  {k}: {v:.4f}" if isinstance(v, float) else f"  {k}: {v}")

9.2 Python: 생물 동등성 TOST (IUT 응용)

import numpy as np
from scipy import stats


def tost_bioequivalence(
    data_T: np.ndarray,
    data_R: np.ndarray,
    delta_L: float = np.log(0.80),
    delta_U: float = np.log(1.25),
    alpha: float = 0.05,
) -> dict:
    """
    생물 동등성 TOST: 두 단측 t 검정의 IUT
    H0: mu_T - mu_R < delta_L OR mu_T - mu_R > delta_U
    H1: delta_L <= mu_T - mu_R <= delta_U
    """
    # 로그 변환 (AUC, Cmax 등 로그 정규 가정)
    log_T = np.log(data_T)
    log_R = np.log(data_R)

    # 짝비교 또는 독립 검정 (여기서는 독립 가정)
    diff = np.mean(log_T) - np.mean(log_R)
    n_T, n_R = len(data_T), len(data_R)
    se_diff = np.sqrt(np.var(log_T, ddof=1) / n_T + np.var(log_R, ddof=1) / n_R)
    df = n_T + n_R - 2
    t_crit = stats.t.ppf(1 - alpha, df=df)

    # 단측 검정 1: H01: diff <= delta_L vs H11: diff > delta_L
    t1 = (diff - delta_L) / se_diff
    reject_H01 = t1 > t_crit

    # 단측 검정 2: H02: diff >= delta_U vs H12: diff < delta_U
    t2 = (diff - delta_U) / se_diff
    reject_H02 = t2 < -t_crit

    # IUT: 두 검정 모두 기각해야 동등성 선언
    bioequivalent = reject_H01 and reject_H02

    # 90% 신뢰구간 (동등성 판단과 동치)
    ci_lower = diff - t_crit * se_diff
    ci_upper = diff + t_crit * se_diff

    return {
        "평균 로그 차이 (T-R)": diff,
        "90% 신뢰구간": (round(ci_lower, 4), round(ci_upper, 4)),
        "허용 범위 [delta_L, delta_U]": (round(delta_L, 4), round(delta_U, 4)),
        "t1 (하한 검정)": t1,
        "t2 (상한 검정)": t2,
        "H01 기각": reject_H01,
        "H02 기각": reject_H02,
        "동등성 선언 (IUT 기각)": bioequivalent,
        "해석": "신뢰구간이 허용 범위 내에 완전히 포함됨" if bioequivalent else "동등성 미입증",
    }


# 예시 데이터
np.random.seed(42)
# 제네릭 약 AUC: 오리지널 대비 약 5% 차이
auc_T = np.random.lognormal(mean=5.0, sigma=0.3, size=24)  # 제네릭
auc_R = np.random.lognormal(mean=5.05, sigma=0.3, size=24) # 오리지널

result_tost = tost_bioequivalence(auc_T, auc_R)
for k, v in result_tost.items():
    if isinstance(v, float):
        print(f"  {k}: {v:.4f}")
    else:
        print(f"  {k}: {v}")

9.3 R

library(stats)

# IUT 크기 시뮬레이션 (품질 검수)
simulate_iut <- function(n_sim = 10000, n = 30, m = 30, alpha = 0.05,
                          theta1_null = 50, theta2_null = 0.95, sigma = 5) {
  set.seed(42)
  reject_s <- 0; reject_f <- 0; reject_iut <- 0
  t_crit <- qt(1 - alpha, df = n - 1)

  for (i in seq_len(n_sim)) {
    strength <- rnorm(n, theta1_null, sigma)
    t_stat <- (mean(strength) - theta1_null) / (sd(strength) / sqrt(n))
    rs <- t_stat > t_crit

    flame <- rbinom(m, 1, theta2_null)
    pf <- binom.test(sum(flame), m, theta2_null, alternative = "greater")$p.value
    rf <- pf < alpha

    if (rs) reject_s <- reject_s + 1
    if (rf) reject_f <- reject_f + 1
    if (rs & rf) reject_iut <- reject_iut + 1
  }

  cat(sprintf("인장 강도 단독 Type I Error: %.4f\n", reject_s / n_sim))
  cat(sprintf("난연성 단독 Type I Error: %.4f\n", reject_f / n_sim))
  cat(sprintf("IUT Type I Error: %.4f\n", reject_iut / n_sim))
  cat(sprintf("보수성 비율: %.4f\n", (reject_iut / n_sim) / alpha))
}

# TOST 생물 동등성
tost <- function(y_T, y_R, delta_L = log(0.80), delta_U = log(1.25), alpha = 0.05) {
  log_T <- log(y_T); log_R <- log(y_R)
  diff <- mean(log_T) - mean(log_R)
  se <- sqrt(var(log_T) / length(y_T) + var(log_R) / length(y_R))
  df <- length(y_T) + length(y_R) - 2
  t_crit <- qt(1 - alpha, df)

  t1 <- (diff - delta_L) / se
  t2 <- (diff - delta_U) / se

  cat(sprintf("평균 로그 차이: %.4f\n", diff))
  cat(sprintf("90%% CI: (%.4f, %.4f)\n", diff - t_crit * se, diff + t_crit * se))
  cat(sprintf("허용 범위: (%.4f, %.4f)\n", delta_L, delta_U))
  cat(sprintf("H01 기각: %s, H02 기각: %s\n", t1 > t_crit, t2 < -t_crit))
  cat(sprintf("동등성 선언: %s\n", t1 > t_crit & t2 < -t_crit))
}

cat("=== IUT 크기 시뮬레이션 ===\n")
simulate_iut()

cat("\n=== TOST 생물 동등성 ===\n")
set.seed(42)
auc_T <- rlnorm(24, meanlog = 5.0, sdlog = 0.3)
auc_R <- rlnorm(24, meanlog = 5.05, sdlog = 0.3)
tost(auc_T, auc_R)

10 핵심 요약

UIT와 IUT의 크기 제어를 위한 세 정리의 논리 구조:

\[\underbrace{\text{Thm 8.3.21}}_{\text{UIT}: \beta_T \leq \beta_\lambda} \implies \text{UIT가 level } \alpha\]

\[\underbrace{\text{Thm 8.3.23}}_{\text{IUT}: P(R) \leq \alpha_\gamma} \implies \text{IUT가 level } \alpha\]

\[\underbrace{\text{Thm 8.3.24}}_{\text{병목 조건}} \implies \text{IUT의 크기} = \alpha \text{ (정확)}\]

실무적으로:

  • UIT와 LRT가 일치하면(Example 8.3.22) 검정력 손실 없이 하위 검정 진단 능력 확보
  • IUT는 결합분포 없이 주변 크기만으로 level \(\alpha\) 보장 → 다변수·다중 엔드포인트 검정에 강력
  • 병목 검정을 파악하면 IUT가 지나치게 보수적이지 않음을 확인 가능

11 관련 주제

(Casella & Berger, 2002, Ch.8 §8.3.3)

Subscribe

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