1function mcompare(s1,s2)
2% MCOMPARE :    MCOMPARE ( [ 'file1' ; 'file2' ] , [ 'var1' ; 'var2' ...] )
3%               This optional command plots the relative differences between
4%               two different simulations for a list of variables. One plot
5%               is drawn for each variable. The trajectories must have been
6%               previously saved by the instruction DYNASAVE. The simulation
7%               in file1 serves as the base simulation and the ploted quantity
8%               is equal to the difference between the two simulation reported
9%               to the first one. If, for a given variable, zero is one of the
10%               value of the base simulation, the absolute difference is ploted
11%               instead of the relative one.
12
13% Copyright (C) 2001-2017 Dynare Team
14%
15% This file is part of Dynare.
16%
17% Dynare is free software: you can redistribute it and/or modify
18% it under the terms of the GNU General Public License as published by
19% the Free Software Foundation, either version 3 of the License, or
20% (at your option) any later version.
21%
22% Dynare is distributed in the hope that it will be useful,
23% but WITHOUT ANY WARRANTY; without even the implied warranty of
24% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25% GNU General Public License for more details.
26%
27% You should have received a copy of the GNU General Public License
28% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
29
30global options_
31global nvx nvy x y lag1
32
33ftest(s1,s2) ;
34
35ix = [1-lag1(1):size(x,2)-lag1(1)]' ;
36i = [lag1(1):size(ix,1)-lag1(2)+1]' ;
37
38if size(options_.smpl,1) == 1
39    error(['DSAMPLE not specified.']) ;
40end
41
42if options_.smpl(3) > 0
43    if options_.smpl(3) == 2
44        if options_.smpl(1)<0 || options_.smpl(2)>size(x,2)-lag1(2)
45            error ('Wrong sample.') ;
46        end
47        i = [options_.smpl(1)+lag1(1):options_.smpl(2)+lag1(1)]' ;
48    elseif options_.smpl(3) == 1
49        if options_.smpl(1)>size(x,2)-lag1(2)
50            error ('Wrong sample.') ;
51        end
52        i = [lag1(1):options_.smpl(1)+lag1(1)]' ;
53    end
54end
55
56for k = 1:size(x,1)
57    figure ;
58    x1 = x(k,i) ;
59    y1 = y(k,i) ;
60    if nnz(x1) < length(x1)
61        plot(ix(i),(y1-x1)) ;
62    else
63        plot(ix(i),(y1-x1)./x1) ;
64    end
65    xlabel(['Periods']) ;
66    title(['Variable ' s2(k)]) ;
67end
68
69return ;
70