Recommendations for what to do when k exceeds 0.5 in the loo package?

T=5, and I=359

First time that I try to do this, not sure if i did it right:

# Extract pointwise log-likelihood and compute LOO
log_lik_1 <- extract_log_lik(fit)
loo_1 <- loo(log_lik_1)
print(loo_1)

# marginal predictive check using LOO probability integral transform
psis <- psislw(-log_lik_1, cores = 32)
ppc_loo_pit(bsdata$y, as.matrix(y_sim), 
            lw = psis$lw_smooth)

image

Could you point me to an explanation for how to read this figure?

Thanks, I added to my reading pile for this weekend :-)

This is my first time trying to fit a negative binomial model with Stan. In my Poisson model the model and generated quantities blocks are:

model {
  sigma_a ~ normal(0, 1);
  sigma_b ~ normal(0, 1);
  a_std ~ normal(0,1);
  b_std ~ normal(0,1);
  gamma ~normal(0,1);
  beta ~ normal(0,1); 
  y ~ poisson_log(log(n) + x_beta + gamma[index_time] + a[practice] + b[practice] .* time);   // likelihood
}


generated quantities {
  //vector[I * T] y_sim;
  vector[I * T] log_lik;
  vector[I * T] y_hat = log(n) + x_beta + gamma[index_time] + a[practice] + b[practice] .* time;
 // for (it in 1:I * T) {
  //  y_sim[it] = poisson_log_rng(y_hat[it]);
 // }
 for(it in 1:I*T){
    log_lik[it] = poisson_log_lpmf(y[it] | log(n[it]) + x_beta[it] + gamma[index_time[it]] + a[practice[it]] + b[practice[it]] .* time[it]);
 }
}

After reading this example, i changed these blocks to:

model {
  phi ~ cauchy(0, 3);
  sigma_a ~ normal(0, 1);
  sigma_b ~ normal(0, 1);
  a_std ~ normal(0,1);
  b_std ~ normal(0,1);
  gamma ~normal(0,1);
  y ~ neg_binomial_2_log(log(n) + gamma[index_time] + a[practice] + b[practice] .* time, phi);   // likelihood
}


generated quantities {
  vector[I * T] y_sim;
  vector[I * T] log_lik;
  vector[I * T] y_hat = log(n) + gamma[index_time] + a[practice] + b[practice] .* time;
 for (it in 1:I * T) {
  y_sim[it] = neg_binomial_2_log_rng(y_hat[it], phi);
 }
 for(it in 1:I*T){
    log_lik[it] = neg_binomial_2_log_lpmf(y[it] | log(n[it]) + gamma[index_time[it]] + a[practice[it]] + b[practice[it]] .* time[it], phi);
 }
}

where real<lower=0> phi;

Alas, when I try to fit this model I get a bunch of errors:

[1] "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"                                                                               
 [2] "Exception: neg_binomial_2_log_lpmf: Precision parameter is 0, but must be > 0!  (in 'model68685a6b6cb4_stan_68685cba1da' at line 36)"                                                         
 [3] "If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,"                                                       
 [4] "but if this warning occurs often then your model may be either severely ill-conditioned or misspecified."                                                                                     
 [5] "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"                                                                               
 [6] "Exception: neg_binomial_2_log_lpmf: Precision parameter is 0, but must be > 0!  (in 'model68685a6b6cb4_stan_68685cba1da' at line 36)"                                                         
 [7] "If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,"                                                       
 [8] "but if this warning occurs often then your model may be either severely ill-conditioned or misspecified."                                                                                     
 [9] "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"                                                                               
[10] "Exception: neg_binomial_2_log_lpmf: Precision parameter is 0, but must be > 0!  (in 'model68685a6b6cb4_stan_68685cba1da' at line 36)"                                                         
[11] "If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,"                                                       
[12] "but if this warning occurs often then your model may be either severely ill-conditioned or misspecified."                                                                                     
[13] "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"                                                                               
[14] "Exception: neg_binomial_2_log_lpmf: Precision parameter is 0, but must be > 0!  (in 'model68685a6b6cb4_stan_68685cba1da' at line 36)"                                                         
[15] "If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,"                                                       
[16] "but if this warning occurs often then your model may be either severely ill-conditioned or misspecified."                                                                                     
[17] "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"                                                                               
[18] "Exception: neg_binomial_2_log_lpmf: Precision parameter is 0, but must be > 0!  (in 'model68685a6b6cb4_stan_68685cba1da' at line 36)"                                                         
[19] "If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,"                                                       
[20] "but if this warning occurs often then your model may be either severely ill-conditioned or misspecified."                                                                                     
[21] "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"                                                                               
[22] "Exception: neg_binomial_2_log_lpmf: Precision parameter is 0, but must be > 0!  (in 'model68685a6b6cb4_stan_68685cba1da' at line 36)"                                                         
[23] "If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,"                                                       
[24] "but if this warning occurs often then your model may be either severely ill-conditioned or misspecified."                                                                                     
[25] "Error in sampler$call_sampler(args_list[[i]]) : "                                                                                                                                             
[26] "  Exception: neg_binomial_2_log_rng: Random number that came from gamma distribution is 9.9818e+009, but must be less than 1.07374e+009  (in 'model68685a6b6cb4_stan_68685cba1da' at line 45)"
[1] "error occurred during calling the sampler; sampling not done"