# Some questions about multi_normal distribution

Hi~
I am having an issue with the multi_normal distribution
I am running an ordered probit model like the following

data{

int<lower=0> K; //6 rating categories
int<lower=0> N;  //sample size
int<lower=1> D;  //8 forecast variable
int<lower=0> T;   //7 year
int T_year[D];  // cutoffs to separate data
int<lower=1,upper=K> y[N]; \\six rating
row_vector[D] x[N];  \\ independent variables
vector[D] a;  \\ 0 vector
}
parameters {
vector[D] beta1[T];   \\estimated parameters
ordered[K-1]  c[T];   \\estimated cutoff
real<lower=0> sigma;
vector<lower=0>[D] sigmacov;
}

model {

vector[K] theta[T];

beta1[1]~ normal(a, sigma);
for (i in 2:T){
beta1[i] ~ normal(beta1[i-1],sigmacov);
}
for (t in 1:T){

for( n in (T_year[t]+1):T_year[t+1]){
real eta;
eta = x[n] * beta1[t];
theta[t,1] = 1 - Phi(eta - c[t,1]);
for (k in 2:(K-1)){
theta[t,k] = Phi(eta - c[t,k-1]) - Phi(eta - c[t,k]);
}
theta[t,K] = Phi(eta - c[t,K-1]);
y[n] ~ categorical(theta[t]);
}
}

}


I wanna express the following process:

\beta_t=\beta_{t-1}+\epsilon_t
\beta_1 \sim N(0, \sigma_\beta^2 I_{N \times N})
\epsilon_t \sim N(0,\sum)

but when I put it in stan, got that:

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.
Chain 1:
Chain 1: Gradient evaluation took 0.01 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 100 seconds.
Chain 1:
Chain 1:
Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)


I donâ€™t know which section I make mistakes in.
Any suggestions?

I find that if I make only a real sigma for beta1, it has a good result
I change my code like this:

data{

int<lower=0> K; //6 rating categories
int<lower=0> N;  //sample size
int<lower=1> D;  //7 forecast variable
int<lower=0> T;
int T_year[8];  // year data
int<lower=1,upper=K> y[N];
row_vector[D] x[N];
vector[D] a;
}
parameters {
vector[D] beta1[T];
ordered[K-1]  c[T];
real<lower=0> sigma;
//cov_matrix[D] sigmacov;
}

model {

vector[K] theta[T];

beta1[1]~ normal(a, sigma);
for (i in 2:T){
beta1[i] ~ normal(beta1[i-1],sigma);
}
for (t in 1:T){

for( n in (T_year[t]+1):T_year[t+1]){
real eta;
eta = x[n] * beta1[t];
theta[t,1] = 1 - Phi(eta - c[t,1]);
for (k in 2:(K-1)){
theta[t,k] = Phi(eta - c[t,k-1]) - Phi(eta - c[t,k]);
}
theta[t,K] = Phi(eta - c[t,K-1]);
y[n] ~ categorical(theta[t]);
}
}

}


I got:

               mean se_mean   sd     2.5%      25%      50%      75%    97.5% n_eff Rhat
