data { int N; real y[N]; matrix[N,N] A; #vector[N] mu_u_prior; } transformed data { matrix[N,N] t_LA_inv; matrix[N,N] A_inv; A_inv <- inverse(A); t_LA_inv <- transpose(cholesky(A_inv)); } parameters{ real beta0; vector[N] u; real sigmasq_e; real sigmasq_u; } model { ##----------------------------------------------- vector[N] v; real sum_of_squares; v <- t_LA_inv * u; sum_of_squares <- 0.0; // or sum(pow(v, 2)) may / should work for(i in 1:N) { sum_of_squares <- sum_of_squares + pow(v[i], 2); } lp__ <- lp__ - 0.5 * N * log(sigmasq_u); // non-constant part of log(det(sigmasq_u * A)^-0.5) lp__ <- lp__ - sum_of_squares / (2 * sigmasq_u); // log of kernel of multivariate normal ## likelihood for(i in 1:N){ y[i] ~ normal(beta0 + u[i], sqrt(sigmasq_e)); } ##--------------------------------- ## priors beta0 ~ normal(0,1000); sigmasq_e ~ scaled_inv_chi_square(2,0.25); sigmasq_u ~ scaled_inv_chi_square(2,0.25); } ## TRANSLATING MODEL 'anon_model' FROM Stan CODE TO C++ CODE NOW. ## Error in stanc(file = file, model_code = model_code, model_name = model_name, : ## failed to parse Stan model 'anon_model' and error message provided as: ## LOCATION: file=input; line=11, column=40 ## t_LA_inv <- transpose(cholesky(A_inv)); ## ^-- here ## DIAGNOSTIC(S) FROM PARSER: ## no matches for function name="cholesky" ## arg 0 type=matrix ## expression is ill formed ## Parser expecting: