Trying to run my first Bayesian model with a toy example
The model is a simple modification from the social relations model in the statistical rethinking book.
The original model in the book
f_dyad <- alist(
GAB ~ poisson( lambdaAB ),
GBA ~ poisson( lambdaBA ),
log(lambdaAB) <- a + T[D,1] ,
log(lambdaBA) <- a + T[D,2] ,
a ~ normal(0,1),
## dyad effects - non-centered
transpars> matrix[N_dyads,2]:T <-
compose_noncentered( rep_vector(sigma_T,2) , L_Rho_T , Z ),
matrix[2,N_dyads]:Z ~ normal( 0 , 1 ),
cholesky_factor_corr[2]:L_Rho_T ~ lkj_corr_cholesky( 2 ),
sigma_T ~ exponential(1),
## compute correlation matrix for dyads
gq> matrix[2,2]:Rho_T <<- Chol_to_Corr( L_Rho_T )
)
mGD <- ulam( f_dyad , data=sim_data , chains=4 , cores=4 , iter=2000 )
I want to try a linear version of it
f_dyad <- alist(
GAB ~ normal(mAB,e),
GBA ~ normal(mBA,e),
mAB <- T[D,1] ,
mBA <- T[D,2] ,
e ~ exponential(1),
## dyad effects - non-centered
transpars> matrix[N_dyads,2]:T <-
compose_noncentered( rep_vector(sigma_T,2) , L_Rho_T , Z ),
matrix[2,N_dyads]:Z ~ normal( 0 , 1 ),
cholesky_factor_corr[2]:L_Rho_T ~ lkj_corr_cholesky( 2 ),
sigma_T ~ exponential(1),
## compute correlation matrix for dyads
gq> matrix[2,2]:Rho_T <<- Chol_to_Corr( L_Rho_T )
)
mGD <- ulam( f_dyad , data=sim_data , chains=4 , cores=4 , iter=2000 )
But the model won’t converge and I got bad effective sample size and rhat. What I am doing wrong here?