0001 function i = name2index(options_, M_, estim_params_, type, name1, name2 )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 nvx = estim_params_.nvx;
0037 nvn = estim_params_.nvn;
0038 ncx = estim_params_.ncx;
0039 ncn = estim_params_.ncn;
0040 npa = estim_params_.np ;
0041 nnn = nvx+nvn+ncx+ncn+npa;
0042
0043 i = [];
0044
0045 if strcmpi(type,'DeepParameter')
0046 i = nvx + nvn + ncx + ncn + ...
0047 strmatch(name1,M_.param_names(estim_params_.param_vals(:,1),:),'exact');
0048 if nargin>5
0049 disp('The last input argument is useless!')
0050 end
0051 if isempty(i)
0052 disp([name1 ' is not an estimated deep parameter!'])
0053 end
0054 return
0055 end
0056
0057 if strcmpi(type,'StructuralShock')
0058 if nargin<6
0059 i = strmatch(name1,M_.exo_names(estim_params_.var_exo(:,1),:),'exact');
0060 if isempty(i)
0061 disp(['The standard deviation of ' name1 ' is not an estimated parameter!'])
0062 return
0063 end
0064 else
0065 offset = nvx+nvn;
0066 try
0067 list_of_structural_shocks = [ M_.exo_names(estim_params_.corrx(:,1),:) , M_.exo_names(estim_params_.corrx(:,2),:) ];
0068 k1 = strmatch(name1,list_of_structural_shocks(:,1),'exact');
0069 k2 = strmatch(name2,list_of_structural_shocks(:,2),'exact');
0070 i = offset+intersect(k1,k2);
0071 if isempty(i)
0072 k1 = strmatch(name1,list_of_structural_shocks(:,2),'exact');
0073 k2 = strmatch(name2,list_of_structural_shocks(:,1),'exact');
0074 i = offset+intersect(k1,k2);
0075 end
0076 if isempty(i)
0077 if isempty(i)
0078 disp(['The correlation between' name1 ' and ' name2 ' is not an estimated parameter!'])
0079 return
0080 end
0081 end
0082 catch
0083 disp(['Off diagonal terms of the covariance matrix are not estimated (state equation)'])
0084 end
0085 end
0086 end
0087
0088 if strcmpi(type,'MeasurementError')
0089 if nargin<6
0090 i = nvx + strmatch(name1,M_.endo_names(estim_params_.var_endo(:,1),:),'exact');
0091 if isempty(i)
0092 disp(['The standard deviation of the measurement error on ' name1 ' is not an estimated parameter!'])
0093 return
0094 end
0095 else
0096 offset = nvx+nvn+ncx;
0097 try
0098 list_of_measurement_errors = [ M_.endo_names(estim_params_.corrn(:,1),:) , M_.endo_names(estim_params_.corrn(:,2),:) ];
0099 k1 = strmatch(name1,list_of_measurement_errors(:,1),'exact');
0100 k2 = strmatch(name2,list_of_measurement_errors(:,2),'exact');
0101 i = offset+intersect(k1,k2);
0102 if isempty(i)
0103 k1 = strmatch(name1,list_of_measurement_errors(:,2),'exact');
0104 k2 = strmatch(name2,list_of_measurement_errors(:,1),'exact');
0105 i = offset+intersect(k1,k2);
0106 end
0107 if isempty(i)
0108 if isempty(i)
0109 disp(['The correlation between the measurement errors on ' name1 ' and ' name2 ' is not an estimated parameter!'])
0110 return
0111 end
0112 end
0113 catch
0114 disp('Off diagonal terms of the covariance matrix are not estimated (measurement equation)')
0115 end
0116 end
0117 end