Home > matlab > ftest.m

ftest

PURPOSE ^

Copyright (C) 2001-2010 Dynare Team

SYNOPSIS ^

function ftest (s1,s2)

DESCRIPTION ^

 Copyright (C) 2001-2010 Dynare Team

 This file is part of Dynare.

 Dynare is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 Dynare is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ftest (s1,s2)
0002 
0003 % Copyright (C) 2001-2010 Dynare Team
0004 %
0005 % This file is part of Dynare.
0006 %
0007 % Dynare is free software: you can redistribute it and/or modify
0008 % it under the terms of the GNU General Public License as published by
0009 % the Free Software Foundation, either version 3 of the License, or
0010 % (at your option) any later version.
0011 %
0012 % Dynare is distributed in the hope that it will be useful,
0013 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015 % GNU General Public License for more details.
0016 %
0017 % You should have received a copy of the GNU General Public License
0018 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0019 
0020 global nvx nvy x y lag1
0021 
0022 if size(s1,1) ~= 2
0023     error ('Sp�ifiez deux fichiers pour la comparaison.') ;
0024 end
0025 
0026 for i = 1:2
0027     if ~ isempty(find(abs(s1(i,:)) == 46))
0028         error ('Entrez les noms de fichiers sans extensions.') ;
0029     end
0030 end
0031 
0032 s1 = [s1 [' ';' ']] ;
0033 file1 = [s1(1,1:min(find(abs(s1(1,:)) == 32))-1) '.BIN'] ;
0034 file2 = [s1(2,1:min(find(abs(s1(2,:)) == 32))-1) '.BIN'] ;
0035 
0036 fid=fopen(file1,'r') ;
0037 n1 = fread(fid,1,'int') ;
0038 n2 = fread(fid,1,'int') ;
0039 n3 = fread(fid,1,'int') ;
0040 lag1 = fread(fid,4,'int') ;
0041 nvx = fread(fid,[n1,n3],'int') ;
0042 x = fread(fid,[n1,n2],'float64') ;
0043 fclose(fid) ;
0044 nvx = char(nvx) ;
0045 
0046 fid=fopen(file2,'r') ;
0047 n1 = fread(fid,1,'int') ;
0048 n2 = fread(fid,1,'int') ;
0049 n3 = fread(fid,1,'int') ;
0050 lag2 = fread(fid,4,'int') ;
0051 nvy = fread(fid,[n1,n3],'int') ;
0052 y = fread(fid,[n1,n2],'float64') ;
0053 fclose(fid) ;
0054 nvy = char(nvy) ;
0055 
0056 if size(x,1) ~= size(y,1)
0057     error ('FTEST: The two files don''t have the same number of variables.');
0058 end
0059 
0060 for i = 1:size(x,1)
0061     if ~ strcmp(nvx(i,:),nvy(i,:))
0062         error ('FTEST: The two files don''t have the same  variables.') ;       
0063     end
0064 end
0065 
0066 if nnz(lag1 - lag2) > 0
0067     error ('FTEST: Leads and lags aren''t the same in both files.') ;
0068 end
0069 
0070 j = zeros(size(s2,1),1);
0071 for i=1:size(s2,1)
0072     k = strmatch(s2(i,:),nvx,'exact') ;
0073     if isempty(k)
0074         t = ['FTEST: Variable ' s2(i) 'doesn''t exist'] ;
0075         error (t) ;
0076     else
0077         j(i) =k;
0078     end
0079 end
0080 
0081 y = y(j,:) ;
0082 x = x(j,:) ;
0083 
0084 %06/18/01 MJ replaced beastr by strmatch

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005