beta1[1,1]    -0.64    0.01 0.39    -1.41    -0.90    -0.64    -0.38     0.13  5363    1
beta1[1,2]     0.22    0.00 0.11     0.02     0.15     0.23     0.29     0.43  5798    1
beta1[1,3]     3.49    0.01 0.63     2.29     3.06     3.47     3.91     4.78  2045    1
beta1[1,4]    -0.24    0.01 0.44    -1.12    -0.53    -0.24     0.06     0.63  2476    1
beta1[1,5]     1.67    0.01 0.34     1.03     1.44     1.67     1.90     2.36  4187    1
beta1[1,6]     0.11    0.01 0.26    -0.41    -0.07     0.11     0.28     0.63  2447    1
beta1[1,7]     0.02    0.01 0.46    -0.88    -0.29     0.02     0.32     0.92  1809    1
beta1[2,1]    -1.12    0.01 0.39    -1.93    -1.38    -1.12    -0.86    -0.36  4977    1
beta1[2,2]     0.16    0.00 0.10    -0.04     0.09     0.16     0.23     0.35  6280    1
beta1[2,3]     4.40    0.01 0.62     3.24     3.98     4.39     4.81     5.65  1911    1
beta1[2,4]    -0.02    0.01 0.48    -0.94    -0.34    -0.03     0.30     0.92  1632    1
beta1[2,5]     1.15    0.00 0.33     0.51     0.93     1.14     1.36     1.80  5959    1
beta1[2,6]     0.08    0.01 0.27    -0.46    -0.09     0.08     0.25     0.63  1928    1
beta1[2,7]     0.07    0.01 0.50    -0.92    -0.26     0.07     0.41     1.06  1392    1
beta1[3,1]    -0.86    0.01 0.35    -1.54    -1.10    -0.86    -0.62    -0.17  4829    1
beta1[3,2]     0.04    0.00 0.10    -0.15    -0.03     0.04     0.10     0.22  5996    1
beta1[3,3]     4.26    0.01 0.61     3.10     3.85     4.25     4.67     5.50  2653    1
beta1[3,4]    -0.06    0.01 0.48    -1.02    -0.39    -0.06     0.26     0.91  1277    1
beta1[3,5]     0.85    0.00 0.32     0.22     0.63     0.85     1.07     1.49  5474    1
beta1[3,6]    -0.01    0.01 0.28    -0.57    -0.21    -0.01     0.19     0.54  1373    1
beta1[3,7]     0.44    0.02 0.52    -0.57     0.08     0.44     0.79     1.49   991    1
beta1[4,1]    -0.85    0.01 0.38    -1.58    -1.10    -0.85    -0.59    -0.09  5204    1
beta1[4,2]    -0.11    0.00 0.08    -0.26    -0.16    -0.11    -0.05     0.05  5894    1
beta1[4,3]     3.75    0.01 0.52     2.73     3.39     3.73     4.10     4.77  3548    1
beta1[4,4]    -0.05    0.01 0.48    -0.98    -0.37    -0.06     0.27     0.90  1215    1
beta1[4,5]     1.64    0.00 0.35     0.96     1.41     1.64     1.88     2.35  5769    1
beta1[4,6]    -0.02    0.01 0.28    -0.54    -0.21    -0.02     0.17     0.54  1275    1
beta1[4,7]     0.34    0.02 0.53    -0.69    -0.03     0.34     0.69     1.37   990    1
beta1[5,1]    -0.67    0.01 0.38    -1.41    -0.94    -0.68    -0.41     0.08  5084    1
beta1[5,2]    -0.01    0.00 0.08    -0.16    -0.06    -0.01     0.04     0.13  6003    1
beta1[5,3]     2.99    0.01 0.39     2.22     2.72     2.99     3.26     3.75  3923    1
beta1[5,4]     0.44    0.01 0.48    -0.54     0.12     0.44     0.77     1.36  1042    1
beta1[5,5]     1.73    0.00 0.35     1.05     1.50     1.73     1.97     2.43  5461    1
beta1[5,6]    -0.20    0.01 0.27    -0.74    -0.39    -0.20    -0.02     0.33  1091    1
beta1[5,7]     0.27    0.02 0.53    -0.78    -0.09     0.26     0.62     1.34   816    1
beta1[6,1]    -0.66    0.01 0.38    -1.39    -0.92    -0.67    -0.41     0.11  4464    1
beta1[6,2]     0.10    0.00 0.08    -0.06     0.05     0.10     0.15     0.25  5930    1
beta1[6,3]     2.72    0.01 0.40     1.94     2.45     2.72     2.99     3.49  3257    1
beta1[6,4]     1.04    0.02 0.47     0.13     0.73     1.05     1.36     1.97   961    1
beta1[6,5]     1.69    0.00 0.30     1.09     1.48     1.68     1.89     2.29  5877    1
beta1[6,6]    -0.41    0.01 0.24    -0.86    -0.58    -0.41    -0.25     0.05  1166    1
beta1[6,7]     0.43    0.02 0.49    -0.54     0.09     0.44     0.76     1.40   875    1
beta1[7,1]    -1.48    0.01 0.40    -2.27    -1.75    -1.48    -1.21    -0.71  5209    1
beta1[7,2]     0.13    0.00 0.10    -0.06     0.06     0.13     0.19     0.32  5600    1
beta1[7,3]     3.30    0.01 0.59     2.15     2.91     3.30     3.69     4.48  5061    1
beta1[7,4]     0.60    0.02 0.51    -0.39     0.24     0.59     0.94     1.60  1093    1
beta1[7,5]     1.74    0.00 0.33     1.09     1.52     1.74     1.96     2.41  5745    1
beta1[7,6]     0.39    0.01 0.30    -0.20     0.18     0.39     0.59     1.00  1410    1
beta1[7,7]    -0.21    0.02 0.59    -1.35    -0.61    -0.22     0.20     0.96  1065    1
c[1,1]        -2.53    0.01 0.29    -3.13    -2.73    -2.52    -2.34    -1.97  2434    1
c[1,2]        -1.18    0.00 0.22    -1.61    -1.33    -1.18    -1.04    -0.76  2711    1
c[1,3]        -0.40    0.00 0.21    -0.81    -0.54    -0.40    -0.25     0.01  2608    1
c[1,4]         0.74    0.00 0.21     0.33     0.60     0.74     0.88     1.16  2607    1
c[1,5]         1.31    0.00 0.21     0.89     1.17     1.31     1.46     1.74  2682    1
c[2,1]        -2.52    0.01 0.29    -3.10    -2.71    -2.52    -2.33    -1.95  2047    1
c[2,2]        -1.46    0.01 0.23    -1.92    -1.62    -1.46    -1.31    -1.02  2052    1
c[2,3]        -0.66    0.00 0.22    -1.10    -0.81    -0.66    -0.51    -0.23  1991    1
c[2,4]         0.66    0.00 0.22     0.23     0.51     0.65     0.81     1.09  1998    1
c[2,5]         1.26    0.00 0.22     0.81     1.11     1.27     1.41     1.69  2023    1
c[3,1]        -2.27    0.01 0.26    -2.78    -2.44    -2.26    -2.09    -1.76  1613    1
c[3,2]        -1.17    0.01 0.22    -1.59    -1.33    -1.17    -1.03    -0.74  1560    1
c[3,3]        -0.56    0.01 0.21    -0.97    -0.71    -0.56    -0.42    -0.15  1542    1
c[3,4]         0.67    0.01 0.21     0.25     0.52     0.67     0.82     1.07  1583    1
c[3,5]         1.28    0.01 0.22     0.87     1.13     1.29     1.43     1.70  1588    1
c[4,1]        -2.05    0.01 0.24    -2.52    -2.22    -2.05    -1.89    -1.59  1412    1
c[4,2]        -1.15    0.01 0.22    -1.57    -1.30    -1.15    -0.99    -0.72  1377    1
c[4,3]        -0.68    0.01 0.21    -1.09    -0.83    -0.69    -0.54    -0.26  1391    1
c[4,4]         0.47    0.01 0.21     0.06     0.32     0.46     0.61     0.88  1379    1
c[4,5]         1.14    0.01 0.21     0.73     1.00     1.14     1.28     1.56  1418    1
c[5,1]        -1.52    0.01 0.22    -1.96    -1.67    -1.52    -1.37    -1.11  1248    1
c[5,2]        -0.62    0.01 0.21    -1.06    -0.76    -0.62    -0.48    -0.22  1203    1
c[5,3]        -0.16    0.01 0.21    -0.58    -0.29    -0.16    -0.01     0.24  1207    1
c[5,4]         0.70    0.01 0.21     0.27     0.56     0.70     0.84     1.10  1203    1
c[5,5]         1.38    0.01 0.22     0.95     1.24     1.37     1.53     1.79  1174    1
c[6,1]        -1.16    0.01 0.22    -1.59    -1.31    -1.16    -1.01    -0.74  1122    1
c[6,2]        -0.25    0.01 0.21    -0.65    -0.39    -0.25    -0.10     0.16  1093    1
c[6,3]         0.21    0.01 0.21    -0.20     0.07     0.21     0.35     0.61  1111    1
c[6,4]         0.98    0.01 0.21     0.57     0.84     0.98     1.12     1.40  1130    1
c[6,5]         1.66    0.01 0.21     1.25     1.52     1.66     1.80     2.08  1104    1
c[7,1]        -1.80    0.01 0.25    -2.30    -1.96    -1.80    -1.63    -1.30  1272    1
c[7,2]        -0.92    0.01 0.23    -1.37    -1.06    -0.92    -0.76    -0.46  1223    1
c[7,3]        -0.18    0.01 0.23    -0.63    -0.33    -0.18    -0.03     0.27  1205    1
c[7,4]         0.65    0.01 0.23     0.21     0.50     0.65     0.80     1.10  1208    1
c[7,5]         1.29    0.01 0.23     0.84     1.13     1.29     1.44     1.73  1244    1
sigma          0.82    0.00 0.13     0.59     0.72     0.81     0.90     1.09  1727    1
lp__       -7509.21    0.18 6.88 -7523.84 -7513.65 -7508.83 -7504.30 -7497.02  1400    1


some suggestions?

I guess maybe some ways to estimate the covariance matrix, but who can tell me how to do it. I donâ€™t find the way in the forum and guidebook

Do you intend to be using the multivariate normal distribution? All I see you using is normal

yes, but how to inference the covariance matrix is a problem for me.
If I use multi_normal distribution directly, I will get NAN in covariance parameters.
I change parameter sigmacov to  cov_matrix, My code is :

data{

int<lower=1> K; //6 rating categories
int<lower=1> N;  //sample size
int<lower=1> D;  //7 forecast variable
int<lower=0> T;
int T_year[8];  // year data
int<lower=1,upper=K> y[N];
row_vector[D] x[N];
vector<lower=0>[D] a;

}

parameters {
vector[D] beta1[T];
ordered[K-1]  c[T];
real<lower=0> sigma;
//vector<lower=0>[D] sigmacov;

cov_matrix[D] sigmacov;
}
transformed parameters{

}
model {

vector[K] theta[T];
// diagonal elements

beta1[1]~ normal(a, sigma);
for (i in 2:T){
beta1[i] ~ multi_normal(beta1[i-1], sigmacov);
}
for (t in 1:T){

for( n in (T_year[t]+1):T_year[t+1]){
real eta;
eta = x[n] * beta1[t];
theta[t,1] = 1 - Phi(eta - c[t,1]);
for (k in 2:(K-1)){
theta[t,k] = Phi(eta - c[t,k-1]) - Phi(eta - c[t,k]);
}
theta[t,K] = Phi(eta - c[t,K-1]);
y[n] ~ categorical(theta[t]);
}
}

}


And I got the result that:


mean       se_mean            sd           2.5%            25%            50%            75%
sigmacov[1,1]  8.599404e+307           NaN           Inf  8.456274e+306  5.092700e+307  7.252107e+307  1.295603e+308
sigmacov[1,2]  7.292332e+154           NaN           Inf -1.446666e+155 -1.667751e+154  5.117183e+154  1.735171e+155
sigmacov[1,3] -6.253577e+155           NaN           Inf -5.086512e+156 -5.142450e+155 -4.351242e+154  7.709921e+154
sigmacov[1,4] -2.177095e+155           NaN           Inf -1.541378e+156 -1.848415e+155 -1.123021e+155 -1.139589e+154
sigmacov[1,5]  1.405440e+155           NaN           Inf -2.247059e+155 -2.789982e+154  1.159817e+155  2.851742e+155
sigmacov[1,6] -2.352359e+155           NaN           Inf -1.269629e+156 -3.212776e+155 -1.224518e+155  1.297582e+154
sigmacov[1,7] -1.776183e+155           NaN           Inf -1.489758e+156 -1.770616e+155  4.741941e+153  3.521461e+154
sigmacov[2,1]  7.292332e+154           NaN           Inf -1.446666e+155 -1.667751e+154  5.117183e+154  1.735171e+155
sigmacov[2,2]  6.087153e+307           NaN           Inf  1.552004e+305  1.243700e+307  4.604856e+307  1.012186e+308
sigmacov[2,3] -2.502571e+155           NaN           Inf -1.656378e+156 -3.147204e+155 -1.076269e+155 -3.264780e+154
sigmacov[2,4] -2.309620e+155           NaN           Inf -1.701163e+156 -2.944258e+155 -9.469117e+154 -2.254942e+154
sigmacov[2,5]  1.169890e+155           NaN           Inf -1.525472e+155  4.852729e+153  2.771053e+154  9.431730e+154
sigmacov[2,6] -1.512198e+155           NaN           Inf -1.686724e+156 -1.410367e+155  8.463578e+153  4.654402e+154
sigmacov[2,7] -1.253382e+155           NaN           Inf -2.264449e+156 -1.851601e+154  6.975868e+154  1.775089e+155
sigmacov[3,1] -6.253577e+155           NaN           Inf -5.086512e+156 -5.142450e+155 -4.351242e+154  7.709921e+154


