I am running simulations to test my joint model with the codes below. All parameters are converging to the true values except for the shared parameters (gama and r). I have tried different priors but it's not helping. Any help will be highly appreciated.
data{
int<lower=1> Nobs; // number of observations
real time[Nobs];
real y1[Nobs];// Continuous longitudinal outcome
real K;
int<lower=1> N; // number of subjects
int<lower=1,upper=N> id[Nobs]; // subject ID
int<lower=0,upper=1> y2[N];// Binary outcome
vector[4] zero; // a vector of zeros
real survt[N]; // survival time
}
parameters{
real delta; // fixeffs
vector[3] beta;// fixeffs
real alpha;// fixeffs
vector[3] gama;// shared parameter for the survival outcome
vector[3] r;// shared parameter for the binary outcome
vector[4] b[N]; // subj raneffs
real pa; // weibull para
real<lower=0> sigma_e; // residual variance
vector<lower=0>[4] sigma_b; // subj variance
corr_matrix[4] Omega_b; // corr matrix for
// subj raneffs
}
transformed parameters{
cov_matrix[4] Sigma_b; // varcov matrix for subj ranefs
for(l in 1:4){
for(c in 1:4){
Sigma_b[l,c] <- sigma_b[l] * sigma_b[c] * Omega_b[l,c];
}
}
}
model{
real mu[Nobs];
real A[Nobs];
real mu3[N];
for(i in 1:Nobs){
A[i]<- time[i]-(delta + b[id[i],4]);
mu[i] <- K+ if_else(A[i]>=0,(beta[1]*(time[i]-(delta + b[id[i],4])) + beta[2]*((time[i]-(delta + b[id[i],4]))*(time[i]-(delta + b[id[i],4]))) + b[id[i],1]*(time[i]-(delta + b[id[i],4]))+ b[id[i],2]*((time[i]-(delta + b[id[i],4]))*(time[i]-(delta + b[id[i],4])))),
(beta[3]*(time[i]-(delta + b[id[i],4])) + b[id[i],3]*(time[i]-(delta + b[id[i],4]))));
}
y1 ~ normal(mu,sigma_e);
for(j in 1:N){
mu3[j] <- exp(-(gama[1]*b[j,1]+ gama[2]*b[j,2]+gama[3]*b[j,3])/pa);
}
increment_log_prob(weibull_log(survt,pa,mu3)); // Jacobian adjustment
for(j in 1:N){
y2 ~ bernoulli_logit(alpha + r[1]*b[j,1]+ r[2]*b[j,2]+r[3]*b[j,3]);
}
b ~ multi_normal(zero,Sigma_b);
pa ~ gamma(1, 1.0E-3);
sigma_b ~ gamma(1.5,1.0E-4);
sigma_e ~ gamma(1.5,1.0E-4);
Omega_b ~ lkj_corr(2.0);
delta ~ normal(0, 100);
beta ~ normal(0, 100);
}
Thanks in advance.
Olive