Home > matlab > subset.m

subset

PURPOSE ^

Copyright (C) 2006-2011 Dynare Team

SYNOPSIS ^

function jndx = subset()

DESCRIPTION ^

 Copyright (C) 2006-2011 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 jndx = subset()
0002 
0003 % Copyright (C) 2006-2011 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 options_ estim_params_ M_
0021 
0022 ExcludedParamNames = options_.ExcludedParams;
0023 VarObs = options_.varobs;
0024 VarExo = M_.exo_names;
0025 info   = options_.ParamSubSet;
0026 
0027 nvx = estim_params_.nvx;
0028 nvn = estim_params_.nvn;
0029 ncx = estim_params_.ncx;
0030 ncn = estim_params_.ncn;
0031 np  = estim_params_.np;
0032 nx  = nvx+nvn+ncx+ncn+np;
0033 
0034 if strcmpi(info,'All')
0035     indx = (1:nx)';
0036 elseif strcmpi(info,'DeepParameters')
0037     indx = (nvx+nvn+ncx+ncn+1:nx)';
0038 elseif strcmpi(info,'StructuralShocks')
0039     indx = [(1:nvx),nvx+nvn+1:nvx+nvn+ncx]';
0040 elseif strcmpi(info,'StructuralShocksWithoutCorrelations')
0041     indx = (1:nvx)';
0042 elseif strcmpi(info,'MeasurementErrors')
0043     indx = [(nvx+1:nvx+nvn),(nvx+nvn+ncx+1:nvx+nvn+ncx+ncn)]';
0044 elseif strcmpi(info,'MeasurementErrorsWithoutCorrelations')
0045     indx = (nvx+1:nvx+nvn)';
0046 elseif strcmpi(info,'AllWithoutMeasurementErrors')
0047     indx = [(1:nvx),nvx+nvn+1:nvx+nvn+ncx,nvx+nvn+ncx+ncn+1:nx]';
0048 elseif strcmpi(info,'None')
0049     indx = [];
0050 end
0051 
0052 if isempty(ExcludedParamNames)
0053     jndx = indx;
0054 else
0055     tt = [];
0056     for i = 1:length(ExcludedParamNames)
0057         tmp = strmatch(ExcludedParamNames{i},M_.exo_names);
0058         if ~isempty(tmp) && ( strcmpi(info,'All') || strcmpi(info,'StructuralShocks') || ...
0059                              strcmpi(info,'StructuralShocksWithoutCorrelations') || ...
0060                              strcmpi(info,'AllWithoutMeasurementErrors') )
0061             % The parameter the user wants to exclude is related to the size of the structural innovations.
0062             if ncx
0063                 disp(['I cannot exclude some of the structural variances if the'])
0064                 disp(['structural innovations are correlated...'])
0065                 error
0066             end
0067             tt = [tt;tmp];
0068         elseif isempty(tmp) && nvn 
0069             tmp = strmatch(ExcludedParamNames{i},options_.varobs);
0070             if ~isempty(tmp) && ( strcmpi(info,'All') || strcmpi(info,'MeasurementErrors') || ...
0071                                  strcmpi(info,'MeasurementErrorsWithoutCorrelations') )
0072                 % The parameter the user wants to exclude is related to the size of the measurement errors variances.
0073                 tmp = nvx+tmp;
0074                 if ncn
0075                     disp(['I cannot exclude some the measurement error variances if the'])
0076                     disp(['measurement errors are correlated...'])
0077                     error
0078                 end
0079                 tt = [tt;tmp];
0080             end
0081         else% Excluded parameters are deep parameters...
0082             tmp = strmatch(ExcludedParamNames{i},M_.param_names(estim_params_.param_vals(:,1),:),'exact');
0083             if ~isempty(tmp)
0084                 tt = [tt;nvx+nvn+ncx+ncn+tmp];
0085             else
0086                 disp('The parameter you want to exclude is unknown!')
0087                 error
0088             end
0089         end
0090     end
0091     jndx = [];
0092     for i=1:length(indx)
0093         if ~any(indx(i)==tt)
0094             jndx = [ jndx ; indx(i) ];
0095         end
0096     end
0097 end

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