Home > matlab > mcompare.m

mcompare

PURPOSE ^

MCOMPARE : MCOMPARE ( [ 'file1' ; 'file2' ] , [ 'var1' ; 'var2' ...] )

SYNOPSIS ^

function mcompare(s1,s2)

DESCRIPTION ^

 MCOMPARE :    MCOMPARE ( [ 'file1' ; 'file2' ] , [ 'var1' ; 'var2' ...] )     
               This optional command plots the relative differences between
               two different simulations for a list of variables. One plot 
               is drawn for each variable. The trajectories must have been
               previously saved by the instruction DYNASAVE. The simulation
               in file1 serves as the base simulation and the ploted quantity
               is equal to the difference between the two simulation reported
               to the first one. If, for a given variable, zero is one of the
               value of the base simulation, the absolute difference is ploted
               instead of the relative one.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mcompare(s1,s2)
0002 % MCOMPARE :    MCOMPARE ( [ 'file1' ; 'file2' ] , [ 'var1' ; 'var2' ...] )
0003 %               This optional command plots the relative differences between
0004 %               two different simulations for a list of variables. One plot
0005 %               is drawn for each variable. The trajectories must have been
0006 %               previously saved by the instruction DYNASAVE. The simulation
0007 %               in file1 serves as the base simulation and the ploted quantity
0008 %               is equal to the difference between the two simulation reported
0009 %               to the first one. If, for a given variable, zero is one of the
0010 %               value of the base simulation, the absolute difference is ploted
0011 %               instead of the relative one.
0012 
0013 % Copyright (C) 2001-2011 Dynare Team
0014 %
0015 % This file is part of Dynare.
0016 %
0017 % Dynare is free software: you can redistribute it and/or modify
0018 % it under the terms of the GNU General Public License as published by
0019 % the Free Software Foundation, either version 3 of the License, or
0020 % (at your option) any later version.
0021 %
0022 % Dynare is distributed in the hope that it will be useful,
0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 % GNU General Public License for more details.
0026 %
0027 % You should have received a copy of the GNU General Public License
0028 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0029 
0030 global options_
0031 global nvx nvy x y lag1
0032 
0033 ftest(s1,s2) ;
0034 
0035 ix = [1-lag1(1):size(x,2)-lag1(1)]' ;
0036 i = [lag1(1):size(ix,1)-lag1(2)+1]' ;
0037 
0038 if size(options_.smpl,1) == 1
0039     error(['DSAMPLE not specified.']) ;
0040 end
0041 
0042 if options_.smpl(3) > 0
0043     if options_.smpl(3) == 2
0044         if options_.smpl(1)<0 || options_.smpl(2)>size(x,2)-lag1(2)
0045             error ('Wrong sample.') ;
0046         end
0047         i = [options_.smpl(1)+lag1(1):options_.smpl(2)+lag1(1)]' ;
0048     elseif options_.smpl(3) == 1
0049         if options_.smpl(1)>size(x,2)-lag1(2)
0050             error ('Wrong sample.') ;
0051         end
0052         i = [lag1(1):options_.smpl(1)+lag1(1)]' ;
0053     end
0054 end
0055 
0056 for k = 1:size(x,1)
0057     figure ;
0058     x1 = x(k,i) ;
0059     y1 = y(k,i) ;
0060     if nnz(x1) < length(x1)
0061         plot(ix(i),(y1-x1)) ;
0062     else
0063         plot(ix(i),(y1-x1)./x1) ;
0064     end
0065     xlabel(['Periods']) ;
0066     title(['Variable ' s2(k)]) ;
0067 end
0068 
0069 return ;

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005