마르코프 체인 진단 및 재현성

RJAGS로 배우는 Bayesian 모델링

Alicia Johnson

Associate Professor, Macalester College

마르코프 체인 출력

RJAGS로 배우는 Bayesian 모델링

고려할 질문

  • "좋은" 마르코프 체인이란 무엇인가?

  • 마르코프 체인의 사후 분포 근사는 얼마나 정확한가?

  • 마르코프 체인을 몇 번 반복해야 하는가?

RJAGS로 배우는 Bayesian 모델링

진단: 추적 플롯

RJAGS로 배우는 Bayesian 모델링

진단: 추적 플롯

좋음: 안정성!

나쁨: 불안정성

RJAGS로 배우는 Bayesian 모델링

진단: 다중 체인

# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 1)

RJAGS로 배우는 Bayesian 모델링

진단: 다중 체인

# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 2)

RJAGS로 배우는 Bayesian 모델링

진단: 다중 체인

# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 4)

RJAGS로 배우는 Bayesian 모델링

진단: 다중 체인

# COMPILE the model
sleep_jags <- jags.model(..., n.chains = 4)

RJAGS로 배우는 Bayesian 모델링
summary(sleep_sim)
1. Empirical mean and standard deviation for each variable,
   plus standard error of the mean:

   Mean    SD Naive SE Time-series SE
m 29.10 8.968   0.2836         0.2820
s 40.07 7.887   0.2494         0.4227

2. Quantiles for each variable:

   2.5%   25%   50%   75% 97.5%
m 11.42 23.27 28.85 34.76 46.76
s 28.31 34.65 38.93 43.91 57.56
  • $m$의 사후 평균 추정값 = 29.10 ms

  • 이 추정값의 (단순) 표준 오차 = 0.2836 ms
    SD / $\sqrt{\text{number of iterations}}$

RJAGS로 배우는 Bayesian 모델링

진단: 표준 오차

  • 추정 평균 = 29.10 ms

  • (단순) 표준 오차 = 0.2836 ms

  • $29.10 \pm 2*0.2836$
RJAGS로 배우는 Bayesian 모델링

마르코프 체인 작업 흐름

  • 모델 정의, 컴파일, 시뮬레이션

  • 다음 진단 항목 검토:

    • 추적 플롯
    • 다중 체인 출력
    • 표준 오차
  • 시뮬레이션 완료

RJAGS로 배우는 Bayesian 모델링

마르코프 체인 완료: 재현성

sleep_jags <- jags.model(textConnection(sleep_model), 
    data = list(Y = sleep_study$diff_3),
    inits = list(.RNG.name = "base::Wichmann-Hill",
                 .RNG.seed = 1989))
RJAGS로 배우는 Bayesian 모델링

연습해 봅시다!

RJAGS로 배우는 Bayesian 모델링

Preparing Video For Download...