combining 3 graphs from different codes.

5 views (last 30 days)
I am trying to replicate a model that corresponds to the New Keynesian model used in Leeper, Traum and Walker (2017). There is a .mod file where I am changing the parameters and there is a .m file that runs the .mod file using dynare, combines the 40 graphs in the .mod file and subplots 12 output into 1 graph.
My problem is, I have 2 other modified version of the .mod file, so I want to combine the result of these 2 graphs over the 1st graph so that they are comparable.

Accepted Answer

Voss
Voss on 9 Jul 2023
Try the modified run.m file attached. I added a for loop to loop over the three .mod files (you'll have to supply their names), runnning dynare on each and plotting each set of results into the same 12 subplots, with a different line color for each model. After the for loop, the other stuff you're doing (setting the subplot title, adding a horizontal line at y=0, setting axis tight) is done once for each subplot.
You may want to add (a) legend(s) to indicate which lines correspond to each model. Since the legend would be the same for each of the 12 subplots, it makes sense to have one legend for all subplots instead. To do that, you can use tiledlayout instead of subplot, as shown here, or do it with subplots as shown here.
  1 Comment
Eashan
Eashan on 9 Jul 2023
Thanks. This is working (with a minor adjustment in subplot_titles). Overall, great solution!

Sign in to comment.

More Answers (0)

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!