Optimization 大数据集采样期间的Rstan错误
我建立了一个简单的分层stan模型来检索二项分布的概率θ(代码如下) 我的输入数据是一个表格,其中包含所有(N)个和成功(N)个试验的数量信息,以及它所属的组的元数据(x:0-1,t:1-225,g:1-4和c:1-4) N N x T G C 123 10 1. 1. 1. 2. 531 500 1. 0 1. 1. 12 6. 0 1. 2. 1. 我得到了一个解决方案: 显然有太多(不必要的)中间变量,这会使程序崩溃。你可以用“二项式逻辑()替换“二项式()”,从而去掉θ。而for循环也可以用更优雅的alternativ替代Optimization 大数据集采样期间的Rstan错误,optimization,limit,stan,rstan,Optimization,Limit,Stan,Rstan,我建立了一个简单的分层stan模型来检索二项分布的概率θ(代码如下) 我的输入数据是一个表格,其中包含所有(N)个和成功(N)个试验的数量信息,以及它所属的组的元数据(x:0-1,t:1-225,g:1-4和c:1-4) N N x T G C 123 10 1. 1. 1. 2. 531 500 1. 0 1. 1. 12 6. 0 1. 2. 1. 我得到了一个解决方案: 显然有太多(不必要的)中间变量,这会使程序崩溃。你可以用“二项式逻辑()替换“二项式()”,从而去掉θ。而for循环也可
data {
int<lower=1> Nr; //
int<lower=1> Nt;//
int<lower=1> Nxtgc; //
int<lower=1> xtgc[Nr]; //
int<lower=1> N[Nr]; //
int<lower=0> n[Nr]; //
int<lower=1> tLookup[Nxtgc]; // lookuptable for combination which t it belongs to
}
parameters {
real a_t[Nt];
real a_xtgc[Nxtgc];
real <lower=0>sigma_xtgc;
real <lower=0>simga_t;
}
model {
simga_t ~ exponential(0.01);
a_t ~ normal(-4,simga_t);
sigma_xtgc ~ exponential(0.01);
a_xtgc ~ normal(a_t[tLookup],sigma_xtgc);
n ~ binomial_logit(N, a_xtgc[xtgc]);
}
数据{
内部编号;//
int Nt//
int Nxtgc;//
int-xtgc[Nr];//
整数N[Nr];//
整数n[Nr];//
int-tLookup[Nxtgc];//可查找它所属的组合
}
参数{
真正的a_t[Nt];
真正的a_xtgc[Nxtgc];
实sigma_xtgc;
真正的辛加;
}
模型{
simga_t~指数(0.01);
a_t~正常(-4,simga_t);
sigma_xtgc~指数(0.01);
a_xtgc~正常(a_t[tLookup],sigma_xtgc);
n~二项逻辑(n,a_xtgc[xtgc]);
}