Cannot use "clear all" command in a mod file

Hi professor,

Could you please let me know why I cannot use the “clear all” command at the top of the dynare file as in Matlab? While “close all” and “clc” work just fine as in Matlab? please find below the screenshot of the error message.

I tried to write a Matlab file with “clear all” and add it to the mod file
to automate it, without any success.

Is there any alternative to “clear all” used in dynare mod file to clean the workspace?

You are supposed to run clear all before calling Dynare, not within the mod-file. If you really not to clear the workspace every time you run Dynare, you can write a Matlab script with just the clear all and the call to Dynare.

Could you explain in more detail by providing a simple example?

thanks!

See run_example1.m, which just contains

clear all
dynare example1.mod

example1.mod (1.5 KB)
run_example1.m (32 Bytes)

1 Like

Yes, it worked!!

another question is:

test.mod (10.1 KB)

could you please let me know what’s wrong the this mod file. The idea is to switch between two regimes: IT targeting and NGDP targeting (lines 140-147)

and plot bond supply stack_b ( generated over 500 values of chi) against 9 variables on the SAME figure for comparison.

I proceeded in 2 runs:

For the 1st run, I commented out line 147 while uncommenting line 142 in the model block - choosing IT targeting equation.

And commented out lines 373-385 while uncommenting lines 344-363 for plotting under regime 1 and saved the result.

For the 2nd run, I did the opposite - switching from line 142 to 147 in the model block - choosing NGDP targeting inflation equation

And commented out lines 344-363 while uncommenting lines 373-385 for plotting under regime 2 and added the result generated under regime 2.

However, the lines generated under 2 regimes coincide…

what’s wrong with my code/approach?

Thanks for your help in advance!

Have you checked that the two mod files generate different results for things like IRFs?

1 Like

[quote=“Julie, post:5, topic:25779”]
n
I didn’t compute IRFs, but did compare mean and variance of taxes between 2 regimes by using the update code attached here:
test_updated.mod (11.9 KB)

which gave the desirable results as below

I tried to clean up your files. Please continue working with them. I introduced a macro switch to switch between cases:
steady_helper.m (217 Bytes)
test_updated.mod (9.9 KB)
run_test_updated.m (73 Bytes)

I tried your updated code which still gave the same results as before…

two lines coincided for the 3*3 plot, while for comparison of taxes, they worked fine.