Unrecognized function or variable 'ytot'

Hi there,

I am trying to replicate Abbritti and Fahr’s 2013 publication, Downward Wage Rigidity and Business Cycle Asymmetries, and I am getting the following error code when I run .mod file in Dynare:

Unrecognized function or variable ‘ytot’.

Error in dwmoments (line 49)
lOUT = lPROD.*ytot;

→ the variable ‘ytot’ is defined as a variable in the ‘var’ block;
→ ytot Inshaa Allahgiven a value in the ‘initval;’ block - it is defined as ytot=Yss; Yss is a parameter and it is defined in the workspace.
→ ytot is defined with an equation based on other defined variables and parameters in the model section

before i get the error term, the steady state results appear in the Command Window, and ytot is indeed= the value of Yss seen in the workspace.
Then when the .mod file calls another file ‘dwmoments.m’ this is where the issue arises. Supposedly, ‘dwmoments.m’ does not recognize the variable ‘ytot’.

For a fuller picture: ytot never appears in the workspace, I am not sure if that is normal or not. Also, when I used the ‘whos’ command in the command window, ytot does not appear at all.

I have spent hours trying to figure out what the problem is, why ‘ytot’ is not recognized… please help!

Many thanks in advance.

Without the files it is hard to tell. Are you using Dynare 6? If yes, you may be missing a

send_endogenous_variables_to_workspace

to restore backward compatibility.

Can you please upload the files to run instead of the plain text?

Please find the attached files (this is from the provided code files from Abrritti and Fahr’s 2013 paper, with some of my amendments) : I am now pinpointing another issue.

The model includes 31 endogenous variables, as is seen in M_.endo_nbr, and when simulated for 566 periods, the results appear in oo_.endo_simul. However, in the workspace only 30 of the 31 variables appear with 566 x 1 vector, the variable ‘v’ is appearing as a constant. However, when I check its index position in oo_.endo_simul it appears to have the correct results. It also prints those results in the command window, when I type this command:

v_simulated = oo_.endo_simul(find(strcmp(M_.endo_names, ‘v’)), :);
disp(v_simulated);

So it recognizes the variable v, and can print its simulated values, but I don’t know why it keeps appearing in the Workspace as a constant.

I even included this command under the simulation to ensure it would appear as a vector, but no dice.

for idx = 1:M_.endo_nbr
assignin(‘base’, M_.endo_names{idx}, oo_.endo_simul(idx,:)');
if strcmp(M_.endo_names{idx}, ‘v’)
disp(oo_.endo_simul(idx,:));
end
end

The difference in array sizes is causing issues for the rest of the code.

Help would be highly appreciated!
dw_AF13.mod (7.5 KB)
dwmoments.m (5.1 KB)

You need to provide all necessary files. There are various m-files missing.

Please just upload a zip or rar file with everything contained.

Ok thank you for your response. I will do this in a moment.

ScienceDirect_files_06Jun2024_08-59-06.459.zip (1.2 MB)

Here it is. Again, this is the files provided by the authors as mentioned above, with amendments I made within their .mod file.

The call to stoch_simul was still incorrect:
dwmoments.m (5.1 KB)

Now there is a problem with logging simulated negative values.

Thank you!

Unfortunately, the same issue has come back with ‘v’ now being saved as a constant in the workspace (rather than a variable with data matrix of simulated values). The simulated values of v are generated and available, I know this because when I type the following in the command window, I get the 566 simulated values of v:

v_simulated = oo_.endo_simul(find(strcmp(M_.endo_names, “v”)), :);
disp(v_simulated);

The code runs fine throughout the file dwmoments.m (which calls the stoch_simuli function), but somewhere there must be a point where a constant is overriding the simulated data matrix. As a result, I cannot run my impulse response function on v as one of the variables.

Is there any code I can include to ensure that v is saved as the data matrix created by stoch_simuli, and is not then allowed to be overwritten?

The file dwmoments.m runs completely, and so foes dwturningpoint.m, the issue arrises when the function dynareif (end of the .mod file) is called, as it calls v as a variable, and it no longer exists in the workspace at that point.

I tried searching where v changed but there are so many files, and it wasn’t clear.

I tried adding this under ‘send_endogenous_variables_to_workspace’ (immedietly after stoch_simuli is called):
v= evalin(‘base’, ‘v’); % Retrieve and fix the value in base
assignin(‘base’, ‘v’, v); % Ensure it is stored as fixed

It didn’t work - v was still a constant.

I also tried renaming v:
v = oo_.endo_simul(find(strcmp(M_.endo_names, ‘v’)), :)';

It also didn’t work.

Any tip would be great! Many many thanks in advance.
ScienceDirect_files_06Jun2024_08-59-06.459 copy 3.zip (1.4 MB)

Please use the consolidated version at Irf function: not extracting values of dr, or other inputs - #5 by injeb

In your present code the issue is that

    i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact');

should be

    i_tmp = strmatch(var_list(i),M_.endo_names,'exact');

to reflect the use of cell arrays instead of character arrays.

great! Many thanks.