So, this is the problem.

Perhaps you should put a prior on sigmacov? Maybe use a Cholesky decomposition and then use multivariate_normal_cholesky.

I guess you want me to use it this way?

data{

int<lower=1> K; //6 rating categories
int<lower=1> N;  //sample size
int<lower=1> D;  //7 forecast variable
int<lower=0> T;
int T_year[8];  // year data
int<lower=1,upper=K> y[N];
row_vector[D] x[N];
vector<lower=0>[D] a;

}

parameters {
vector[D] beta1[T];
ordered[K-1]  c[T];
real<lower=0> sigma;
//vector<lower=0>[D] sigmacov;
cholesky_factor_corr[D] L_Omega;
vector<lower=0>[D] L_sigma;
}

model {
matrix[D, D] L_Sigma;

vector[K] theta[T];
// diagonal elements
L_Omega ~ lkj_corr_cholesky(4);
L_sigma ~ cauchy(0, 2.5);
L_Sigma = diag_pre_multiply(L_sigma, L_Omega);

beta1[1]~ normal(a, sigma);
for (i in 2:T){
beta1[i] ~ multi_normal_cholesky(beta1[i-1], L_Sigma);
}
for (t in 1:T){

for( n in (T_year[t]+1):T_year[t+1]){
real eta;
eta = x[n] * beta1[t];
theta[t,1] = 1 - Phi(eta - c[t,1]);
for (k in 2:(K-1)){
theta[t,k] = Phi(eta - c[t,k-1]) - Phi(eta - c[t,k]);
}
theta[t,K] = Phi(eta - c[t,K-1]);
y[n] ~ categorical(theta[t]);
}
}

}


the code can run but I got :

SAMPLING FOR MODEL 'bond_rating' NOW (CHAIN 4).
Chain 4: Rejecting initial value:
Chain 4:   Log probability evaluates to log(0), i.e. negative infinity.
Chain 4:   Stan can't start sampling from this initial value.
Chain 4:
Chain 4: Gradient evaluation took 0.019 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 190 seconds.


some problem in my parameters or prior?
Thanks~

Add some print statements through your code to discern what is causing the target to evaluate to log(0)

Hello~This is the result:

Warning messages:
1: There were 125 divergent transitions after warmup. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
2: Examine the pairs() plot to diagnose sampling problems

3: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
http://mc-stan.org/misc/warnings.html#tail-ess
> print(fit)
Inference for Stan model: bond_rating.
4 chains, each with iter=2000; warmup=1000; thin=1;
post-warmup draws per chain=1000, total post-warmup draws=4000.

