问题标签 [stan]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
523 浏览

ode - 如何使用 stans integration_ode x 输入?

最近 stan 添加了该integrate_ode方法。不幸的是,我能找到的唯一文档是stan 参考手册(第 191 页)。我有一个需要一些驱动信号的模型。据我了解该参数x_r并且x_i应该用于此。

为了具体示例,假设我想通过以下更改来实现文档中的示例:

输入信号应该是输入的时间序列 - 假设我提交input_signal_vector <- sin(t) + rnorm(T, sd=0.1)(应该是 中时间点的信号ts)并且我计划使用input_signal最接近的时间值。

我能想象的唯一方法是可以 concat tsand input_signal_vectorin x_r 然后在这个数组中搜索。但我无法想象这是这些参数的预期用途。这也将是极其低效的。

因此,如果有人能说明应该如何解决这种情况,我将不胜感激。

0 投票
1 回答
1178 浏览

bayesian - pymc3 中不正确的、平坦的先验

我正在将来自 Stan 的 ARM 书中的选定模型“翻译”到 pymc3(我希望尽快将它们发布到 Github 上),并且我有一个关于“不正确的先验”的问题。

我知道 Stan 默认是对参数使用统一的先验。如果无界,这意味着统一(-inf,+inf)

我的问题是:无论如何在pymc3中指定这样的先验?

这是一个示例来说明问题以及我到目前为止所做的尝试。

在斯坦(pystan)

在pymc3

我查看了 glm 的源代码,它似乎默认使用模糊的先验,Krutschke 和许多 BUGS 示例也推荐这种做法并且它有效(见上文)。然而,立场参考手册(第 52 页)表示,他们积极劝阻用户不要使用默认比例先验,因为他们将太多的概率质量集中在合理的后验值之外(...)可能会产生倾斜后验的深远影响

0 投票
0 回答
88 浏览

r - 尝试为贝叶斯分析运行 STAN 脚本时出错

当我尝试运行John KruschkeStan-Ymet-Xnom1grp-Mrobust-Example.r的脚本时,我收到以下错误:

在 Internet 上搜索并没有返回任何对我有帮助的信息。可能是什么问题呢?

0 投票
1 回答
2050 浏览

r - How to define a set of vectors with various length in Stan model

I have a set of time-series variables with different length, and I am trying to estimate a hierarchical autoregressive model using the Stan language (using rstan). I have learned the basics of Stan, but am not sure how I should express a set of vectors with differing length.

I ended up augmenting the shorter vectors by filling arbitrary numbers so that all vectors have the same length, and ignored these filled values in the model section.

While this seems to be working, I would like to know if there are better ways to define this type of data. Any suggestion is appreciated!

I am on Ubuntu 14.04 with R version 3.2.3 and rstan_2.9.0.

Data

My data looks like this. Note that there are three vectors in y, each having length 3, 5, and 10. I filled the shorter vectors with 100 so that all vectors are of size 10.

Stan code

My Stan code is as follows:

R script

The code below reproduces my data, Stan code and the fitting in R.

0 投票
2 回答
3281 浏览

python - 如何处理stan中的缺失数据?

我是 stan 的新手,我正在实施概率矩阵分解模型。

给定一个用户项目评分矩阵:

我应该如何表示块中的可观察数据和data块中用于预测的缺失数据parameter

先感谢您!

编辑:

现在我正在实现如下模型:

No matches for: real ~ normal(matrix, real)在这行代码中出现错误:

但是jj[d]应该是一个整数,表示 的 id user。并且 u[ int] 应该是一个row_vectorhask因子,所以i[ii[d]]. 他们的产品应该是一个单一的真实价值,为什么斯坦说它是一个matrix

0 投票
1 回答
1218 浏览

r - STAN 中的简单 Gamma GLM

我正在 STAN 和 R 中尝试一个简单的 Gamma GLM,但它会立即崩溃

生成数据:

这是我的 STAN 模型:

当我运行这个模型时,R 立即崩溃:

更新:我认为问题出在向量化的某个地方,因为我可以获得一个运行模型,其中我将 X 的每一列作为向量传递。

update2:这也有效

0 投票
1 回答
817 浏览

python - 将两个 1*k 向量相乘,但在 pystan 中没有匹配项:real ~ normal(matrix, real) 错误

现在我正在实现 pmf 模型,如下所示:

No matches for: real ~ normal(matrix, real)在这行代码中出现错误:

jj[d]应该是 a int,表示 的 id user。并且u[int]应该是一个row_vectork因素等等i[ii[d]]。它们的乘积应该是一个单一的实数值,为什么 stan 说它是一个矩阵?

提前致谢!

编辑:

通过添加sum产品解决了最初的问题。但是现在又出现了一个错误:

在 pmf 模型中,I是单位矩阵。所以 的乘积(1/alpha_u) * I也是一个矩阵。但是 stan 只是接受向量或实数值作为方差。我想知道如何将其转换为向量或单个值。谢谢。

0 投票
1 回答
239 浏览

bayesian - stan 中向量的分位数

我想在 stan 中使用向量的分位数,但函数 quantile 似乎不起作用。请参阅以下示例中的 ** **。

0 投票
1 回答
75 浏览

python - 无法在pystan中实现pmf模型

我是 stan 和机器学习的新手。现在我想实现 pmf 模型。这是我的代码的一部分:

但是我得到了一个错误:No matches for: row vector ~ normal(int, matrix)在这行代码中:

哪里I是单位矩阵。所以 的乘积(1/alpha_u) * I也是一个矩阵。但是 stan 只是接受向量或实数值作为方差。我想知道如何将其转换为向量或单个值。

先感谢您!

0 投票
2 回答
1048 浏览

python - PyStan API 中的变分推理?

我在PyStan 文档中找不到任何提及变分推理的内容,即使它已添加到 Stan 本身中。我错过了什么,还是 Python API 还没有实现它?