Let’s consider a very simple example, it doesn’t work if P is greater than 30.

data {

int<lower=1> P; // number of variables

int<lower=1> N; // number of observations

matrix[N,P] x; // observations

vector[P] mu; // expected value

}

parameters{

cov_matrix[P] Ccov;

}

transformed parameters {

```
cov_matrix[P] identitaP;
```

for (i in 1:P){

for (j in 1:P)

{ if (i==j) { identitaP[i,j]=1;}

else identitaP[i,j]=0;

}

}

}

model {

for (j in 1:N)

x[j]~ multi_normal(mu,Ccov);

Ccov~inv_wishart(P+2,identitaP);

}

I got this message

Exception: multi_normal_lpdf: LDLT_Factor of covariance parameter is not positive definite. last conditional variance is 0. (in ‘model10b4245857c9_programma_wishart’ at line 28)

Exception: multi_normal_lpdf: LDLT_Factor of covariance parameter is not positive definite. last conditional variance is -2.22045e-016. (in ‘model10b4245857c9_programma_wishart’ at line 28)

[1] "Error in sampler$call_sampler(args_list[[i]]) : “

[2] " Exception: multi_normal_lpdf: LDLT_Factor of covariance parameter is not positive definite. last conditional variance is -2.22045e-016. (in ‘model10b4245857c9_programma_wishart’ at line 28)”

[1] “error occurred during calling the sampler; sampling not done”