使用 rstanarm 进行贝叶斯回归建模
Jake Thompson
Psychometrician, ATLAS, University of Kansas
library(rstanarm)stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq)
正在为模型 'continuous' 采样(链 1)。
梯度评估耗时 0.000408 秒
1000 次跃蛙步进转移预计耗时
4.08 秒。
请相应调整预期!
迭代: 1 / 2000 [ 0%] (预热)
迭代: 200 / 2000 [ 10%] (预热)
迭代: 400 / 2000 [ 20%] (预热)
迭代: 600 / 2000 [ 30%] (预热)
迭代: 800 / 2000 [ 40%] (预热)
迭代: 1000 / 2000 [ 50%] (预热)
迭代: 1001 / 2000 [ 50%] (采样)
迭代: 1200 / 2000 [ 60%] (采样)
迭代: 1400 / 2000 [ 70%] (采样)
迭代: 1600 / 2000 [ 80%] (采样)
迭代: 1800 / 2000 [ 90%] (采样)
迭代: 2000 / 2000 [100%] (采样)
用时:0.37735 秒(预热)
0.252244 秒(采样)
0.629594 秒(总计)
summary(stan_model)
模型信息:
function: stan_glm
family: gaussian [identity]
formula: kid_score ~ mom_iq
algorithm: sampling
priors: see help('prior_summary')
sample: 4000 (posterior sample size)
observations: 434
predictors: 2
估计:
mean sd 2.5% 25% 50% 75% 97.5%
(Intercept) 25.7 6.0 13.8 21.6 25.7 30.0 37.0
mom_iq 0.6 0.1 0.5 0.6 0.6 0.7 0.7
sigma 18.3 0.6 17.1 17.9 18.3 18.7 19.5
mean_PPD 86.8 1.2 84.3 85.9 86.8 87.6 89.2
log-posterior -1885.4 1.2 -1888.5 -1886.0 -1885.1 -1884.5 -1884.0
诊断:
mcse Rhat n_eff
(Intercept) 0.1 1.0 4000
mom_iq 0.0 1.0 4000
sigma 0.0 1.0 3827
mean_PPD 0.0 1.0 4000
log-posterior 0.0 1.0 1896
对每个参数,mcse 为蒙特卡洛标准误,n_eff 为有效样本量的粗略度量,Rhat 为分链的潜在尺度缩减因子
(收敛时 Rhat=1)。
估计:
mean sd 2.5% 25% 50% 75% 97.5%
(Intercept) 25.7 6.0 13.8 21.6 25.7 30.0 37.0
mom_iq 0.6 0.1 0.5 0.6 0.6 0.7 0.7
sigma 18.3 0.6 17.1 17.9 18.3 18.7 19.5
mean_PPD 86.8 1.2 84.3 85.9 86.8 87.6 89.2
log-posterior -1885.4 1.2 -1888.5 -1886.0 -1885.1 -1884.5 -1884.0
诊断:
mcse Rhat n_eff
(Intercept) 0.1 1.0 4000
mom_iq 0.0 1.0 4000
sigma 0.0 1.0 3827
mean_PPD 0.0 1.0 4000
log-posterior 0.0 1.0 1896
对每个参数,mcse 为蒙特卡洛标准误,
n_eff 为有效样本量的粗略度量,
Rhat 为分链尺度缩减因子
(收敛时 Rhat=1)。
使用 rstanarm 进行贝叶斯回归建模