Hi,

I have written a Rstan code for a linear mixed-effects model with a random intercept and a Brownian motion stochastic process. I used the stan() to do that. I also passed initial values into the function. But, If I run it for 4 chains, 10000 iterations, It runs for 2 (or less) chains completely and maybe half of the remaining to chains and does not go forward than that. The same thing happens when I change the number of chains/iterations. I appreciate any suggestions/ help. Thanks!

```
functions{
matrix vcovFBM(vector t,//input timeSince_t0 from ni_l to ni_u
real H,
int n,
real kappa)//input ni as a number
{
matrix[n, n] m;
for(j in 1:n)
{
for(k in 1:n)
{
if(j == k)
{
m[j, k] = pow(fabs(t[j]), 2*H);
}
else{
m[j, k] = kappa*0.5*(pow(fabs(t[j]), 2*H) + pow(fabs(t[k]), 2*H) - pow(fabs(t[j] - t[k]), 2*H));
}
}
}
return (cholesky_decompose(m));
}
}
data {
// Define variables in data
// Number of level-1 observations (an integer)
int<lower=0> N;
// Number of level-2 clusters
int<lower=0> Ni;
// Cluster IDs
int<lower=1> level2[N];
int K;
// Continuous outcome
real<lower=0> Y_ij[N];
// Continuous predictor
matrix<lower=0>[N, K] X_ij;
int<lower=0> ni_l[Ni];
int<lower=0> ni_u[Ni];
vector<lower=0>[N] timeSince_t0;
int<lower=1> ni[Ni];
}
parameters {
// Define parameters to estimate
//Parameters of covariates
vector[K] alpha;
// Level-1
real<lower=0> sigma;
// Level-2 random effect
real ui[Ni];
real<lower=0> tau;
vector[N] wij;
real<lower=0> kappa;
//real<lower=0,upper=1> H;
}
transformed parameters {
// Varying intercepts
real alpha_0j[Ni];
// Individual mean
vector[N] mu;
// Level-2 (100 level-2 random intercepts)
for (j in 1:Ni) {
alpha_0j[j] = ui[j];
}
// Individual mean
for (i in 1:N) {
mu[i] = alpha_0j[level2[i]] + X_ij[i,]*alpha + wij[i];
}
}
model {
// Prior part of Bayesian inference
sigma ~ inv_gamma(1, 10^4);
tau ~ inv_gamma(1, 10^4);
alpha ~ normal(0, 10^4);
H ~ uniform(0, 1);
kappa ~ inv_gamma(0, 10);
// Random effects distribution
ui ~ normal(0, tau);
//FBM
for(i in 1 : Ni)
{
wij[ni_l[i]:ni_u[i]] ~ multi_normal_cholesky(rep_vector(0, ni[i]), vcovBM(timeSince_t0[ni_l[i]:ni_u[i]], ni[i], kappa));
}
// Likelihood part of Bayesian inference
// Outcome model N(mu, sigma^2) (use SD rather than Var)
for (i in 1:N) {
//target += normal_lpdf(Y_ij[i] | mu[i], sigma)
Y_ij[i] ~ normal_lpdf(mu[i], sigma);
}
}
```