【发布时间】:2021-07-08 16:03:56
【问题描述】:
我想用 Stan 拟合 Lotka-Volterra 竞赛模型。 我读了section about multivariate hierarchical priors in the manual。
我们有:
- “个体”= 在时间 t 观察到焦点物种的丰度
- “组”= 焦点物种
- “预测因子”= 每个物种的丰度
- “结果”= t 和 t+1 之间的焦点物种丰度增量 (对于知道模型的人,我现在只尝试推断交互矩阵(alpha),稍后我将添加物种增长率(但它更简单,因为不需要多变量)。
但在手册中,他们在 Stan 模型中添加了“先验均值的组级预测变量”。 我认为我不需要这个,我什至看不到它在我的数据中会是什么(也许我错了,告诉我是不是这样!)。 因此我试图删除它。但我对我的模型非常不确定,尤其是 mu,如果我对这些模型更有经验的人能告诉我我是否错了,我会很高兴。
data {
int<lower=0> N; // num individuals (generations)
int<lower=1> K; // num ind predictors (species)
int<lower=1> J; // num groups (species)
int<lower=1,upper=J> jj[N]; // group for individual
matrix[N, K] x; // individual predictors
vector[N] y; // outcomes
}
parameters {
corr_matrix[K] Omega; // prior correlation
vector<lower=0>[K] tau; // prior scale
vector[K] beta[J]; // indiv coeffs by group
vector[K] mu[J]; // mean coeff by group
real<lower=0> sigma; // prediction error scale
}
model {
tau ~ cauchy(0, 2.5);
Omega ~ lkj_corr(2);
{
for (j in 1:J)
mu[J] ~ normal(0, 5);
beta ~ multi_normal(mu, quad_form_diag(Omega, tau));
}
for (n in 1:N)
y[n] ~ normal(x[n] * beta[jj[n]], sigma);
}
【问题讨论】:
标签: stan