Prior ที่กำหนดเอง

การสร้างโมเดลการถดถอยแบบ Bayesian ด้วย rstanarm

Jake Thompson

Psychometrician, ATLAS, University of Kansas

ทำไมต้องเปลี่ยน prior ค่าเริ่มต้น?

  • มีเหตุผลที่ดีว่าพารามิเตอร์จะมีค่าหนึ่งๆ
  • ข้อจำกัดของพารามิเตอร์
การสร้างโมเดลการถดถอยแบบ Bayesian ด้วย rstanarm

การระบุ prior

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)
)
การสร้างโมเดลการถดถอยแบบ Bayesian ด้วย rstanarm

การระบุ prior

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)
)
การสร้างโมเดลการถดถอยแบบ Bayesian ด้วย rstanarm

การระบุ prior

stan_model <- stan_glm(kid_score ~ mom_iq, data = kidiq,
  prior_intercept = normal(location = 3, scale = 2),
  prior = cauchy(location = 0, scale = 1))
  • prior มีหลายรูปแบบ
    • normal()
    • exponential()
    • student_t()
    • cauchy()
  • ?priors
การสร้างโมเดลการถดถอยแบบ Bayesian ด้วย rstanarm

Flat priors

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
การสร้างโมเดลการถดถอยแบบ Bayesian ด้วย rstanarm

มาฝึกกันเถอะ!

การสร้างโมเดลการถดถอยแบบ Bayesian ด้วย rstanarm

Preparing Video For Download...