- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当从 stan
启动标准示例时 webpage像下面这样:
schools_code <- '
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
}
parameters {
real theta[J];
real mu;
real<lower=0> tau;
}
model {
theta ~ normal(mu, tau);
y ~ normal(theta, sigma);
}
'
schools_dat <- list(J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
fit <- stan(model_code = schools_code, data = schools_dat,
iter = 1000, n_chains = 4)
(这是从 here 获得的)
然而,这只为我提供了参数后验的分位数。所以我的问题是:如何获得其他百分位数?我猜它应该类似于 bugs(?)
评论:我试图引入标签stan
,但是,我的声誉太低;)对此感到抱歉
最佳答案
从 rstan v1.0.3
(尚未发布)开始,您将能够直接在 stanfit 对象上使用主力
。如果fit是从apply()
函数由 stan() 函数
生成的类stan()
获得的对象,那么例如,
apply(fit, MARGIN = "parameters", FUN = quantile, probs = (1:100) / 100)
或
apply(as.matrix(fit), MARGIN = 2, FUN = quantile, probs = (1:100) / 100)
前者将 FUN 应用于每个链中的每个参数,而后者在将 FUN 应用于每个参数之前组合链。如果您只对一个参数感兴趣,那么类似
beta <- extract(fit, pars = "beta", inc_warmup = FALSE, permuted = TRUE)[[1]]
quantile(beta, probs = (1:100) / 100)
是一个选项。
关于r - 如何获得 stan 中参数的完整边际分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12268220/
我看到一些示例中使用了 //,但是否还有其他允许的注释字符。 Stan 中的注释字符是什么?什么是完整的评论规则? 最佳答案 来自Stan reference manual : 23.1. Comme
我需要将数据作为具有不同长度的向量列表和具有相同行数但具有不同列数的矩阵列表传递。有没有办法在Rstan中传递数据? 最佳答案 答案本质上是否定的,Stan语言不允许不规则的数据结构,例如不同长度的向
我需要将数据作为具有不同长度的向量列表和具有相同行数但具有不同列数的矩阵列表传递。有没有办法在Rstan中传递数据? 最佳答案 答案本质上是否定的,Stan语言不允许不规则的数据结构,例如不同长度的向
我刚开始学习 stan,有几个问题。我正在尝试在 stan 中做一个有序的 probit 模型。我有一些问题。首先,下面的模型抛出一条错误消息 Stan model does not contain
我现在在 Stan 中学习建模的绳索很有趣。现在我正在努力研究我的受试者间和受试者内混合析因实验设计模型。有不同的受试者组,每个受试者都表示他们对三种不同饮料(水、无咖啡因和咖啡)中的每一种饮料减少咖
我正在尝试使用 RSTAN 拟合随机效应模型。我的设计矩阵有 198 列。它是如此之宽,因为我的原始数据框是一堆因子变量,我将其转换为二进制指标以尝试在 STAN 中拟合模型。我可以使用从一两个预测变
鉴于示例数据 sampleDT 和模型 lm.fit 和 brm.fit 下面,我想: estimate, extract and add to the data frame the values o
我正在使用这里定义的函数:Extreme value analysis and user defined probability functions in Stan for modeling the
我想学习如何在 stan 中使用 Dirichlet 分布。 我有一个表格,其中包含因子变量的六个级别中每个级别的观察总数: counts n factor_var -
有没有办法从 stan 中的偏态正态分布中提取数据?如果不是,有没有办法从正态分布中提取然后转换为偏正态分布? 更新 我在 stan 手册中找到了 y~skew_normal(mu, sigma, a
当从 stan 启动标准示例时 webpage像下面这样: schools_code J; // number of schools real y[J]; // estimated treat
我在学习rstan目前我正在解决 Gelman 的“贝叶斯数据分析”中的练习。作为引用,这是关于第 3 章中的示例 5。 它总是失败: Initialization failed after 100
有没有办法在 Stan 中构造一个带有单纯形列的矩阵?我要构建的模型类似于以下模型,其中我的模型算作狄利克雷多项式: data { int g; int c; int counts[g,
假设我有 gamma=10 的泊松分布。我想拟合一个高斯分布,它可以最小化泊松分布的 KL 散度。这可以通过变分推理来实现。我如何使用 Stan 进行此优化? reference manual有一个关
是否可以根据任意后验函数定义 Stan 模型? 我在想类似于 MCMCPack 的 MCMCmetrop1R() 功能,用户可以在其中定义任意后验函数。如果有一个很好的例子说明如何去做,我愿意深入研究
我是 stan 的新手,我正在实现概率矩阵分解模型。 给定一个用户-项目评分矩阵: item user 1 3 NA 4
我在 PySTAN 工作。假设我的可能性是:p1 * p2 其中p1 ~ N(x, xerr) 和 p2 = 0.823 if t = 0 1 if t = 1 我的模型是: mod
我最近遇到了高斯过程模型,并且碰巧认为它们可能是我实验室一直在研究的问题的解决方案。我有一个关于交叉验证的开放和相关问题,但我想将我的建模/数学问题与我的编程问题分开。因此,这是第二个相关帖子。如果更
我有一个 R 包,它使用 Rcpp 来实现一些内部功能。这些函数不会导出供用户直接访问(请参阅 rcpptest 存储库中的最小可重现示例)。 我现在正尝试将 Stan 代码添加到 src/ 目录,以
根据STAN homepage , STAN 能够进行惩罚最大似然 (BFGS) 优化。我正在使用 R 包 rstan 但我还没有找到如何使用此方法的方法。我试图查看 ?stan 对 stan() 函
我是一名优秀的程序员,十分优秀!