2
我正在嘗試將一些代碼從JAGS移植到Stan。說我有以下數據集:在Stan中部分觀測的參數
N <- 10
nchoices <- 3
ncontrols <- 3
toydata <- list("y" = rbinom(N, nchoices - 1, .5),
"controls" = matrix(runif(N*ncontrols), N, ncontrols),
"N" = N,
"nchoices" = nchoices,
"ncontrols" = ncontrols)
和我要運行用下面的代碼多項式Logit(從文檔的第9.5節所):
data {
int N;
int nchoices;
int y[N];
int ncontrols;
vector[ncontrols] controls[N];
}
parameters {
matrix[nchoices, ncontrols] beta;
}
model {
for (k in 1:nchoices)
for (d in 1:ncontrols)
beta[k,d] ~ normal(0,100);
for (n in 1:N)
y[n] ~ categorical(softmax(beta * controls[n]));
}
我現在要修復第一行beta
歸零。在JAGS中,我只是在模型塊中聲明
for (i in 1:ncontrols) {
beta[1,i] <- 0
}
但我不確定在Stan如何做到這一點。我已經嘗試了許多組合沿着文檔(部分已知參數)的6.2節的行,例如,
但他們都沒有工作。有什麼建議麼?
工程就像一個夢。謝謝。 – griverorz