Hi, sorry that I keep bugging you with questions. Now I want to make a more complicated model, and revised my code as follows. something went wrong with the data “trial”. The model can be complied but when I apply my data, it showed error message. My data should be good, the variable “trial” only contains 1,2,3,4,5,6,7,8.
data{
int T;
int N;
vector[N] score;
matrix[N, T] A;
int trial[N];
int<lower=0> y1[N,T];
int<lower=0> y2[N,T];
}
transformed data{
matrix[N,T] log_A;
log_A = log(A);
}
parameters{
matrix[1,2] beta;
vector[T] d;
matrix[2,8] ran_trial;
vector[2] s_trial;
}
transformed parameters{
vector[T] log_d;
log_d= log(d)
}
model {
for (o in 1:2){
beta[1,o] ~ normal(0,1)
s_trial[o] ~ student_t(1,0,1)
for(tn in 1:8){
ran_trial[o, tn] ~ normal(0,s_trial[o]}
}}
d ~ exponential(1);
for(j in 1:T) {
for (i in 1:N) {
y1[i,j] ~ poisson_log(log_A[i,j] +beta[1,1]* score[i] +ran_trial[1,trial[i]]+log_d);
y2[i,j] ~ poisson_log(log_A[i,j] +beta[1,2]* score[i] +ran_trial[2,trial[i]]+log_d);
}}
}
Error in new_CppObject_xp(fields$.module, fields$.pointer, …) :
Exception: variable does not exist; processing stage=data initialization; variable name=trial; base type=int (in ‘model29045b845223_104d2d1efc277c900643b11430b3da1e’ at line 14)
In addition: Warning message:
In FUN(X[[i]], …) : data with name trial is not numeric and not used
failed to create the sampler; sampling not done
…
Besides, when I complied the model, it showed warning:
Warning message:
In if (nchar(CXX) > 0) return(TRUE) :
the condition has length > 1 and only the first element will be used
Is it normal?