# Designing probability outside the model

Hello,

I come across something that looks pretty strange. I have a model with news-shocks. What I do mainly is to compare the case where shocks are pure surprises to the case where shocks are known one period in advance. In order to do so, I treat news as a parametre. The way I program it is that, at the **very very begining ** of my mod file (i.e. before the var or the parametres block) I set:

``````@#define q = 0
q= @{q}``````

Then, my shock process writes:

``````zT1 = autoregressive terms + eT1(-@{q}) ;
zT2 = autoregressive terms + eT2(-@{q}) ;``````

Thus, when I set “@#define q = 0” I have the case of traditional, unexpected disturbances and when “@#define q = 1” is the case of news-shocks. So I compare the two cases. What I want to try next is how my results change when news arrive with some probability. For example, some statistics move from a value X when q=0 to a value Y when q=1. These are the two extreme cases where news either arrive or not. Now I want to check if news arrive 1/10, 2/10, 3/10,… times whether my statistic will move (monotonically or otherwise) from X–>Y.

To implement this I thought of simulations. My idea is to simulate the model 500 times (or more) and at each time, before a model is run, I make a random draw over the unit interval and I check if this draw is < prob; where prob is the probability of news. Thus, to implement that, again at the VERY beginning of my code and before the var block, I do:

``````jj = 5 ;

NewsCount=0;
I = 10000 ; % insert the number of desired simulations
for i = 1:I ;

xx0 = rand([1,1]);

prob = jj/10 ;

if xx0 <= prob
xx01(1, i) = xx0;
xx01(2,i) = 1 ;
eval('NewsCount', ' = NewsCount', ' + 1 ;']);
@#define countries =  "1", "2" ]
% Number of lags for which news shocks as in play
@#define q = 1
q= @{q}
else
xx01(1, i) = xx0;
xx01(2,i) = 0;
@#define countries =  "1", "2" ]
% Number of lags for which news shocks as in play
@#define q = 0
q= @{q}
end ``````

In the above case the probability is 5/10=1/2. The problem is that even though q does change, and in the end of the 500 simulations the empirical probability is close to the theoretical one (thats why I use this NewsCount thing, to count the number of times q=1 and then compute the REALISED probability out of the experiment) the results do not change. That is, the results will concern the case q=0 or q=1, depending which was done first. After a lot of struggle, I realise that q does not ACTUALLY change when I allowed q to be chosen as above and I solved the asymptotic case. What happens is that even though the value of q does change from what I can see on my screen, I guess it does not change in the matlab files dynare creates. Thus, whatever the resulting value of q (again, the one I can see on the screen), the results are unchanged (since it concerns the asymptotic case) corresponding to q=0 or q=1, depending on which case was run in the very beginning when the model was solved without the probability thing, but as in the very first part above.

now, this is strange no? I don’t understand why when I program the thing as in the first case above it works, but when I pick up the value of q as in the latter case it does not. Anyone has an idea? In general, how I could implement this?

Hope this is clear enough, albeit quite long.

Kyriacos

Hi,

I am not sure that I understand your problem. However, you are using the preprocessor macro language. What the language does is do text evaluation. Essentially, your macro codes are evaluated by the preprocessor at the beginning of the Dynare run, leading to a mod-file where every macros have been replaced by a fixed text. I am pretty sure that the preprocessor is not evaluating the random number generation. Thus, you are always dealing with a fixed case.

They way I would have tried it is having a model where you have both news and surprise shocks. You set their standard deviations in the shocks-block to the actual standard deviations, but you premultiply them in the model-block with a parameter acting as an indicator, e.g.

```zT1 = autoregressive terms + ind1*eT1(-1) +ind2*eT1; ```
Now after running Dynare once on the mod-file, you can just use the workspace to execute Dynare commands. With

```set_param_value(ind1,1) set_param_value(ind2,0) ```
you can for example use only a news shock, while the opposite case would be a surprise shock. Given the reset parameters, you can then just use

```info = stoch_simul(var_list_); ```
to simulate the model again, given the options you specified in the stoch_simul-command of the mod-file you just ran once. The results structure oo_ will store the results from the recent run of stoch_simul with the parameters you just set.

You can also embed the whole thing in a Matlab m-file. In this case, run the mod-file first with the noclearall option and then iterate over set_param_value and stoch_simul.

Even though I did not use what you suggested, your response gave me an idea. I basically worked directly on the matlab files created by Dynare. It worked and gave me the result I wanted )