Closed paciorek closed 6 days ago
@paciorek The issue is essentially, when RW_block
sampler estimates the empirical covariance from the recent samples (specifically, using the samples collected during the most recent adaptation period), that estimation of a 2nd order statistic (variance-covariance matrix) will fail when there's only 1 sample in each adaptation period (when adaptInterval
= 1).
Looking the the code for the RW_block
sampler, this problem manifests itself around line 745 or so, when first the "centering" of the empircal samples (here, a single sample), centers them to become all zero:
empirSamp[, i] <<- empirSamp[, i] - mean(empirSamp[, i])
and then worse, when it divides by $n-1$, or here timesRan-1
, that's dividing by 0, which seems to give NaN
, or something similar, and then the chol
fails, and I guess it's downhill from there.
Maybe we could restrict adaptInterval
to be at least 2? Or, set adaptScaleOnly = TRUE
in the case when adaptInterval = 1
, so that no adaptation of the proposal covariance happens? Or, modify the RW_block
sampler it always uses more than 1 sample for this estimation? Just ideas..
Simplest thing given this hasn't come up in practice is that we restrict adaptInterval
to be at least 2. I'm going to add that error trap.
It runs (which I was thinking it might not because of 1-d vs 2-d allocation for the samples saved for calculating the covariance), but in a simple example, there are no acceptances. @danielturek or I should look into for 1.3.0 release.