Error when estimating model

Hi!
I’m very new to dynare.
I’m trying to estimate a (sort of) large model. I’ve been following examples that I found online. Mostly, Anzoategui et al. (2019, AEJ: Macro) and Christiano et al. (2014, AER).
I’m not sure what the error of my code means, so any ideas will be much appreciated.
From my reading of the two codes, I need to define certain equations using the pound (#) operator, so that in the estimation, these are not set fixed, right?
Nevertheless, it seems that dynare doesn’t like to apply leads in such equations.
Also, I guess that if I’m defining model local variables, then I can’t define them in the variables block in the model?

Also, I’m using dynare 4.5.7 because I’ve also used dynareOBC in the past, and as far as I know, the match between dynareOBC and dynare 4.5.7 was great. I don’t mind updating to dynare 6.1, but just wondering if it’d be necessary or I can just move on.

The error is

ERROR: model_estimation.mod: line 45, cols 1-57: Ntil has wrong type or was already used on the right-hand side. You cannot use it on the left-hand side of a pound (‘#’) expression

but when i remove it from the block of # defined variables, I get

ERROR: model_estimation.mod: line 46, cols 1-51: x2 has wrong type or was already used on the right-hand side. You cannot use it on the left-hand side of a pound (‘#’) expression

and so on
data_use.mat (6.2 KB)
model_estimation.mod (7.9 KB)
estimation_params.m (8.8 KB)

What exactly are you trying to do?

#Ntil = w - b_ur + (1-sep)*M(+1)*(1-j_f(+1))*Ntil(+1)*gy;

is a recursive definition that cannot be a model-local variable. It would be an infinite recursion.

Right, thanks for pointing it out!
I have a new version of the files, and the error is that the there’s a non positive definite matrix and the cholesky breaks down.
Would be grateful if you could take a look
model_estimation.mod (8.1 KB)
estimation_params.m (7.9 KB)
data_use.mat (3.1 KB)

Check your observation equations. The steady state of Rnomobs is 102.407, but the data has a mean of about 1.