mean se_mean    sd     2.5%      25%      50%      75%    97.5% n_eff Rhat
beta1[1,1]      -0.90    0.01  0.34    -1.57    -1.11    -0.91    -0.70    -0.18  1549 1.00
beta1[1,2]       0.16    0.00  0.09    -0.01     0.09     0.15     0.22     0.35  1470 1.00
beta1[1,3]       5.70    0.02  0.80     4.20     5.18     5.67     6.20     7.40  1209 1.00
beta1[1,4]      -0.03    0.02  0.43    -0.87    -0.33     0.00     0.28     0.77   699 1.00
beta1[1,5]       1.80    0.01  0.35     1.20     1.55     1.77     2.02     2.56  1663 1.00
beta1[1,6]       0.00    0.01  0.22    -0.39    -0.14    -0.01     0.14     0.44   637 1.00
beta1[1,7]       0.22    0.02  0.40    -0.59    -0.03     0.25     0.49     0.96   460 1.01
beta1[2,1]      -1.04    0.01  0.31    -1.70    -1.22    -1.02    -0.85    -0.44  1271 1.00
beta1[2,2]       0.11    0.00  0.07    -0.02     0.06     0.11     0.16     0.26  2154 1.00
beta1[2,3]       5.39    0.01  0.65     4.11     4.95     5.39     5.82     6.72  2775 1.00
beta1[2,4]       0.06    0.02  0.39    -0.71    -0.20     0.07     0.34     0.80   573 1.01
beta1[2,5]       1.32    0.01  0.30     0.69     1.14     1.34     1.52     1.85  1915 1.00
beta1[2,6]      -0.01    0.01  0.20    -0.38    -0.14    -0.02     0.13     0.39   563 1.01
beta1[2,7]       0.23    0.02  0.37    -0.53    -0.02     0.25     0.48     0.92   430 1.01
beta1[3,1]      -0.92    0.01  0.28    -1.47    -1.11    -0.93    -0.75    -0.34  2065 1.00
beta1[3,2]       0.04    0.00  0.07    -0.11     0.00     0.04     0.08     0.17  2429 1.00
beta1[3,3]       4.67    0.01  0.66     3.50     4.20     4.64     5.10     6.03  2850 1.00
beta1[3,4]       0.15    0.02  0.37    -0.59    -0.09     0.15     0.39     0.85   578 1.01
beta1[3,5]       1.10    0.01  0.36     0.33     0.86     1.12     1.37     1.74  1100 1.00
beta1[3,6]       0.01    0.01  0.19    -0.35    -0.13     0.00     0.14     0.38   519 1.01
beta1[3,7]       0.30    0.02  0.36    -0.41     0.06     0.32     0.55     0.98   418 1.01
beta1[4,1]      -0.90    0.01  0.28    -1.45    -1.07    -0.90    -0.73    -0.34  2409 1.00
beta1[4,2]      -0.02    0.00  0.07    -0.18    -0.07    -0.02     0.03     0.11  1231 1.00
beta1[4,3]       3.88    0.02  0.59     2.68     3.49     3.89     4.26     5.01  1394 1.00
beta1[4,4]       0.17    0.01  0.36    -0.58    -0.06     0.18     0.40     0.86   633 1.01
beta1[4,5]       1.58    0.01  0.29     1.02     1.38     1.57     1.75     2.20  2727 1.00
beta1[4,6]      -0.05    0.01  0.18    -0.39    -0.18    -0.06     0.06     0.31   490 1.01
beta1[4,7]       0.29    0.02  0.35    -0.42     0.06     0.29     0.53     0.94   426 1.01
beta1[5,1]      -0.81    0.01  0.30    -1.34    -1.01    -0.84    -0.63    -0.12  1549 1.00
beta1[5,2]       0.01    0.00  0.06    -0.11    -0.02     0.02     0.06     0.12  2211 1.00
beta1[5,3]       2.90    0.01  0.42     2.10     2.61     2.91     3.18     3.68  1683 1.00
beta1[5,4]       0.40    0.01  0.35    -0.26     0.16     0.37     0.64     1.12   628 1.00
beta1[5,5]       1.67    0.01  0.30     1.12     1.47     1.65     1.85     2.33  2330 1.00
beta1[5,6]      -0.17    0.01  0.18    -0.53    -0.29    -0.17    -0.05     0.20   503 1.01
beta1[5,7]       0.26    0.02  0.35    -0.46     0.03     0.28     0.50     0.92   428 1.01
beta1[6,1]      -0.80    0.01  0.33    -1.37    -1.03    -0.84    -0.61    -0.03  1169 1.00
beta1[6,2]       0.08    0.00  0.06    -0.04     0.03     0.08     0.12     0.22  1429 1.00
beta1[6,3]       2.22    0.02  0.44     1.44     1.91     2.19     2.50     3.15   832 1.00
beta1[6,4]       0.73    0.02  0.41     0.01     0.42     0.71     1.00     1.61   503 1.01
beta1[6,5]       1.68    0.01  0.27     1.17     1.51     1.67     1.85     2.27  2121 1.00
beta1[6,6]      -0.22    0.01  0.19    -0.60    -0.34    -0.22    -0.09     0.15   635 1.01
beta1[6,7]       0.30    0.02  0.37    -0.44     0.07     0.31     0.54     0.99   487 1.01
beta1[7,1]      -1.21    0.01  0.38    -2.03    -1.44    -1.17    -0.94    -0.58   939 1.00
beta1[7,2]       0.10    0.00  0.08    -0.04     0.04     0.09     0.14     0.26  1779 1.00
beta1[7,3]       3.35    0.02  0.65     2.16     2.90     3.33     3.77     4.69  1088 1.00
beta1[7,4]       0.50    0.01  0.38    -0.23     0.25     0.49     0.75     1.30   703 1.00
beta1[7,5]       1.68    0.01  0.29     1.13     1.48     1.67     1.87     2.30  2991 1.00
beta1[7,6]       0.05    0.01  0.21    -0.32    -0.09     0.04     0.19     0.51   624 1.00
beta1[7,7]       0.30    0.02  0.38    -0.51     0.06     0.32     0.55     0.98   494 1.01
c[1,1]          -2.49    0.01  0.31    -3.12    -2.69    -2.48    -2.28    -1.90  1066 1.00
c[1,2]          -1.06    0.01  0.22    -1.49    -1.21    -1.05    -0.91    -0.64   966 1.00
c[1,3]          -0.26    0.01  0.21    -0.70    -0.40    -0.25    -0.11     0.14   919 1.00
c[1,4]           0.90    0.01  0.21     0.47     0.75     0.90     1.04     1.31   966 1.00
c[1,5]           1.47    0.01  0.22     1.04     1.33     1.48     1.63     1.90   960 1.00
c[2,1]          -2.46    0.01  0.26    -2.99    -2.63    -2.46    -2.28    -1.97  1003 1.00
c[2,2]          -1.40    0.01  0.19    -1.79    -1.53    -1.40    -1.27    -1.03   837 1.01
c[2,3]          -0.59    0.01  0.19    -0.96    -0.72    -0.58    -0.46    -0.24   729 1.01
c[2,4]           0.74    0.01  0.19     0.35     0.61     0.74     0.86     1.09   726 1.01
c[2,5]           1.35    0.01  0.19     0.96     1.22     1.35     1.48     1.71   699 1.01
c[3,1]          -2.18    0.01  0.22    -2.63    -2.33    -2.18    -2.03    -1.75  1013 1.01
c[3,2]          -1.09    0.01  0.18    -1.44    -1.21    -1.09    -0.98    -0.74   695 1.01
c[3,3]          -0.48    0.01  0.17    -0.83    -0.59    -0.48    -0.36    -0.14   644 1.01
c[3,4]           0.76    0.01  0.17     0.42     0.64     0.76     0.87     1.09   607 1.01
c[3,5]           1.37    0.01  0.18     1.03     1.25     1.37     1.49     1.71   645 1.01
c[4,1]          -1.93    0.01  0.20    -2.34    -2.06    -1.93    -1.80    -1.54   943 1.00
c[4,2]          -1.02    0.01  0.18    -1.38    -1.14    -1.02    -0.90    -0.68   807 1.00
c[4,3]          -0.56    0.01  0.17    -0.92    -0.68    -0.56    -0.44    -0.23   792 1.00
c[4,4]           0.59    0.01  0.17     0.24     0.47     0.59     0.71     0.90   801 1.00
c[4,5]           1.26    0.01  0.17     0.91     1.15     1.27     1.38     1.59   787 1.00
c[5,1]          -1.53    0.01  0.18    -1.88    -1.65    -1.54    -1.41    -1.19   910 1.00
c[5,2]          -0.63    0.01  0.17    -0.96    -0.75    -0.64    -0.52    -0.29   815 1.00
c[5,3]          -0.17    0.01  0.17    -0.48    -0.28    -0.17    -0.06     0.17   797 1.00
c[5,4]           0.69    0.01  0.17     0.36     0.58     0.68     0.80     1.03   844 1.00
c[5,5]           1.37    0.01  0.17     1.04     1.25     1.36     1.48     1.71   843 1.00
c[6,1]          -1.31    0.01  0.20    -1.67    -1.45    -1.32    -1.18    -0.91   703 1.01
c[6,2]          -0.40    0.01  0.19    -0.73    -0.53    -0.40    -0.27     0.00   646 1.00
c[6,3]           0.05    0.01  0.19    -0.28    -0.09     0.05     0.18     0.44   647 1.00
c[6,4]           0.82    0.01  0.19     0.49     0.69     0.82     0.95     1.22   677 1.00
c[6,5]           1.50    0.01  0.19     1.15     1.37     1.50     1.63     1.90   672 1.00
c[7,1]          -1.82    0.01  0.21    -2.21    -1.95    -1.82    -1.67    -1.40   676 1.01
c[7,2]          -0.94    0.01  0.18    -1.33    -1.06    -0.94    -0.82    -0.58   605 1.01
c[7,3]          -0.21    0.01  0.18    -0.59    -0.32    -0.21    -0.09     0.16   619 1.01
c[7,4]           0.62    0.01  0.18     0.27     0.50     0.62     0.74     0.99   629 1.01
c[7,5]           1.25    0.01  0.19     0.90     1.13     1.25     1.38     1.63   633 1.01
sigma            2.87    0.02  1.09     1.48     2.13     2.63     3.34     5.63  2357 1.00
L_Omega[1,1]     1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
L_Omega[1,2]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,3]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,4]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,1]    -0.03    0.01  0.27    -0.55    -0.22    -0.03     0.16     0.48  2705 1.00
L_Omega[2,2]     0.96    0.00  0.05     0.82     0.95     0.98     1.00     1.00  1986 1.00
L_Omega[2,3]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,4]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,1]    -0.07    0.01  0.26    -0.58    -0.26    -0.07     0.11     0.44  1992 1.00
L_Omega[3,2]     0.03    0.01  0.26    -0.46    -0.15     0.04     0.22     0.50  2062 1.00
L_Omega[3,3]     0.92    0.00  0.07     0.72     0.89     0.94     0.98     1.00   910 1.01
L_Omega[3,4]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[4,1]     0.02    0.00  0.27    -0.51    -0.17     0.02     0.21     0.52  3301 1.00
L_Omega[4,2]     0.01    0.00  0.26    -0.50    -0.17     0.02     0.20     0.50  3277 1.00
L_Omega[4,3]    -0.09    0.00  0.26    -0.58    -0.28    -0.09     0.08     0.40  2758 1.00
L_Omega[4,4]     0.88    0.00  0.09     0.67     0.84     0.90     0.95     0.99  1719 1.00
L_Omega[4,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[4,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[4,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[5,1]     0.01    0.01  0.28    -0.56    -0.19     0.01     0.20     0.56  1398 1.00
L_Omega[5,2]     0.02    0.00  0.26    -0.49    -0.17     0.02     0.20     0.54  3261 1.00
L_Omega[5,3]    -0.02    0.01  0.26    -0.53    -0.21    -0.03     0.16     0.47  1784 1.00
L_Omega[5,4]    -0.01    0.01  0.27    -0.53    -0.20    -0.01     0.18     0.50  1734 1.00
L_Omega[5,5]     0.84    0.00  0.10     0.59     0.77     0.86     0.92     0.98  1257 1.00
L_Omega[5,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[5,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[6,1]    -0.08    0.01  0.27    -0.61    -0.26    -0.08     0.11     0.42  1630 1.00
L_Omega[6,2]     0.00    0.01  0.26    -0.50    -0.18     0.00     0.18     0.51  2576 1.00
L_Omega[6,3]     0.12    0.00  0.25    -0.38    -0.04     0.13     0.29     0.57  4382 1.00
L_Omega[6,4]    -0.09    0.01  0.27    -0.59    -0.28    -0.09     0.09     0.44  2419 1.00
L_Omega[6,5]    -0.03    0.00  0.26    -0.51    -0.22    -0.04     0.16     0.48  3214 1.00
L_Omega[6,6]     0.79    0.00  0.12     0.52     0.72     0.80     0.87     0.96  1082 1.01
L_Omega[6,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[7,1]    -0.01    0.00  0.28    -0.54    -0.20    -0.01     0.18     0.53  3297 1.00
L_Omega[7,2]     0.00    0.00  0.27    -0.53    -0.19     0.00     0.19     0.51  3070 1.00
L_Omega[7,3]     0.01    0.01  0.27    -0.50    -0.18     0.01     0.20     0.52  2510 1.00
L_Omega[7,4]    -0.03    0.01  0.28    -0.55    -0.23    -0.04     0.17     0.51  1674 1.00
L_Omega[7,5]    -0.01    0.01  0.26    -0.52    -0.20     0.00     0.17     0.48  2659 1.00
L_Omega[7,6]    -0.06    0.01  0.27    -0.57    -0.27    -0.07     0.13     0.48  2388 1.00
L_Omega[7,7]     0.73    0.00  0.12     0.45     0.66     0.75     0.83     0.93  1660 1.00
L_sigma[1]       0.42    0.02  0.37     0.03     0.15     0.32     0.58     1.33   562 1.00
L_sigma[2]       0.12    0.00  0.08     0.01     0.06     0.10     0.15     0.33  1052 1.00
L_sigma[3]       1.32    0.02  0.57     0.55     0.92     1.21     1.58     2.71  1376 1.00
L_sigma[4]       0.41    0.01  0.29     0.04     0.21     0.35     0.55     1.10   813 1.00
L_sigma[5]       0.55    0.01  0.39     0.05     0.27     0.48     0.73     1.48   993 1.00
L_sigma[6]       0.22    0.00  0.15     0.02     0.12     0.18     0.28     0.59  1023 1.00
L_sigma[7]       0.21    0.01  0.18     0.02     0.08     0.16     0.28     0.66   919 1.00
lp__         -7477.33    0.57 11.55 -7499.05 -7485.01 -7477.54 -7469.74 -7453.63   405 1.01


Thanks~

No, I meant print statements and n the Stan model code itself

Sorry, I print the statement in my code, maybe these can help:

data{

int<lower=1> K; //6 rating categories
int<lower=1> N;  //sample size
int<lower=1> D;  //7 forecast variable
int<lower=0> T;   //7 year
int T_year[8];  // year data
int<lower=1,upper=K> y[N];  //regression dependent variable
row_vector[D] x[N];   //regressors
vector<lower=0>[D] a;  // a vector of 0

}

parameters {
vector[D] beta1[T];  //different year regressor parameters
ordered[K-1]  c[T];  //different year cutoff
real<lower=0> sigma; //the beta1[1] standard deviation
cholesky_factor_corr[D] L_Omega;
vector<lower=0>[D] L_sigma;
}
transformed parameters{
vector[D] s=[1,1,1,1,1,1,1]';
}
model {
matrix[D, D] L_Sigma;
vector[K] theta[T];

L_Omega ~ lkj_corr_cholesky(4);
L_sigma ~ cauchy(0, 2.5);
L_Sigma = diag_pre_multiply(L_sigma, L_Omega);

beta1[1]~ multi_normal(a, sigma*diag_matrix(s));//beta1[1] obey normal(0,sigma*I_{D*D}) distribution

for (i in 2:T){
beta1[i] ~ multi_normal_cholesky(beta1[i-1], L_Sigma); //beta1[i] obey normal(beta1[i-1], cov) distribution
}

//orderd probit regression model
for (t in 1:T){

for( n in (T_year[t]+1):T_year[t+1]){
real eta;
eta = x[n] * beta1[t];
theta[t,1] = 1 - Phi(eta - c[t,1]);
for (k in 2:(K-1)){
theta[t,k] = Phi(eta - c[t,k-1]) - Phi(eta - c[t,k]);
}
theta[t,K] = Phi(eta - c[t,K-1]);
y[n] ~ categorical(theta[t]);
}
}

}


I revise some places, now I havenâ€™t log(0) in my code. But my results still have NaN!
the results are:

mean se_mean    sd     2.5%      25%      50%      75%    97.5% n_eff Rhat
beta1[1,1]      -0.90    0.01  0.35    -1.58    -1.11    -0.91    -0.69    -0.16  1682 1.00
beta1[1,2]       0.15    0.00  0.09     0.00     0.08     0.15     0.21     0.35   998 1.00
beta1[1,3]       5.81    0.02  0.81     4.26     5.26     5.80     6.35     7.43  1336 1.00
beta1[1,4]      -0.01    0.02  0.44    -0.89    -0.31     0.00     0.29     0.81   608 1.00
beta1[1,5]       1.79    0.01  0.35     1.21     1.54     1.75     2.01     2.54  1670 1.00
beta1[1,6]      -0.02    0.01  0.22    -0.48    -0.16    -0.03     0.12     0.42   375 1.00
beta1[1,7]       0.26    0.02  0.41    -0.58     0.00     0.27     0.54     1.03   338 1.01
beta1[2,1]      -1.06    0.02  0.34    -1.80    -1.24    -1.03    -0.84    -0.47   444 1.01
beta1[2,2]       0.11    0.00  0.07    -0.02     0.06     0.11     0.16     0.27  1400 1.00
beta1[2,3]       5.43    0.01  0.66     4.17     4.99     5.43     5.87     6.74  2232 1.00
beta1[2,4]       0.06    0.02  0.40    -0.77    -0.21     0.07     0.34     0.81   389 1.01
beta1[2,5]       1.33    0.01  0.29     0.69     1.15     1.34     1.53     1.85  1548 1.00
beta1[2,6]      -0.03    0.01  0.20    -0.40    -0.16    -0.03     0.10     0.36   423 1.00
beta1[2,7]       0.27    0.02  0.38    -0.50     0.01     0.26     0.52     0.99   318 1.00
beta1[3,1]      -0.92    0.01  0.28    -1.45    -1.09    -0.92    -0.74    -0.33  1720 1.00
beta1[3,2]       0.04    0.00  0.07    -0.10     0.00     0.04     0.08     0.16  2614 1.00
beta1[3,3]       4.72    0.01  0.65     3.47     4.27     4.73     5.13     6.08  2670 1.00
beta1[3,4]       0.15    0.02  0.38    -0.63    -0.11     0.16     0.41     0.84   399 1.01
beta1[3,5]       1.14    0.01  0.36     0.37     0.90     1.17     1.42     1.72   713 1.01
beta1[3,6]      -0.01    0.01  0.19    -0.42    -0.14    -0.02     0.12     0.37   375 1.00
beta1[3,7]       0.33    0.02  0.37    -0.38     0.09     0.32     0.57     1.07   321 1.01
beta1[4,1]      -0.90    0.01  0.29    -1.45    -1.08    -0.91    -0.72    -0.26   909 1.01
beta1[4,2]      -0.02    0.00  0.07    -0.18    -0.07    -0.01     0.03     0.10  1125 1.01
beta1[4,3]       3.90    0.01  0.59     2.76     3.50     3.90     4.29     5.09  2646 1.00
beta1[4,4]       0.16    0.02  0.37    -0.57    -0.07     0.18     0.42     0.83   423 1.00
beta1[4,5]       1.58    0.01  0.29     1.04     1.39     1.56     1.74     2.19  2354 1.00
beta1[4,6]      -0.07    0.01  0.18    -0.43    -0.19    -0.06     0.06     0.29   374 1.00
beta1[4,7]       0.31    0.02  0.36    -0.38     0.06     0.30     0.55     1.00   304 1.00
beta1[5,1]      -0.80    0.01  0.31    -1.35    -1.01    -0.84    -0.63    -0.12   872 1.01
beta1[5,2]       0.01    0.00  0.06    -0.11    -0.03     0.02     0.06     0.12  2100 1.00
beta1[5,3]       2.90    0.01  0.42     2.08     2.61     2.91     3.19     3.65  1286 1.00
beta1[5,4]       0.39    0.02  0.36    -0.33     0.15     0.38     0.63     1.07   461 1.00
beta1[5,5]       1.66    0.01  0.29     1.12     1.48     1.64     1.83     2.27  2108 1.00
beta1[5,6]      -0.18    0.01  0.18    -0.54    -0.30    -0.17    -0.05     0.16   411 1.01
beta1[5,7]       0.28    0.02  0.36    -0.41     0.04     0.27     0.53     0.99   325 1.00
beta1[6,1]      -0.78    0.02  0.35    -1.35    -1.01    -0.83    -0.60     0.10   446 1.01
beta1[6,2]       0.08    0.00  0.06    -0.04     0.04     0.08     0.12     0.20  1491 1.00
beta1[6,3]       2.20    0.02  0.44     1.38     1.89     2.20     2.52     3.06   860 1.00
beta1[6,4]       0.71    0.02  0.41    -0.04     0.42     0.70     0.97     1.56   503 1.00
beta1[6,5]       1.68    0.01  0.28     1.15     1.49     1.66     1.85     2.23  1530 1.00
beta1[6,6]      -0.23    0.01  0.20    -0.62    -0.36    -0.22    -0.09     0.13   417 1.00
beta1[6,7]       0.32    0.02  0.38    -0.42     0.06     0.30     0.57     1.07   366 1.00
beta1[7,1]      -1.22    0.02  0.39    -2.16    -1.45    -1.16    -0.94    -0.60   485 1.00
beta1[7,2]       0.10    0.00  0.08    -0.04     0.04     0.09     0.15     0.27  1070 1.00
beta1[7,3]       3.38    0.02  0.64     2.18     2.95     3.37     3.81     4.63  1800 1.00
beta1[7,4]       0.50    0.02  0.38    -0.25     0.23     0.51     0.75     1.24   546 1.00
beta1[7,5]       1.67    0.01  0.29     1.12     1.47     1.65     1.85     2.25  2154 1.00
beta1[7,6]       0.03    0.01  0.21    -0.39    -0.11     0.03     0.17     0.46   421 1.00
beta1[7,7]       0.33    0.02  0.38    -0.42     0.08     0.33     0.58     1.07   373 1.00
c[1,1]          -2.48    0.01  0.31    -3.11    -2.69    -2.48    -2.26    -1.91  1028 1.00
c[1,2]          -1.05    0.01  0.22    -1.49    -1.21    -1.05    -0.90    -0.64   678 1.00
c[1,3]          -0.26    0.01  0.21    -0.69    -0.40    -0.26    -0.11     0.15   716 1.00
c[1,4]           0.90    0.01  0.22     0.47     0.76     0.91     1.06     1.31   772 1.00
c[1,5]           1.48    0.01  0.22     1.04     1.33     1.49     1.63     1.90   825 1.00
c[2,1]          -2.46    0.01  0.26    -2.99    -2.63    -2.45    -2.28    -1.98   875 1.00
c[2,2]          -1.41    0.01  0.20    -1.82    -1.54    -1.40    -1.27    -1.03   393 1.01
c[2,3]          -0.59    0.01  0.19    -1.00    -0.73    -0.59    -0.46    -0.24   443 1.00
c[2,4]           0.73    0.01  0.20     0.31     0.60     0.74     0.87     1.09   395 1.01
c[2,5]           1.34    0.01  0.20     0.91     1.21     1.35     1.48     1.71   402 1.01
c[3,1]          -2.18    0.01  0.24    -2.67    -2.35    -2.17    -2.01    -1.73   464 1.00
c[3,2]          -1.09    0.01  0.19    -1.48    -1.21    -1.09    -0.96    -0.73   461 1.00
c[3,3]          -0.48    0.01  0.18    -0.86    -0.60    -0.47    -0.35    -0.14   455 1.00
c[3,4]           0.76    0.01  0.18     0.39     0.64     0.76     0.89     1.08   475 1.00
c[3,5]           1.38    0.01  0.18     1.01     1.26     1.38     1.50     1.71   489 1.00
c[4,1]          -1.94    0.01  0.21    -2.41    -2.07    -1.93    -1.79    -1.55   504 1.00
c[4,2]          -1.03    0.01  0.18    -1.38    -1.15    -1.02    -0.91    -0.68   484 1.00
c[4,3]          -0.57    0.01  0.18    -0.92    -0.68    -0.57    -0.45    -0.23   497 1.00
c[4,4]           0.58    0.01  0.18     0.23     0.47     0.59     0.70     0.91   507 1.00
c[4,5]           1.26    0.01  0.18     0.90     1.14     1.27     1.39     1.59   507 1.00
c[5,1]          -1.53    0.01  0.18    -1.89    -1.65    -1.54    -1.41    -1.18   715 1.00
c[5,2]          -0.64    0.01  0.17    -0.97    -0.74    -0.64    -0.52    -0.31   623 1.00
c[5,3]          -0.17    0.01  0.17    -0.50    -0.28    -0.17    -0.05     0.15   613 1.00
c[5,4]           0.69    0.01  0.17     0.35     0.58     0.68     0.81     1.01   641 1.00
c[5,5]           1.36    0.01  0.17     1.02     1.25     1.37     1.48     1.69   620 1.00
c[6,1]          -1.31    0.01  0.20    -1.67    -1.45    -1.32    -1.18    -0.90   587 1.00
c[6,2]          -0.40    0.01  0.19    -0.74    -0.53    -0.41    -0.27     0.00   523 1.00
c[6,3]           0.05    0.01  0.19    -0.30    -0.09     0.04     0.18     0.44   508 1.00
c[6,4]           0.82    0.01  0.19     0.48     0.68     0.81     0.95     1.22   553 1.00
c[6,5]           1.50    0.01  0.20     1.15     1.36     1.49     1.63     1.91   585 1.00
c[7,1]          -1.82    0.01  0.21    -2.25    -1.96    -1.81    -1.68    -1.42   706 1.00
c[7,2]          -0.95    0.01  0.19    -1.36    -1.07    -0.94    -0.82    -0.59   532 1.00
c[7,3]          -0.21    0.01  0.19    -0.63    -0.33    -0.20    -0.09     0.14   493 1.00
c[7,4]           0.62    0.01  0.19     0.20     0.49     0.62     0.74     0.97   502 1.00
c[7,5]           1.25    0.01  0.19     0.84     1.13     1.26     1.37     1.60   546 1.00
sigma           12.99    0.39 16.05     2.64     5.75     8.81    14.37    47.41  1683 1.00
L_Omega[1,1]     1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
L_Omega[1,2]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,3]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,4]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[1,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,1]    -0.02    0.00  0.27    -0.51    -0.22    -0.03     0.16     0.50  3569 1.00
L_Omega[2,2]     0.96    0.00  0.05     0.83     0.95     0.98     1.00     1.00  1874 1.00
L_Omega[2,3]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,4]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[2,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,1]    -0.08    0.00  0.26    -0.56    -0.26    -0.09     0.10     0.44  2971 1.00
L_Omega[3,2]     0.03    0.00  0.25    -0.45    -0.14     0.03     0.21     0.51  3555 1.00
L_Omega[3,3]     0.93    0.00  0.07     0.74     0.90     0.95     0.98     1.00  1718 1.00
L_Omega[3,4]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[3,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[4,1]     0.03    0.00  0.26    -0.48    -0.14     0.03     0.22     0.54  3845 1.00
L_Omega[4,2]     0.01    0.01  0.27    -0.55    -0.18     0.02     0.21     0.52  1133 1.00
L_Omega[4,3]    -0.09    0.00  0.26    -0.59    -0.27    -0.09     0.09     0.43  2744 1.00
L_Omega[4,4]     0.88    0.00  0.09     0.66     0.83     0.90     0.95     0.99  1708 1.00
L_Omega[4,5]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[4,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[4,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[5,1]     0.01    0.00  0.27    -0.50    -0.18     0.02     0.20     0.52  3280 1.00
L_Omega[5,2]     0.03    0.00  0.26    -0.48    -0.16     0.03     0.22     0.53  3256 1.00
L_Omega[5,3]    -0.02    0.00  0.26    -0.51    -0.19    -0.02     0.16     0.47  3062 1.00
L_Omega[5,4]     0.00    0.01  0.27    -0.51    -0.18     0.00     0.19     0.52  1709 1.00
L_Omega[5,5]     0.84    0.00  0.10     0.61     0.79     0.86     0.92     0.98  2007 1.00
L_Omega[5,6]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[5,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[6,1]    -0.08    0.01  0.27    -0.57    -0.28    -0.09     0.10     0.45  1280 1.00
L_Omega[6,2]     0.00    0.00  0.27    -0.50    -0.20    -0.01     0.19     0.52  3491 1.00
L_Omega[6,3]     0.11    0.01  0.25    -0.37    -0.07     0.11     0.29     0.57  2411 1.00
L_Omega[6,4]    -0.08    0.01  0.27    -0.57    -0.27    -0.09     0.11     0.45  1981 1.00
L_Omega[6,5]    -0.02    0.01  0.26    -0.55    -0.21    -0.02     0.16     0.48  2029 1.00
L_Omega[6,6]     0.79    0.00  0.11     0.54     0.71     0.80     0.87     0.96  1518 1.00
L_Omega[6,7]     0.00     NaN  0.00     0.00     0.00     0.00     0.00     0.00   NaN  NaN
L_Omega[7,1]    -0.02    0.00  0.27    -0.52    -0.21    -0.02     0.17     0.49  3065 1.00
L_Omega[7,2]     0.00    0.00  0.26    -0.50    -0.19     0.00     0.19     0.50  2993 1.00
L_Omega[7,3]     0.02    0.01  0.28    -0.50    -0.17     0.01     0.20     0.59   986 1.00
L_Omega[7,4]    -0.04    0.01  0.27    -0.56    -0.25    -0.05     0.16     0.48  1756 1.00
L_Omega[7,5]    -0.02    0.01  0.27    -0.55    -0.21    -0.03     0.17     0.49  1632 1.00
L_Omega[7,6]    -0.05    0.01  0.27    -0.57    -0.24    -0.05     0.14     0.47  2120 1.00
L_Omega[7,7]     0.74    0.00  0.13     0.46     0.65     0.75     0.83     0.94  1647 1.00
L_sigma[1]       0.42    0.02  0.36     0.02     0.15     0.33     0.58     1.31   406 1.01
L_sigma[2]       0.12    0.00  0.08     0.01     0.06     0.10     0.15     0.32   712 1.00
L_sigma[3]       1.33    0.01  0.56     0.58     0.95     1.22     1.60     2.73  1594 1.00
L_sigma[4]       0.41    0.01  0.27     0.05     0.21     0.36     0.53     1.10   917 1.00
L_sigma[5]       0.52    0.01  0.39     0.03     0.24     0.45     0.72     1.48   679 1.01
L_sigma[6]       0.21    0.01  0.15     0.02     0.11     0.18     0.27     0.57   831 1.00
L_sigma[7]       0.19    0.01  0.17     0.02     0.08     0.15     0.26     0.63   802 1.00
s[1]             1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
s[2]             1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
s[3]             1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
s[4]             1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
s[5]             1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
s[6]             1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
s[7]             1.00     NaN  0.00     1.00     1.00     1.00     1.00     1.00   NaN  NaN
lp__         -7475.27    0.54 11.09 -7497.19 -7482.57 -7475.41 -7467.70 -7453.68   419 1.01


And I put my R code and data:

D<-read.csv("data.csv",header = T)
library(dplyr)
D<- arrange(D,D[,2]) #sort by year
Y<-D[,1]
X<-D[,-1:-2]
N<-nrow(D)
y_year=c(594,646,703,697,716,753,822) # The numebers of data in each year
T_year<-cumsum(y_year)
T_year<-c(0,T_year)
a=c(0,0,0,0,0,0,0)
data<-list(y=Y,x=X,N=N,K=6,D=7,T=7,T_year=T_year,a=a)


data.csv (337.2 KB)
Maybe these can provide enough information?
Thanks~

I do not know if it is going to change things, but you can simply write

beta1[1]~ normal(0, sigma);


and it will understand that it is a vector of independent normals

Those NaNs are ok as they appear in the SE column summarizing the posterior and you wouldnâ€™t expect any variability in those elements of a cholesky-factored covariant matrix.

thank you~ it does change, the R_hat becomes large. And there were 2239 divergent transitions after warmup. The results are:


mean  se_mean       sd      2.5%       25%      50%      75%    97.5% n_eff   Rhat
beta1[1,1]       -0.42     0.37     0.59     -1.45     -0.88    -0.46     0.42     0.42     2   2.26
beta1[1,2]       -0.02     0.18     0.26     -0.46     -0.23     0.07     0.13     0.31     2   4.51
beta1[1,3]        4.28     1.86     2.67     -0.25      2.21     5.75     5.98     6.86     2   5.58
beta1[1,4]        0.42     0.37     0.59     -0.71     -0.05     0.49     1.22     1.22     3   2.19
beta1[1,5]        1.58     0.40     0.61      0.61      0.64     1.85     2.02     2.40     2   2.71
beta1[1,6]       -0.38     0.49     0.71     -1.58     -0.93     0.00     0.03     0.37     2   5.29
beta1[1,7]        0.00     0.15     0.33     -0.38     -0.32    -0.05     0.19     0.80     5   1.36
beta1[2,1]       -0.95     0.09     0.24     -1.53     -1.02    -0.97    -0.77    -0.60     7   1.20
beta1[2,2]       -0.42     0.63     0.89     -1.96     -0.58     0.03     0.12     0.26     2  17.89
beta1[2,3]        4.23     1.18     1.72      1.39      2.87     4.73     5.46     6.42     2   4.10
beta1[2,4]        0.57     0.44     0.66     -0.54      0.06     0.51     1.58     1.58     2   2.81
beta1[2,5]        1.20     0.15     0.30      0.78      0.87     1.31     1.32     1.77     4   1.44
beta1[2,6]       -0.39     0.50     0.72     -1.61     -1.01    -0.01     0.04     0.30     2   5.74
beta1[2,7]        0.29     0.24     0.41     -0.36     -0.05     0.15     0.84     0.84     3   1.79
beta1[3,1]       -0.40     0.61     0.88     -1.36     -0.94    -0.80     0.29     1.09     2   5.15
beta1[3,2]       -0.32     0.44     0.62     -1.39     -0.53     0.03     0.04     0.17     2  13.54
beta1[3,3]        3.20     1.77     2.55     -1.13      1.53     4.44     4.66     6.06     2   5.40
beta1[3,4]        0.22     0.13     0.30     -0.38      0.04     0.18     0.52     0.70     5   1.32
beta1[3,5]        0.70     0.56     0.82     -0.65     -0.28     1.11     1.28     1.70     2   3.35
beta1[3,6]        0.41     0.46     0.66     -0.26      0.02     0.05     0.86     1.53     2   5.68
beta1[3,7]        0.54     0.49     0.72     -0.24     -0.03     0.22     1.53     1.71     2   3.49
beta1[4,1]       -0.42     0.57     0.83     -1.54     -0.92    -0.75     0.43     0.96     2   4.06
beta1[4,2]        0.33     0.41     0.58     -0.16     -0.01     0.04     0.46     1.33     2  11.92
beta1[4,3]        2.85     1.50     2.16     -0.80      1.22     3.86     4.34     4.84     2   5.63
beta1[4,4]        0.39     0.14     0.30     -0.40      0.19     0.53     0.62     0.73     5   1.34
beta1[4,5]        0.96     0.78     1.13     -0.96      0.25     1.55     1.62     2.09     2   5.83
beta1[4,6]        0.24     0.30     0.44     -0.32     -0.04     0.05     0.69     0.96     2   3.73
beta1[4,7]        0.06     0.14     0.30     -0.24     -0.22    -0.02     0.24     0.79     5   1.35
beta1[5,1]       -1.04     0.33     0.50     -1.82     -1.82    -0.82    -0.73    -0.29     2   2.60
beta1[5,2]       -0.37     0.49     0.69     -1.57     -0.53     0.02     0.05     0.10     2  19.41
beta1[5,3]        2.35     0.55     0.82      1.02      1.52     2.62     2.87     3.54     2   3.27
beta1[5,4]       -0.05     0.61     0.89     -1.53     -1.02     0.40     0.53     1.00     2   3.95
beta1[5,5]        1.49     0.26     0.41      0.87      0.87     1.68     1.75     2.19     3   2.14
beta1[5,6]       -0.33     0.30     0.44     -1.06     -0.88    -0.15    -0.02     0.18     2   3.67
beta1[5,7]       -0.02     0.23     0.39     -0.56     -0.56     0.06     0.19     0.75     3   1.77
beta1[6,1]       -0.36     0.53     0.80     -1.24     -0.94    -0.80     0.55     0.92     2   3.23
beta1[6,2]       -0.12     0.25     0.35     -0.73     -0.26     0.06     0.09     0.18     2   8.55
beta1[6,3]        1.16     1.04     1.49     -1.32      0.36     1.55     2.24     2.90     2   5.65
beta1[6,4]        0.58     0.20     0.41      0.15      0.17     0.51     0.78     1.47     4   1.40
beta1[6,5]        1.80     0.14     0.27      1.25      1.65     1.77     2.10     2.20     4   1.52
beta1[6,6]       -0.18     0.02     0.14     -0.51     -0.20    -0.18    -0.14     0.18    88   1.05
beta1[6,7]        0.63     0.52     0.77     -0.30      0.15     0.24     1.61     1.89     2   3.20
beta1[7,1]       -0.54     0.82     1.19     -2.06     -1.17    -1.05     0.39     1.45     2   4.36
beta1[7,2]        0.33     0.30     0.43     -0.02      0.06     0.08     0.61     1.07     2   8.99
beta1[7,3]        2.61     0.96     1.42      0.30      0.70     3.26     3.41     4.44     2   3.17
beta1[7,4]        0.04     0.58     0.85     -1.37     -0.87     0.47     0.54     1.14     2   3.64
beta1[7,5]        1.73     0.05     0.21      1.22      1.65     1.78     1.83     2.12    16   1.10
beta1[7,6]        0.13     0.12     0.21     -0.23     -0.02     0.06     0.40     0.41     3   1.58
beta1[7,7]        0.16     0.13     0.31     -0.31     -0.16     0.21     0.27     0.84     6   1.28
c[1,1]           -2.23     0.37     0.56     -2.98     -2.57    -2.49    -1.63    -1.33     2   2.85
c[1,2]           -0.68     0.34     0.50     -1.40     -1.03    -0.80    -0.19     0.13     2   3.61
c[1,3]            0.61     1.00     1.42     -0.61     -0.25    -0.10     1.12     3.05     2  10.52
c[1,4]            1.54     0.71     1.01      0.56      0.93     1.07     2.02     3.27     2   7.47
c[1,5]            3.68     2.60     3.67      1.13      1.50     1.67     4.12    10.07     2  26.47
c[2,1]           -1.92     0.64     0.92     -2.88     -2.48    -2.41    -1.33    -0.35     2   5.72
c[2,2]           -0.89     0.55     0.79     -1.70     -1.36    -1.26    -0.44     0.45     2   6.24
c[2,3]            0.64     1.45     2.05     -0.88     -0.55    -0.49     1.09     4.20     2  17.26
c[2,4]            1.71     1.15     1.63      0.45      0.76     0.82     2.20     4.55     2  13.81
c[2,5]            2.35     1.16     1.65      1.05      1.38     1.46     2.88     5.21     2  13.26
c[3,1]           -1.25     1.32     1.87     -2.61     -2.55    -2.18    -0.61     1.97     2  12.14
c[3,2]            0.02     1.30     1.84     -1.37     -1.08    -0.96     0.41     3.21     2  16.60
c[3,3]            0.55     1.20     1.71     -0.74     -0.46    -0.36     0.96     3.50     2  15.80
c[3,4]            1.94     1.40     1.98      0.50      0.77     0.85     2.35     5.36     2  18.52
c[3,5]            2.99     1.94     2.74      1.10      1.39     1.45     3.41     7.73     2  25.09
c[4,1]           -1.14     0.83     1.18     -2.23     -1.92    -1.64    -0.78     0.89     2   9.57
c[4,2]           -0.43     0.66     0.94     -1.29     -1.02    -0.87    -0.05     1.18     2   8.72
c[4,3]           -0.02     0.57     0.81     -0.83     -0.57    -0.33     0.38     1.36     2   7.53
c[4,4]            0.89     0.30     0.43      0.33      0.59     0.77     1.37     1.59     2   4.03
c[4,5]            1.46     0.19     0.28      1.00      1.26     1.43     1.89     1.89     2   2.60
c[5,1]           -1.14     0.40     0.57     -1.79     -1.50    -1.37    -0.67    -0.18     2   5.01
c[5,2]           -0.40     0.24     0.35     -0.88     -0.65    -0.53     0.05     0.18     2   3.36
c[5,3]            1.10     1.53     2.17     -0.40     -0.17    -0.13     1.49     5.05     2  19.87
c[5,4]            1.87     1.39     1.97      0.45      0.71     0.81     2.23     5.48     2  18.16
c[5,5]            2.45     1.28     1.82      1.12      1.35     1.48     2.91     5.81     2  16.43
c[6,1]           -0.68     0.81     1.16     -1.62     -1.49    -1.28    -0.15     1.30     2   7.66
c[6,2]            0.05     0.57     0.83     -0.67     -0.56    -0.37     0.61     1.44     2   5.53
c[6,3]            1.56     1.89     2.68     -0.22     -0.15     0.08     2.12     6.22     2  18.07
c[6,4]            2.54     2.12     3.01      0.55      0.68     0.85     3.04     7.78     2  20.32
c[6,5]            3.28     2.19     3.10      1.22      1.38     1.53     3.82     8.68     2  20.89
c[7,1]           -1.72     0.15     0.26     -2.16     -1.90    -1.83    -1.36    -1.36     3   1.87
c[7,2]           -0.78     0.23     0.35     -1.19     -1.02    -0.95    -0.23    -0.22     2   2.95
c[7,3]           -0.07     0.20     0.31     -0.46     -0.29    -0.23     0.41     0.41     2   2.66
c[7,4]            0.77     0.21     0.32      0.37      0.55     0.60     1.28     1.29     2   2.81
c[7,5]            1.30     0.08     0.17      1.00      1.20     1.25     1.49     1.55     4   1.40
sigma             3.91     1.67     2.46      1.67      1.90     2.78     7.69     8.10     2   3.55
L_Omega[1,1]      1.00      NaN     0.00      1.00      1.00     1.00     1.00     1.00   NaN    NaN
L_Omega[1,2]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[1,3]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[1,4]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[1,5]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[1,6]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[1,7]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[2,1]     -0.17     0.22     0.35     -0.68     -0.68     0.00     0.08     0.41     3   2.05
L_Omega[2,2]      0.92     0.08     0.11      0.73      0.73     0.99     1.00     1.00     2   3.82
L_Omega[2,3]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[2,4]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[2,5]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[2,6]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[2,7]      0.00      NaN     0.00      0.00      0.00     0.00     0.00     0.00   NaN    NaN
L_Omega[3,1]      0.10     0.25     0.39     -0.48     -0.15    -0.03     0.70     0.70     3   2.17


It doesnâ€™t matter, very thank you~~

OK!
thank you very much~
this really help me.

I think you were looking at a prior version of their model; in later version itâ€™s made clear that each row-vector in beta is intended to be a multivariate normal (and autoregressively such that the i^{th} row is influenced by the (i-1)^{th} row)

Yes, but the first one does not if I read correctly right?

1 Like

Correct đź™‚