问题描述
我正在尝试使用Stan建立实验数据模型。我想让 beta 不小于0且不大于60。如何在模型中进行设置? Beta是在转换后的参数部分定义的。谢谢!
这是我的模特:
// saved as cond1_sav_nor.stan
//
data{
int<lower=1> N; // Number of observations
int<lower=1,upper=6> S; // Number of subjects
int<lower=1,upper=6> subID[N]; // Subject IDs
int<lower=1,upper=4> C; // Number of conditions
int<lower=1,upper=4> condID[N]; // Condition ID
real<lower=0,upper=60> Sav[N]; // Number of tokens saved per session
}
//
transformed data {
vector[S] u;
for (s in 1:S) {
u[s] = 1;
}
}
//
parameters{
matrix[C,S] z; // beta proxy
cholesky_factor_corr[C] L_Omega; // prior correlation
vector<lower=0>[C] tau; // prior scale
row_vector[C] gamma; // population means
real<lower=0> sigma[S];
}
//
transformed parameters{
matrix[S,C] beta; // I want the beta to be bigger than 0 and smaller than 60.
beta = u * gamma + (diag_pre_multiply(tau,L_Omega) * z)';
}
//
model{
real muSav;
to_vector(z) ~ normal(0,1);
L_Omega ~ lkj_corr_cholesky(1);
tau ~ exponential(1);
to_vector(gamma) ~ normal(0,1);
sigma ~ cauchy(0,2);
for ( n in 1:N ) {
muSav = beta[subID[n],condID[n]];
Sav[n] ~ normal(muSav,sigma[subID[n]]);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)