Hi,

I am trying to use for the first time multivariate models.

I read the manual.

I did two models following it (with and without " Optimization through Cholesky factorization").

In both cases, there are initialisation problems. I’ll copy the error messages below each model.

The observations (y) are integers, that can be positive, negative or zero.

- Without Cholesky factorization

```
data {
int<lower=0> N; // num individuals (observations)
int<lower=1> K; // num ind predictors (= nb of species)
int<lower=1> J; // num groups (= nb of species)
int<lower=1> L; // num group predictors (1?)
int<lower=1,upper=J> jj[N]; // group for individual (species)
matrix[N, K] x; // individual predictors (all abundances at time t)
row_vector[L] u[J]; // group predictors (1 everywhere)
vector[N] y; // outcomes (abundance of focal species at time t)
}
parameters {
corr_matrix[K] Omega; // prior correlation
vector<lower=0>[K] tau; // prior scale
matrix[L, K] gamma; // group coeffs
vector[K] beta[J]; // indiv coeffs by group
real<lower=0> sigma; // prediction error scale
}
model {
tau ~ cauchy(0, 2.5);
Omega ~ lkj_corr(2);
to_vector(gamma) ~ normal(0, 5);
{
row_vector[K] u_gamma[J];
for (j in 1:J)
u_gamma[j] = u[j] * gamma;
beta ~ multi_normal(u_gamma, quad_form_diag(Omega, tau));
}
{
vector[N] x_beta_jj;
for (n in 1:N)
x_beta_jj[n] = x[n] * beta[jj[n]];
y ~ normal(x_beta_jj, sigma);
}
}
```

Errors :

Repeated message :

```
Chain 1: Exception: lkj_corr_lpdf: Shape parameter is 0, but must be > 0! (in 'model1d032109b2a5f_Model' at line 20)
```

And at the last message :

```
Chain 1:
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] "Error in sampler$call_sampler(args_list[[i]]) : Initialization failed."
error occurred during calling the sampler; sampling not done
```

- With Cholesky factorization

```
data {
int<lower=0> N; // num individuals (observations)
int<lower=1> K; // num ind predictors (= nb of species)
int<lower=1> J; // num groups (= nb of species)
int<lower=1> L; // num group predictors (1?)
int<lower=1,upper=J> jj[N]; // group for individual (species)
matrix[N, K] x; // individual predictors (all abundances at time t)
matrix[L, J] u; // group predictors (1 everywhere)
vector[N] y; // outcomes (abundance of focal species at time t)
}
parameters {
matrix[K, J] z;
cholesky_factor_corr[K] L_Omega;
vector<lower=0,upper=pi()/2>[K] tau_unif; // prior scale
matrix[K, L] gamma; // group coeffs
real<lower=0> sigma; // prediction error scale
}
transformed parameters {
vector<lower=0>[K] tau = 2.5 * tan(tau_unif);
matrix[K, J] beta = gamma * u + diag_pre_multiply(tau, L_Omega) * z;
}
model {
vector[N] mu;
for(n in 1:N) {
mu[n] = x[n, ] * beta[, jj[n]];
}
to_vector(z) ~ std_normal();
L_Omega ~ lkj_corr_cholesky(2);
to_vector(gamma) ~ normal(0, 5);
y ~ normal(mu, sigma);
}
```

Repeated message :

```
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can't start sampling from this initial value.
```

Final message :

```
Chain 1:
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] "Error in sampler$call_sampler(args_list[[i]]) : Initialization failed."
error occurred during calling the sampler; sampling not done
```

I don’t see what to do since I don’t know the maths…if some of you have an idea, I would be happy to try it !