比较贝叶斯与频率学派方法

使用 rstanarm 进行贝叶斯回归建模

Jake Thompson

Psychometrician, ATLAS, University of Kansas

相同的参数!

tidy(lm_model)
         term   estimate  std.error statistic      p.value
1 (Intercept) 25.7997778 5.91741208  4.359977 1.627847e-05
2      mom_iq  0.6099746 0.05852092 10.423188 7.661950e-23
tidy(stan_model)
        term   estimate  std.error
1 (Intercept) 25.7257965 6.01262625
2      mom_iq  0.6110254 0.05917996
使用 rstanarm 进行贝叶斯回归建模

频率学派 vs. 贝叶斯

  • 频率学派:参数固定,数据随机
  • 贝叶斯:参数随机,数据固定
  • 什么是 p 值?
    • 在原假设成立下,观测到该检验统计量的概率
  • 那么贝叶斯关注什么?
    • 在已观测数据下,参数取各值的概率
使用 rstanarm 进行贝叶斯回归建模

评估贝叶斯参数

  • 置信区间:某区间包含真值的概率
    • 有 90% 的概率该区间包含真值
  • 可信区间:真值落在某区间内的概率
    • 有 90% 的概率真值落在此区间
  • 参数值的概率 vs. 区间边界的概率
使用 rstanarm 进行贝叶斯回归建模

构建可信区间

posterior_interval(stan_model)
                    5%        95%
(Intercept) 16.1396617 35.6015948
mom_iq       0.5131289  0.7042666
sigma       17.2868651 19.3411104
posterior_interval(stan_model, prob = 0.95)
                  2.5%      97.5%
(Intercept) 14.5472824 37.2505664
mom_iq       0.4963677  0.7215823
sigma       17.1197930 19.5359616
posterior_interval(stan_model, prob = 0.5)
                   25%        75%
(Intercept) 21.7634032 29.6542886
mom_iq       0.5714405  0.6496865
sigma       17.8776965 18.7218373
使用 rstanarm 进行贝叶斯回归建模

置信区间 vs. 可信区间

confint(lm_model, parm = "mom_iq", level = 0.95)
           2.5 %    97.5 %
mom_iq 0.4949534 0.7249957
stan_model <- stan_glm(kid_score ~ mom_iq, 
                       data = kidiq)
posterior_interval(stan_model, 
                   pars = "mom_iq", 
                   prob = 0.95)
             2.5%     97.5%
mom_iq 0.4963677  0.7215823
posterior <- spread_draws(stan_model, mom_iq) 
mean(between(posterior_mom_iq, 0.60, 0.65))
0.31475
使用 rstanarm 进行贝叶斯回归建模

Passons à la pratique !

使用 rstanarm 进行贝叶斯回归建模

Preparing Video For Download...