如何解决如何在Stan中设置参数优先级的范围?
我正在尝试使用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 举报,一经查实,本站将立刻删除。