用户自定义先验

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

Jake Thompson

Psychometrician, ATLAS, University of Kansas

为何修改默认先验?

  • 有充分理由认为参数取某值
  • 参数有约束
使用 rstanarm 进行贝叶斯回归建模

指定先验

stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq,
  prior_intercept = normal(location = 0, scale = 10),
  prior = normal(location = 0, scale = 2.5),
  prior_aux = exponential(rate = 1)
)
使用 rstanarm 进行贝叶斯回归建模

指定先验

stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq,
  prior_intercept = normal(location = 0, scale = 10, autoscale = FALSE),
  prior = normal(location = 0, scale = 2.5, autoscale = FALSE),
  prior_aux = exponential(rate = 1, autoscale = FALSE)
)
使用 rstanarm 进行贝叶斯回归建模

指定先验

stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq,
  prior_intercept = normal(location = 3, scale = 2),
  prior = cauchy(location = 0, scale = 1))
  • 多种先验
    • normal()
    • exponential()
    • student_t()
    • cauchy()
  • ?priors
使用 rstanarm 进行贝叶斯回归建模

平坦先验

stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq,
  prior_intercept = NULL,
  prior = NULL,
  prior_aux = NULL)
prior_summary(stan_model)
Priors for model 'stan_model' 
 ------
Intercept (after predictors centered)
 ~ flat

Coefficients
 ~ flat

Auxiliary (sigma)
 ~ flat
 ------
See help('prior_summary.stanreg') for more details
使用 rstanarm 进行贝叶斯回归建模

开始练习!

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

Preparing Video For Download...