I am trying to use DSGE models to create artificial data in order to build a hybrid model DSGE-VAR. Indeed, i need to construct observations with a size Ta = k*Tr. Tr represents a real observations size and k a weight that is given the prior information in our analysis. Nevertheless, when computing my programs, i encounter the following problem. If k is not an integer such as (1;2;3;…), my program can not run because Ta should be also an integer. So, my question is:
Can we use usual functions like “sqrt” or “floor” within macro-expression, to resolve my problem?
@# define k=1/2
@# define m=39
@# define n=floor(k*m)
To see my exact problem, you find attached the following files: Go to line 388 in model file.
Your help really appreciated.
Thanks a lot.
MSSF_VAR_forecast_2_steps_steadystate.m (3.64 KB)
MSSF_VAR_forecast_2_steps.mod (18.2 KB)
Sorry, but the preprocessor is for text operations. The expressions you create will not be parsed.
You can get around some of the restriction by directly using the expression for n:
But this only works for code parts interpreted by Matlab, which knows the floor()-command. It will fail with
Have you considered doing the first loop via Dynare and then manually iterating over perfect_foresight_setup and perfect_foresight_solver via a Matlab-script?
No, i did not consider this way of dealing. And, i don’t know how i can carry out this way in my case.
Any other help is appreciated.
If I understand it correctly, you are using the macro-processor to loop over
where you change the number of periods. What you can do is run the mod-file once for the first step of the loop. Dynare will provide you with the code for this in the m-file. Then you can just take that piece of code and adjust it. If you provide me with a clean mod-file for the first step (i.e. without the macroprocessor stuff) and tell me what you are trying to do, I might be able to help you.
Before preparing a clean mod-file to be send, i have a question about arithmetic operators( namely division) on macro-variables.
Can this following code be compiled?
@# define a=1
@# define b=2
@# define p= a/b
Because i remark that in my programs p gets 0 instead of 1/2.
Thanks a lot for your help!!
This seems to be buggy. Please do not rely on the output of arithmetic in define statements. We are investigating the issue. See github.com/DynareTeam/dynare/issues/1278
As you might have seen, downward truncation is actually a design feature of the preprocessor.