0001 function oo_.dr=osr1(params,weights)
0002 global M_ oo_ options_ it_
0003
0004 xlen = M_.maximum_lead + M_.maximum_lag + 1;
0005 klen = M_.maximum_lag + M_.maximum_lead + 1;
0006 iyv = M_.lead_lag_incidence';
0007 iyv = iyv(:);
0008 iyr0 = find(iyv) ;
0009 it_ = M_.maximum_lag + 1 ;
0010
0011
0012 if M_.exo_nbr == 0
0013 oo_.exo_steady_state = [] ;
0014 end
0015
0016 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
0017 error ('OLR: Error in model specification: some variables don"t appear as current') ;
0018 end
0019
0020 if M_.maximum_lead == 0
0021 error ('Backward or static model: no point in using OLR') ;
0022 end
0023
0024 if xlen > 1
0025 error (['OLR: stochastic exogenous variables must appear only at the' ...
0026 ' current period. Use additional endogenous variables']) ;
0027 end
0028
0029
0030 fh = str2func([M_.fname '_static']);
0031 if max(abs(feval(fh,oo_.steady_state))) > options_.dynatol
0032 [oo_.dr.ys, check] = dynare_solve([M_.fname '_static'],oo_.steady_state);
0033 if check
0034 error('OLR: convergence problem in DYNARE_SOLVE')
0035 end
0036 else
0037 oo_.dr.ys = oo_.steady_state;
0038 end
0039
0040
0041 np = size(params,1);
0042 t0 = zeros(np,1);
0043 for i=1:np
0044 t0(i)=evalin('base',[params(i,:) ';']);
0045 end
0046
0047 [p,f]=fminsearch(@osr_obj,t0,[],params,weights);
0048
0049 disp('')
0050 disp('OPTIMAL VALUE OF THE PARAMETERS:')
0051 disp('')
0052 for i=1:np
0053 disp(sprintf('%16s %16.6g\n',params(i,:),p(i)))
0054 end
0055 disp(sprintf('Objective function : %16.6g\n',f));
0056 disp(' ')
0057 oo_.dr=resol(oo_.steady_state,options_.dr_algo,options_.linear,options_.order);
0058
0059