Hello, I am modelling correlated binary outcomes using my own distribution. However when I use inv_logit for my probabilities take values outside 0 and 1 even if i set up constrains for p and used my own initial values.
Any ideas???
transformed parameters{
real<lower = -1, upper = 1> rho1;
real ktau1;
vector<lower = 0, upper = 1>[2] pA[Ns];
vector<lower = 0, upper = 1>[2] pB[Ns];
matrix[2,2] Sigma;
//rho1 = tanh(etarho1);
rho1 = etarho1*2-1;
for (i in 1:Ns){
pA[i][1] = inv_logit(mu1[i]);
pA[i][2] = inv_logit(mu2[i]);
pB[i][1] = inv_logit(mu1[i]+delta[i,1]);
pB[i][2] = inv_logit(mu2[i]+delta[i,2]);
}
ktau1 = (2/pi())*asin(rho1);
Sigma[1, 1] = sigma[1]^2;
Sigma[1, 2] = sigma[1]*sigma[2]*rho1;
Sigma[2, 1] = sigma[1]*sigma[2]*rho1;
Sigma[2, 2] = sigma[2]^2;
}
model{
//etarho1 ~ beta(1.5,1.5);
theta ~ uniform(-30,30);
etarho1 ~ beta(1.5,1.5);
d ~ normal(0, 10);
sigma ~ cauchy(0, 5);
mu1 ~ normal(0, 10);
mu2 ~ normal(0, 10);
for (i in 1:Ns){
delta[i] ~ multi_normal(d,Sigma);
}
for(i in 1:Ns){
rA[i] ~ BBinom(pA[i], N[i],theta);
rB[i] ~ BBinom(pB[i], N[i],theta);
}
}
Chain 1: Rejecting initial value:
Chain 1: Error evaluating the log probability at the initial value.
Chain 1: Exception: Exception: binomial_cdf: Probability parameter is 2, but must be in the interval [0, 1] (in ‘model3eb434f32c81_BB2’ at line 36)
(in ‘model3eb434f32c81_BB2’ at line 95)
Chain 1:
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”
[1] “error occurred during calling the sampler; sampling not done”
Thanks a lot.