1function [fval,info,exit_flag,DLIK,Hess,SteadyState,trend_coeff]  = TaRB_optimizer_wrapper(optpar,par_vector,parameterindices,TargetFun,varargin)
2% function [fval,info,exit_flag,DLIK,Hess,SteadyState,trend_coeff]  = TaRB_optimizer_wrapper(optpar,par_vector,parameterindices,TargetFun,varargin)
3% Wrapper function for target function used in TaRB algorithm; reassembles
4% full parameter vector before calling target function
5%
6% INPUTS
7%   o optpar            [double]   (p_opt*1) vector of subset of parameters to be considered
8%   o par_vector        [double]   (p*1) full vector of parameters
9%   o parameterindices  [double]   (p_opt*1) index of optpar entries in
10%                                   par_vector
11%   o TargetFun         [char]      string specifying the name of the objective
12%                                   function (posterior kernel).
13%   o varargin          [structure] other inputs of target function
14%
15% OUTPUTS
16%   o fval       [scalar]   value of (minus) the likelihood.
17%   o info       [double]  (p*2) error code vector
18%   o exit_flag  [scalar]   equal to zero if the routine return with a penalty (one otherwise).
19%   o DLIK       [double]  (p*1) score vector of the likelihood.
20%   o Hess       [double]  (p*p) asymptotic Hessian matrix.
21%   o SteadyState [double]  Vector of doubles, steady state level for the endogenous variables.
22%   o trend_coeff [double]  Matrix of doubles, coefficients of the deterministic trend in the measurement equation
23%
24
25% Copyright (C) 2015-2017 Dynare Team
26%
27% This file is part of Dynare.
28%
29% Dynare is free software: you can redistribute it and/or modify
30% it under the terms of the GNU General Public License as published by
31% the Free Software Foundation, either version 3 of the License, or
32% (at your option) any later version.
33%
34% Dynare is distributed in the hope that it will be useful,
35% but WITHOUT ANY WARRANTY; without even the implied warranty of
36% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37% GNU General Public License for more details.
38%
39% You should have received a copy of the GNU General Public License
40% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
41
42par_vector(parameterindices,:)=optpar; %reassemble parameter
43[fval,info,exit_flag,DLIK,Hess,SteadyState,trend_coeff] = feval(TargetFun,par_vector,varargin{:}); %call target function
44