model{
matrix[Ntm,Ntm] L_beta_0_prior;
matrix[Ncovar,Ncovar] L_betas_prior;
#impute missing standard deviations
s_obs~cauchy(0,scl);
s_ms~cauchy(0,scl);
#hyper priors for intercept and coefficients
beta_0_prior~multi_normal_cholesky(hyper_beta_0,L_beta_0_hyper);
betas_prior~multi_normal_cholesky(hyper_betas,L_betas_hyper);
#heterogeneity parameter for random effect for intercept and coefficients
tau_beta_0_sing ~ inv_gamma(gam_shape,gam_rate);
tau_betas_sing ~ inv_gamma(gam_shape,gam_rate);
#correlation matrices for prior and study
Omega_prior ~ lkj_corr(1);
Omega_study ~ lkj_corr(1);
L_betas_prior<-cholesky_decompose(diag_matrix(rep_vector(sqrt(tau_betas_sing),Ncovar)));
L_beta_0_prior <- cholesky_decompose(Omega_prior);
for (i in 1:Ntm){
for (j in 1:i){
L_beta_0_prior[i,j] <- sqrt(tau_beta_0_sing) * L_beta_0_prior[i,j];
}
}
#study level intercept and coefficients
for(study in 1:Nstudy){
beta_0[study]~multi_normal_cholesky(beta_0_prior,L_beta_0_prior);
betas[study]~multi_normal_cholesky(betas_prior,L_betas_prior);
}
for(grp in 1:Ngrp){
matrix [len_tms[grp],Ntm] des_mat;
vector [len_tms[grp]] temp1;
vector [len_tms[grp]] temp2;
matrix [len_tms[grp],len_tms[grp]] temp3;
matrix [len_tms[grp],len_tms[grp]] temp4;
#Create a design matrix for each study, so that only observed time points are used
des_mat<- rep_matrix(0,len_tms[grp],Ntm);
for(i in 1:len_tms[grp]){
des_mat[i,tms[grp,i]]<-1;
}
temp1<-des_mat*mns[grp];
temp2<-des_mat*beta_0[study_ind[grp]];
temp3<- des_mat*covar_grp[grp]*des_mat';
temp4<-cholesky_decompose(temp3);
temp1~multi_normal_cholesky(temp2,temp4);
}
}
Error in function stan::prob::lkj_corr_log(N4stan5agrad3varE): yy is not positive definite. y(0,0) is 1:0.Rejecting proposed initial value with zero density.
Initialization failed after 100 attempts. Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
Error in function stan::prob::lkj_corr_log(N4stan5agrad3varE): yy is not symmetric. y[0,1] is 1.2277783349104863:0, but y[1,0] element is -1.2975:0Rejecting proposed initial value with zero density.
Initialization failed after 100 attempts. Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
My model runs when the parameters Omega_prior and Omega_study are a diagonal matrix of 1 (uncomment variable definition in data block, and comment in parameter block).When I run the model using the lkj distribution I get the error:Error in function stan::prob::lkj_corr_log(N4stan5agrad3varE): yy is not positive definite. y(0,0) is 1:0.Rejecting proposed initial value with zero density.Initialization failed after 100 attempts. Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
Omega_prior ~ lkj_corr(1);
Omega_study ~ lkj_corr(1);
When I define the Omega_ parameters simply as matrices (not corr_matrix), I get the error:Error in function stan::prob::lkj_corr_log(N4stan5agrad3varE): yy is not symmetric. y[0,1] is 1.2277783349104863:0, but y[1,0] element is -1.2975:0Rejecting proposed initial value with zero density.Initialization failed after 100 attempts. Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/eFMxEuV_ENA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks for your tips. I have built the model up from smaller chunks, and it works properly until I reach this point.
My correlation matrix is 16x16... could this be the problem?
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/eFMxEuV_ENA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.