I was trying to fit the below model with brms:
fit.1 <- brm(y ~ A * B * C * D + E + (A * B * C * D | g1) + (1 | g2),
data = df, family = lognormal,
cores = 1, chains = 1, iter = 300)
A
, B
, C
and D
are factors and E
is a covariate. This is the dumped data set data.R (410.3 KB).
During sampling, I got errors:
Rejecting initial value:
Log probability evaluates to log(0), i.e. negative infinity.
Stan can't start sampling from this initial value.
Iteration: 1 / 300 [ 0%] (Warmup)
Exception: model39d27bec92db_a2c0a7231ba0e427628b016846ca7749_namespace::write_array: y is not positive definite. (in 'model39d27bec92db_a2c0a7231ba0e427628b016846ca7749' at line 143)
After the sampling ended, I got an error saying that sampling was not done:
error occurred during calling the sampler; sampling not done
However, if I remove the correlation of varying intercepts and varying slopes, the model converges successfully:
fit.2 <- brm(y ~ A * B * C * D + E + (A * B * C * D || g1) + (1 | g2),
data = df, family = lognormal,
cores = 1, chains = 1, iter = 300)
Do you know what was wrong with the first model?
Thank you!
The full errors after sampling:
[1] "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"
[2] "Exception: lognormal_lpdf: Scale parameter is inf, but must be finite! (in 'model39d27bec92db_a2c0a7231ba0e427628b016846ca7749' at line 137)"
[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: lognormal_lpdf: Scale parameter is inf, but must be finite! (in 'model39d27bec92db_a2c0a7231ba0e427628b016846ca7749' at line 137)"
[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: lognormal_lpdf: Scale parameter is inf, but must be finite! (in 'model39d27bec92db_a2c0a7231ba0e427628b016846ca7749' at line 137)"
[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: multiply: A[37] is -nan, but must not be nan! (in 'model39d27bec92db_a2c0a7231ba0e427628b016846ca7749' at line 79)"
[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: lognormal_lpdf: Scale parameter is inf, but must be finite! (in 'model39d27bec92db_a2c0a7231ba0e427628b016846ca7749' at line 137)"
[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] "Error in sampler$call_sampler(args_list[[i]]) : "
[22] " Exception: model39d27bec92db_a2c0a7231ba0e427628b016846ca7749_namespace::write_array: y is not positive definite. (in 'model39d27bec92db_a2c0a7231ba0e427628b016846ca7749' at line 143)"
error occurred during calling the sampler; sampling not done
- Operating System: Ubuntu 18.04.1
- brms Version: 2.5.0