Estimating VAR block within DSGE model

Dear All,

I am currently estimating a model featuring an endogenous DSGE economy, together with an exogenous rest of the world block, modelled as a VAR.
The model is input in its non-linear form and I am using an external steady state file.

My question is the following: when running estimation, how can I make sure that the draws of the VAR coefficients are such that they don’t violate B-K conditions?
Or, to put it differently, how can I make sure I am disregarding parameters draws that make the VAR unstable?
Should I insert in the steady state file something like:

if unstable==1
check=1;
return;
end

Where unstable is a boolean set to 1 any time coefficients draw makes the VAR unstable.
Is this the way to go? Or do you have any other suggestions? Files are attached below

Thanks in advance for your time!
Mattia

ScotModelTest.mod (39.0 KB)

modeldata.xlsx (71.0 KB)

SS_Solver.m (2.4 KB)

ScotModelTest_steadystate.m (5.1 KB)

Yes, that is exactly the way to go.
However, I am not sure that Dynare would allow an unstable VAR in the first place. You would get an eigenvalue bigger than 1 with only backward-looking variables. So the model would violate the BK-conditions.

Dear Professor Pfeifer,

Thanks a lot for your reply.
Can I just double check the following in relation to your reply?

During estimation, is it any parameter draw causing violation of B-K conditions just automatically discarded?
So in my case with the VAR, no control is actually needed because Dynare just discard any parameter draw causing instability and moves on without crashing?

Thanks!

Yes, I think so. We had a case like this in Model diagnostics command