Occbin: "increase maxit or check_ahead_periods" with very high maxit and check_ahead_periods

Thank you for the revised file. Unfortunately, there are still a couple of hard errors which get thrown:

  • “Make shocks the right size for the output” (setting etahat) needs to be done before all the returns, not only that first try/catch loop. The reason is that etahat naturally has two columns, and is reduced using etahat = etahat(:,2) at the very end of the function. This reduction is not done if the function returns early.

  • I also sometimes get an error “Error using missing_observations_kalman_filter. Assignment between unlike types is not allowed.”. This seems to be a consequence the way that regimes_ is initialised as [] at the beginning of the function. I have replaced the line regimes=[]; with regimes=[regimes0 regimes0(end)], which seems to have fixed the issue.