사후 추정 및 추론

RJAGS로 배우는 Bayesian 모델링

Alicia Johnson

Associate Professor, Macalester College

베이지안 회귀 모델

$Y_i$ = 성인 $i$의 체중 (kg)
$X_i$ = 성인 $i$의 신장 (cm)

$\;$

모델

$Y_i \sim N(m_i, s^2)$
$m_i = a + b X_i$

$a \sim N(0, 200^2)$
$b \sim N(1, 0.5^2)$
$s \sim \text{Unif}(0, 20)$

RJAGS로 배우는 Bayesian 모델링

사후 점 추정

RJAGS로 배우는 Bayesian 모델링

사후 점 추정

RJAGS로 배우는 Bayesian 모델링
summary(weight_sim_big)
1. Empirical mean and standard deviation for each variable,
   plus standard error of the mean:
      Mean      SD  Naive SE Time-series SE
a -104.038 7.85296 0.0248332       0.661515
b    1.012 0.04581 0.0001449       0.003849
s    9.331 0.29495 0.0009327       0.001216

2. Quantiles for each variable:
       2.5%       25%      50%     75%   97.5%
a -118.6843 -109.5171 -104.365 -99.036 -87.470
b    0.9152    0.9828    1.014   1.044   1.098
s    8.7764    9.1284    9.322   9.524   9.933

$a$의 사후 평균 $\approx$ -104.038

$b$의 사후 평균 $\approx$ 1.012

RJAGS로 배우는 Bayesian 모델링

사후 점 추정

사후 평균 추세:

$m_i = -104.038 + 1.012 X_i$

마르코프 체인 출력:

head(weight_chains)
             a        b        s
[1,] -113.9029 1.072505 8.772007
[2,] -115.0644 1.077914 8.986393
[3,] -114.6958 1.077130 9.679812
[4,] -115.0568 1.072668 8.814403
[5,] -114.0782 1.071775 8.895299
[6,] -114.3271 1.069477 9.016185
RJAGS로 배우는 Bayesian 모델링

사후 불확실성

사후 평균 추세:

$m_i = -104.038 + 1.012 X_i$

마르코프 체인 출력:

head(weight_chains)
             a        b        s
[1,] -113.9029 1.072505 8.772007
[2,] -115.0644 1.077914 8.986393
[3,] -114.6958 1.077130 9.679812
[4,] -115.0568 1.072668 8.814403
[5,] -114.0782 1.071775 8.895299
[6,] -114.3271 1.069477 9.016185
RJAGS로 배우는 Bayesian 모델링

사후 신용 구간

RJAGS로 배우는 Bayesian 모델링
summary(weight_sim_big)
1. Empirical mean and standard deviation for each variable,
   plus standard error of the mean:
      Mean      SD  Naive SE Time-series SE
a -104.038 7.85296 0.0248332       0.661515
b    1.012 0.04581 0.0001449       0.003849
s    9.331 0.29495 0.0009327       0.001216

2. Quantiles for each variable:
       2.5%       25%      50%     75%   97.5%
a -118.6843 -109.5171 -104.365 -99.036 -87.470
b    0.9152    0.9828    1.014   1.044   1.098
s    8.7764    9.1284    9.322   9.524   9.933

$a$의 95% 사후 신용 구간: (-118.6843, -87.470)

$b$의 95% 사후 신용 구간: (0.9152, 1.098)

RJAGS로 배우는 Bayesian 모델링

사후 신용 구간

해석

사전 분포와 관측 데이터를 고려할 때, $b$가 0.9152~1.098 kg/cm 사이에 있을 사후 확률은 95%입니다.

RJAGS로 배우는 Bayesian 모델링

사후 확률

table(weight_chains$b > 1.1)
FALSE  TRUE 
97835  2165
mean(weight_chains$b > 1.1)
0.02165

해석:
$b$가 1.1 kg/cm을 초과할 사후 확률은 2.165%입니다.

RJAGS로 배우는 Bayesian 모델링

연습해 봅시다!

RJAGS로 배우는 Bayesian 모델링

Preparing Video For Download...