Home > matlab > initialize_from_mode.m

initialize_from_mode

PURPOSE ^

function estim_params_ = initialize_from_mode(fname,M_,estim_params_)

SYNOPSIS ^

function estim_params_ = initialize_from_mode(fname,M_,estim_params_)

DESCRIPTION ^

 function estim_params_ = initialize_from_mode(fname,M_,estim_params_)
 initialize parameters and initial value of estimated parameters
 from a *_mode.mat file    
  
 INPUTS
   fname:  mode file name (*.mat file)
   M_:     sructure of model characteristics
   estim_params_: structure of estimated parameters
  
 OUTPUTS
   estim_params:  modified structure of estimated parameters

 SPECIAL REQUIREMENTS
   none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function estim_params_ = initialize_from_mode(fname,M_,estim_params_)
0002 % function estim_params_ = initialize_from_mode(fname,M_,estim_params_)
0003 % initialize parameters and initial value of estimated parameters
0004 % from a *_mode.mat file
0005 %
0006 % INPUTS
0007 %   fname:  mode file name (*.mat file)
0008 %   M_:     sructure of model characteristics
0009 %   estim_params_: structure of estimated parameters
0010 %
0011 % OUTPUTS
0012 %   estim_params:  modified structure of estimated parameters
0013 %
0014 % SPECIAL REQUIREMENTS
0015 %   none
0016 
0017 % Copyright (C) 2003-2011 Dynare Team
0018 %
0019 % This file is part of Dynare.
0020 %
0021 % Dynare is free software: you can redistribute it and/or modify
0022 % it under the terms of the GNU General Public License as published by
0023 % the Free Software Foundation, either version 3 of the License, or
0024 % (at your option) any later version.
0025 %
0026 % Dynare is distributed in the hope that it will be useful,
0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0029 % GNU General Public License for more details.
0030 %
0031 % You should have received a copy of the GNU General Public License
0032 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0033 
0034 
0035 load(fname,'xparam1','parameter_names');
0036 
0037 endo_names = M_.endo_names;
0038 exo_names = M_.exo_names;
0039 param_names = M_.param_names;
0040 param_vals = estim_params_.param_vals;
0041 var_exo = estim_params_.var_exo;
0042 var_endo = estim_params_.var_endo;
0043 corrx = estim_params_.corrx;
0044 corrn = estim_params_.corrn;
0045 for i=1:length(parameter_names)
0046     name = parameter_names{i};
0047     k1 = strmatch(name,param_names,'exact');
0048     if ~isempty(k1)
0049         k2 = find(param_vals(:,1) == k1);
0050         if ~isempty(k2)
0051             estim_params_.param_vals(k2,2) = xparam1(i);
0052         end
0053         M_.params(i) = xparam1(i);
0054         continue
0055     end
0056     k3 = strfind(name,',');
0057     if isempty(k3)
0058         k1 = strmatch(name,exo_names,'exact');
0059         if ~isempty(k1)
0060             k2 = find(var_exo(:,1) == k1);
0061             if ~isempty(k2)
0062                 estim_params_.var_exo(k2,2) = xparam1(i);
0063             end
0064             M_.Sigma_e(k1,k1) = xparam1(i)^2;
0065             continue
0066         end
0067         k1 = strmatch(name,endo_names,'exact');
0068         if ~isempty(k1)
0069             k2 = find(var_endo(:,1) == k1);
0070             if ~isempty(k2)
0071                 estim_params_.var_endo(k2,2) = xparam1(i);
0072             end
0073             M_.H(k1,k1) = xparam1(i)^2;
0074             continue
0075         end
0076     else
0077         k1 = strmatch(name(1:k3-1),exo_names,'exact');
0078         k1a = strmatch(name(k3+1:end),exo_names,'exact');
0079         if ~isempty(k1) && ~isempty(k1a)
0080             k2 = find(corrx(:,1) == k1 & corrx(:,2) == k1a);
0081             if ~isempty(k2)
0082                 estim_params_.corrx(k2,3) = xparam1(i);
0083             end
0084             M_.Sigma_e(k1,k1a) = xparam1(i)*sqrt(M_.Sigma_e(k1,k1)+M_.Sigma_e(k1a,k1a));
0085             M_.Sigma_e(k1a,k1) = M_.Sigma_e(k1,k1a);
0086             continue
0087         end
0088         k1 = strmatch(name(1:k3-1),endo_names,'exact');
0089         k1a = strmatch(name(k3+1:end),endo_names,'exact');
0090         if ~isempty(k1) && ~isempty(k1a)
0091             k2 = find(corrn(:,1) == k1 & corrn(:,2) == k1a);
0092             if ~isempty(k2)
0093                 estim_params_.corrn(k2,3) = xparam1(i);
0094             end
0095             M_.H(k1,k1a) = xparam1(i)*sqrt(M_.H(k1,k1)+M_.H(k1a,k1a));
0096             M_.H(k1a,k1) = M_.H(k1,k1a);
0097             continue
0098         end
0099     end
0100     error([name 'doesn''t exist in this model'])
0101 end
0102

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