贝叶斯可信区间的覆盖概率估计(正态分布)

时间:2018-09-26 00:57:23

标签: r bayesian normal-distribution credible-interval

正态分布的贝叶斯推断,我使用下面的r代码获取后验分布。

install.packages(c("mvtnorm","loo","coda"), repos="https://cloud.r-project.org/",dependencies=TRUE)
options(repos=c(getOption('repos'), rethinking='http://xcelab.net/R'))
install.packages('rethinking',type='source')
library(rethinking)

set.seed(650)
x <- data.frame(x = rt(100,3))

fit <- rethinking::map(
  alist(
    x ~ dnorm(mu, sigma),
    mu ~ dnorm(1, 10),
    sigma ~ dunif(0, 50)
  ),
  data=x)

precis(fit, corr=TRUE)

sim_post <- extract.samples(fit)
dim(sim_post)
post_mean <- apply(sim_post, 2, mean)
post_mean

quantile(sim_post$mu ,  c(.05, .95))
quantile(sim_post$sigma, c(0.05, 0.95))

我使用后验分布模拟了10000个样本。如何获得亩的覆盖率?

0 个答案:

没有答案