Home > matlab > partial_information > dr1_PI.m

dr1_PI

PURPOSE ^

function [dr,info,M_,options_,oo_] = dr1_PI(dr,task,M_,options_,oo_)

SYNOPSIS ^

function [dr,info,M_,options_,oo_] = dr1_PI(dr,task,M_,options_,oo_)

DESCRIPTION ^

 function [dr,info,M_,options_,oo_] = dr1_PI(dr,task,M_,options_,oo_)
 Computes the reduced form solution of a rational expectation model first
 order
 approximation of the Partial Information stochastic model solver around the deterministic steady state).
 Prepares System as
        A0*E_t[y(t+1])+A1*y(t)=A2*y(t-1)+c+psi*eps(t)
 with z an exogenous variable process.
 and calls PI_Gensys.m solver 
 based on Pearlman et al 1986 paper and derived from
 C.Sims' gensys linear solver.
 to return solution in format
       [s(t)' x(t)' E_t x(t+1)']'=G1pi [s(t-1)' x(t-1)' x(t)]'+C+impact*eps(t),

 INPUTS
   dr         [matlab structure] Decision rules for stochastic simulations.
   task       [integer]          if task = 0 then dr1 computes decision rules.
                                 if task = 1 then dr1 computes eigenvalues.
   M_         [matlab structure] Definition of the model.           
   options_   [matlab structure] Global options.
   oo_        [matlab structure] Results 
    
 OUTPUTS
   dr         [matlab structure] Decision rules for stochastic simulations.
   info       [integer]          info=1: the model doesn't define current variables uniquely
                                 info=2: problem in mjdgges.dll info(2) contains error code. 
                                 info=3: BK order condition not satisfied info(2) contains "distance"
                                         absence of stable trajectory.
                                 info=4: BK order condition not satisfied info(2) contains "distance"
                                         indeterminacy.
                                 info=5: BK rank condition not satisfied.
   M_         [matlab structure]            
   options_   [matlab structure]
   oo_        [matlab structure]
  
 ALGORITHM
   ...
    
 SPECIAL REQUIREMENTS
   none.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [dr,info,M_,options_,oo_] = dr1_PI(dr,task,M_,options_,oo_)
0002 % function [dr,info,M_,options_,oo_] = dr1_PI(dr,task,M_,options_,oo_)
0003 % Computes the reduced form solution of a rational expectation model first
0004 % order
0005 % approximation of the Partial Information stochastic model solver around the deterministic steady state).
0006 % Prepares System as
0007 %        A0*E_t[y(t+1])+A1*y(t)=A2*y(t-1)+c+psi*eps(t)
0008 % with z an exogenous variable process.
0009 % and calls PI_Gensys.m solver
0010 % based on Pearlman et al 1986 paper and derived from
0011 % C.Sims' gensys linear solver.
0012 % to return solution in format
0013 %       [s(t)' x(t)' E_t x(t+1)']'=G1pi [s(t-1)' x(t-1)' x(t)]'+C+impact*eps(t),
0014 %
0015 % INPUTS
0016 %   dr         [matlab structure] Decision rules for stochastic simulations.
0017 %   task       [integer]          if task = 0 then dr1 computes decision rules.
0018 %                                 if task = 1 then dr1 computes eigenvalues.
0019 %   M_         [matlab structure] Definition of the model.
0020 %   options_   [matlab structure] Global options.
0021 %   oo_        [matlab structure] Results
0022 %
0023 % OUTPUTS
0024 %   dr         [matlab structure] Decision rules for stochastic simulations.
0025 %   info       [integer]          info=1: the model doesn't define current variables uniquely
0026 %                                 info=2: problem in mjdgges.dll info(2) contains error code.
0027 %                                 info=3: BK order condition not satisfied info(2) contains "distance"
0028 %                                         absence of stable trajectory.
0029 %                                 info=4: BK order condition not satisfied info(2) contains "distance"
0030 %                                         indeterminacy.
0031 %                                 info=5: BK rank condition not satisfied.
0032 %   M_         [matlab structure]
0033 %   options_   [matlab structure]
0034 %   oo_        [matlab structure]
0035 %
0036 % ALGORITHM
0037 %   ...
0038 %
0039 % SPECIAL REQUIREMENTS
0040 %   none.
0041 %
0042 
0043 % Copyright (C) 1996-2012 Dynare Team
0044 %
0045 % This file is part of Dynare.
0046 %
0047 % Dynare is free software: you can redistribute it and/or modify
0048 % it under the terms of the GNU General Public License as published by
0049 % the Free Software Foundation, either version 3 of the License, or
0050 % (at your option) any later version.
0051 %
0052 % Dynare is distributed in the hope that it will be useful,
0053 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0054 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0055 % GNU General Public License for more details.
0056 %
0057 % You should have received a copy of the GNU General Public License
0058 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0059 
0060 global lq_instruments;
0061 info = 0;
0062 
0063 options_ = set_default_option(options_,'qz_criterium',1.000001);
0064 
0065 xlen = M_.maximum_endo_lead + M_.maximum_endo_lag + 1;
0066 
0067 if (options_.aim_solver == 1)
0068     options_.aim_solver == 0;
0069     warning('You can not use AIM with Part Info solver. AIM ignored'); 
0070 end
0071 if (options_.order > 1) 
0072     warning('You can not use order higher than 1 with Part Info solver. Order 1 assumed');
0073     options_.order =1;
0074 end
0075 
0076 % expanding system for Optimal Linear Regulator
0077 if options_.ramsey_policy && options_.ACES_solver == 0
0078     if isfield(M_,'orig_model')
0079         orig_model = M_.orig_model;
0080         M_.endo_nbr = orig_model.endo_nbr;
0081         M_.endo_names = orig_model.endo_names;
0082         M_.lead_lag_incidence = orig_model.lead_lag_incidence;
0083         M_.maximum_lead = orig_model.maximum_lead;
0084         M_.maximum_endo_lead = orig_model.maximum_endo_lead;
0085         M_.maximum_lag = orig_model.maximum_lag;
0086         M_.maximum_endo_lag = orig_model.maximum_endo_lag;
0087     end
0088     old_solve_algo = options_.solve_algo;
0089     %  options_.solve_algo = 1;
0090     oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,0,M_,options_,oo_,it_);
0091     options_.solve_algo = old_solve_algo;
0092     [junk,junk,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
0093     [jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_);
0094     klen = M_.maximum_lag + M_.maximum_lead + 1;
0095     dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar];
0096 else
0097     klen = M_.maximum_lag + M_.maximum_lead + 1;
0098     iyv = M_.lead_lag_incidence';
0099     iyv = iyv(:);
0100     iyr0 = find(iyv) ;
0101     it_ = M_.maximum_lag + 1 ;
0102     
0103     if M_.exo_nbr == 0
0104         oo_.exo_steady_state = [] ;
0105     end
0106     
0107 
0108     if options_.ACES_solver == 1
0109         sim_ruleids=[];
0110         tct_ruleids=[];
0111         if  size(M_.equations_tags,1)>0  % there are tagged equations, check if they are aceslq rules
0112             for teq=1:size(M_.equations_tags,1)
0113                 if strcmp(M_.equations_tags(teq,3),'aceslq_sim_rule')
0114                     sim_ruleids=[sim_ruleids cell2mat(M_.equations_tags(teq,1))]
0115                 end
0116                 if strcmp(M_.equations_tags(teq,3),'aceslq_tct_rule')
0117                     tct_ruleids=[tct_ruleids cell2mat(M_.equations_tags(teq,1))]
0118                 end
0119             end
0120         end
0121         lq_instruments.sim_ruleids=sim_ruleids;
0122         lq_instruments.tct_ruleids=tct_ruleids;
0123         %if isfield(lq_instruments,'xsopt_SS') %% changed by BY
0124         [junk, lq_instruments.xsopt_SS,lq_instruments.lmopt_SS,s2,check] = opt_steady_get;%% changed by BY
0125         [qc, DYN_Q] = QPsolve(lq_instruments, s2, check); %% added by BY
0126         z = repmat(lq_instruments.xsopt_SS,1,klen);
0127     else
0128         z = repmat(dr.ys,1,klen);
0129     end
0130     z = z(iyr0) ;
0131     [junk,jacobia_] = feval([M_.fname '_dynamic'],z,[oo_.exo_simul ...
0132                         oo_.exo_det_simul], M_.params, dr.ys, it_);
0133 
0134     if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 )
0135         if length(sim_ruleids)>0
0136             sim_rule=jacobia_(sim_ruleids,:);
0137             % uses the subdirectory - BY
0138             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_sim_rule.txt'], 'sim_rule', '-ascii', '-double', '-tabs');
0139         end
0140         if length(tct_ruleids)>0
0141             tct_rule=jacobia_(tct_ruleids,:);
0142             % uses the subdirectory - BY
0143             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_tct_rule.txt'], 'tct_rule', '-ascii', '-double', '-tabs');
0144         end
0145         aces_ruleids=union(tct_ruleids,sim_ruleids);
0146         j_size=size(jacobia_,1);
0147         j_rows=1:j_size;
0148         j_rows = setxor(j_rows,aces_ruleids);
0149         jacobia_=jacobia_(j_rows ,:);
0150     end
0151 
0152 end
0153 
0154 if options_.debug
0155     save([M_.fname '_debug.mat'],'jacobia_')
0156 end
0157 
0158 dr=set_state_space(dr,M_);
0159 kstate = dr.kstate;
0160 kad = dr.kad;
0161 kae = dr.kae;
0162 nstatic = dr.nstatic;
0163 nfwrd = dr.nfwrd;
0164 npred = dr.npred;
0165 nboth = dr.nboth;
0166 order_var = dr.order_var;
0167 nd = size(kstate,1);
0168 nz = nnz(M_.lead_lag_incidence);
0169 
0170 sdyn = M_.endo_nbr - nstatic;
0171 
0172 k0 = M_.lead_lag_incidence(M_.maximum_endo_lag+1,order_var);
0173 k1 = M_.lead_lag_incidence(find([1:klen] ~= M_.maximum_endo_lag+1),:);
0174 
0175 if (options_.aim_solver == 1) 
0176     error('Anderson and Moore AIM solver is not compatible with Partial Information models');
0177 end % end if useAIM and...
0178 
0179     % If required, try PCL86 solver, that is, if not the check being
0180     % performed only and if it is 1st order
0181     % create sparse, extended jacobia AA:
0182     nendo=M_.endo_nbr; % = size(aa,1)
0183     
0184 
0185     if(options_.ACES_solver==1)
0186         %if ~isfield(lq_instruments,'names')
0187         if isfield(options_,'instruments')
0188             lq_instruments.names=options_.instruments;
0189         end
0190         %end
0191         if isfield(lq_instruments,'names')
0192             num_inst=size(lq_instruments.names,1);
0193             if ~isfield(lq_instruments,'inst_var_indices') && num_inst>0
0194                 for i=1:num_inst
0195                     i_tmp = strmatch(deblank(lq_instruments.names(i,:)),M_.endo_names,'exact');
0196                     if isempty(i_tmp)
0197                         error (['One of the specified instrument variables does not exist']) ;
0198                     else
0199                         i_var(i) = i_tmp;
0200                     end
0201                 end
0202                 lq_instruments.inst_var_indices=i_var;
0203             elseif size(lq_instruments.inst_var_indices)>0
0204                 i_var=lq_instruments.inst_var_indices;
0205                 if ~num_inst
0206                     num_inst=size(lq_instruments.inst_var_indices);
0207                 end
0208             else
0209                 i_var=[];
0210                 num_inst=0;
0211             end
0212             if size(i_var,2)>0 && size(i_var,2)==num_inst
0213                 m_var=zeros(nendo,1);
0214                 for i=1:nendo
0215                     if isempty(find(i_var==i))
0216                         m_var(i)=i;
0217                     end
0218                 end
0219                 m_var=nonzeros(m_var);
0220                 lq_instruments.m_var=m_var;
0221             else
0222                 error('WARNING: There are no instrumnets for ACES!');
0223             end
0224         else %if(options_.ACES_solver==1)
0225             error('WARNING: There are no instrumnets for ACES!');
0226         end
0227     end
0228 
0229     % find size xlen of the state vector Y and of A0, A1 and A2 transition matrices:
0230     % it is the sum the all i variables's lag/lead representations,
0231     % for each variable i representation being defined as:
0232     % Max (i_lags-1,0)+ Max (i_leads-1,0)+1
0233     % so that if variable x appears with 2 lags and 1 lead, and z
0234     % with 2 lags and 3 leads, the size of the state space is:
0235     % 1+0+1   +   1+2+1   =6
0236     % e.g. E_t Y(t+1)=
0237     %     E_t x(t)
0238     %     E_t x(t+1)
0239     %     E_t z(t)
0240     %     E_t z(t+1)
0241     %     E_t z(t+2)
0242     %     E_t z(t+3)
0243     
0244     % partition jacobian:
0245     jlen=dr.nspred+dr.nsfwrd+M_.endo_nbr+M_.exo_nbr; % length of jacobian
0246     PSI=-jacobia_(:, jlen-M_.exo_nbr+1:end); % exog
0247                                              % first transpose M_.lead_lag_incidence';
0248     lead_lag=M_.lead_lag_incidence';
0249     max_lead_lag=zeros(nendo,2); % lead/lag representation in Y for each endogenous variable i
0250     if ( M_.maximum_lag <= 1) && (M_.maximum_lead <= 1)
0251         xlen=size(jacobia_,1);%nendo;
0252         AA0=zeros(xlen,xlen);  % empty A0
0253         AA2=AA0; % empty A2 and A3
0254         AA3=AA0;
0255         if xlen==nendo % && M_.maximum_lag <=1 && M_.maximum_lead <=1 % apply a shortcut
0256             AA1=jacobia_(:,npred+1:npred+nendo); 
0257             if M_.maximum_lead ==1
0258                 fnd = find(lead_lag(:,M_.maximum_lag+2));
0259                 AA0(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,M_.maximum_lag+2))); %forwd jacobian
0260             end
0261             if npred>0 && M_.maximum_lag ==1  
0262                 fnd = find(lead_lag(:,1));
0263                 AA2(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,1))); %backward
0264             end
0265         elseif options_.ACES_solver==1 % more endo vars than equations in jacobia_
0266         if nendo-xlen==num_inst
0267             PSI=[PSI;zeros(num_inst, M_.exo_nbr)];
0268             % AA1 contemporary
0269             AA_all=jacobia_(:,npred+1:npred+nendo); 
0270             AA1=AA_all(:,lq_instruments.m_var); % endo without instruments
0271             lq_instruments.ij1=AA_all(:,lq_instruments.inst_var_indices); %  instruments only
0272             lq_instruments.B1=-[lq_instruments.ij1; eye(num_inst)];
0273             AA1=[AA1, zeros(xlen,num_inst); zeros(num_inst,xlen), eye(num_inst)];
0274             %PSI=[PSI; zeros(num_inst,M_.exo_nbr)];
0275             if M_.maximum_lead ==1 % AA0 forward looking
0276                 AA_all(:,:)=0.0;
0277                 fnd = find(lead_lag(:,M_.maximum_lag+2));
0278                 AA_all(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,M_.maximum_lag+2))); %forwd jacobian
0279                 AA0=AA_all(:,lq_instruments.m_var);
0280                 lq_instruments.ij0=AA_all(:,lq_instruments.inst_var_indices); %  instruments only
0281                 lq_instruments.B0=[lq_instruments.ij0; eye(num_inst)];
0282                 AA0=[AA0, zeros(xlen,num_inst); zeros(num_inst,xlen+num_inst)];
0283             end
0284             if npred>0 && M_.maximum_lag ==1  
0285                 AA_all(:,:)=0.0;
0286                 fnd = find(lead_lag(:,1));
0287                 AA_all(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,1))); %backward
0288                 AA2=AA_all(:,lq_instruments.m_var);
0289                 lq_instruments.ij2=AA_all(:,lq_instruments.inst_var_indices); %  instruments only
0290                 lq_instruments.B2=[lq_instruments.ij2; eye(num_inst)];
0291                 AA2=[AA2, lq_instruments.ij2 ; zeros(num_inst,xlen+num_inst)];
0292             end
0293         else
0294             error('ACES number of instruments does match');
0295         end
0296         else
0297             error('More than one lead or lag in the jabian');
0298         end
0299         if M_.orig_endo_nbr<nendo
0300             % findif there are any expecatations at time t
0301             exp_0= strmatch('AUX_EXPECT_LEAD_0_', M_.endo_names);
0302             num_exp_0=size(exp_0,1);
0303             if num_exp_0>0
0304                 AA3(:,exp_0)=AA1(:,exp_0);
0305                 XX0=zeros(nendo,num_exp_0);
0306                 AA1(:,exp_0)=XX0(:,[1:num_exp_0])
0307             end
0308         end
0309     end
0310     PSI=-[[zeros(xlen-nendo,M_.exo_nbr)];[jacobia_(:, jlen-M_.exo_nbr+1:end)]]; % exog
0311     cc=0;
0312     NX=M_.exo_nbr; % no of exogenous varexo shock variables.
0313     NETA=nfwrd+nboth; % total no of exp. errors  set to no of forward looking equations
0314     FL_RANK=rank(AA0); % nfwrd+nboth; % min total no of forward looking equations and vars
0315     
0316     try
0317         % call [G1pi,C,impact,nmat,TT1,TT2,gev,eu]=PI_gensys(a0,a1,a2,c,PSI,NX,NETA,NO_FL_EQS)
0318         % System given as
0319         %        a0*E_t[y(t+1])+a1*y(t)=a2*y(t-1)+c+psi*eps(t)
0320         % with eps an exogenous variable process.
0321         % Returned system is
0322         %       [s(t)' x(t)' E_t x(t+1)']'=G1pi [s(t-1)' x(t-1)' x(t)]'+C+impact*eps(t),
0323         %  and (a) the matrix nmat satisfying   nmat*E_t z(t)+ E_t x(t+1)=0
0324         %      (b) matrices TT1, TT2  that relate y(t) to these states:
0325         %      y(t)=[TT1 TT2][s(t)' x(t)']'.
0326 
0327         if(options_.ACES_solver==1)
0328             if isfield(lq_instruments,'xsopt_SS')
0329                 SSbar= diag([lq_instruments.xsopt_SS(m_var)]);% lq_instruments.xsopt_SS(lq_instruments.inst_var_indices)]);
0330                 insSSbar=repmat(lq_instruments.xsopt_SS(lq_instruments.inst_var_indices)',nendo-num_inst,1);
0331             else
0332                 SSbar= diag([dr.ys(m_var)]);%; dr.ys(lq_instruments.inst_var_indices)]);%(oo_.steady_state);
0333                 insSSbar=repmat(dr.ys(lq_instruments.inst_var_indices)',nendo-num_inst,1);
0334             end
0335             SSbar=diag([diag(SSbar);diag(eye(num_inst))]);
0336             insSSbar=[insSSbar;diag(eye(num_inst))];
0337 
0338             AA0=AA0*SSbar;
0339             AA1=AA1*SSbar;
0340             AA2=AA2*SSbar;
0341             lq_instruments.B1=(lq_instruments.B1).*insSSbar;
0342         end
0343         %% for expectational models when complete
0344         if any(AA3)
0345             AA3=AA3*SSbar;
0346             [G1pi,CC,impact,nmat,TT1,TT2,gev,eu, DD, E2,E5, GAMMA, FL_RANK]=PI_gensysEXP(AA0,AA1,-AA2,AA3,cc,PSI,NX,NETA,FL_RANK, M_, options_);
0347         else
0348             [G1pi,CC,impact,nmat,TT1,TT2,gev,eu, DD, E2,E5, GAMMA, FL_RANK]=PI_gensys(AA0,AA1,-AA2,AA3,cc,PSI,NX,NETA,FL_RANK, M_, options_);
0349         end
0350 
0351         % reuse some of the bypassed code and tests that may be needed
0352         if (eu(1) ~= 1 || eu(2) ~= 1) && options_.ACES_solver==0
0353             info(1) = abs(eu(1)+eu(2));
0354             info(2) = 1.0e+8;
0355             %     return
0356         end
0357         
0358         dr.PI_ghx=G1pi;
0359         dr.PI_ghu=impact;
0360         dr.PI_TT1=TT1;
0361         dr.PI_TT2=TT2;
0362         dr.PI_nmat=nmat;
0363         dr.PI_CC=CC;
0364         dr.PI_gev=gev;
0365         dr.PI_eu=eu;
0366         dr.PI_FL_RANK=FL_RANK;
0367         %dr.ys=zeros(nendo); % zero steady state
0368         dr.ghx=G1pi;
0369         dr.ghu=impact;
0370         dr.eigval = eig(G1pi);
0371         dr.rank=FL_RANK;
0372         
0373         if options_.ACES_solver==1
0374             betap=options_.planner_discount;
0375             sigma_cov=M_.Sigma_e;
0376             % get W - BY
0377             W=(1-betap)*GAMMA'*DYN_Q*GAMMA;
0378             %W=[0]
0379             ACES.A=G1pi;
0380             ACES.C=impact; % (:,1);
0381             ACES.D=DD; %=impact (:,20);
0382             ACES.E2=E2;
0383             ACES.E5=E5;
0384             ACES.GAMMA=GAMMA;
0385             ACES_M=size(G1pi,2)-FL_RANK;
0386             ACES_NM=FL_RANK;
0387             ACES.M=ACES_M;
0388             ACES.NM=FL_RANK;
0389             % added by BY
0390             ACES.Q=DYN_Q;
0391             ACES.W=W;
0392             NY=nendo-num_inst;
0393             
0394             % save the followings in a subdirectory - BY
0395             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_Matrices'], 'ACES');
0396             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_GAMMA'], 'GAMMA');
0397             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_A.txt'], 'G1pi', '-ascii', '-double', '-tabs');
0398             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_C.txt'], 'impact','-ascii', '-double', '-tabs');
0399             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_D.txt'], 'DD', '-ascii', '-double', '-tabs');
0400             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_E2.txt'], 'E2', '-ascii', '-double', '-tabs');
0401             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_E5.txt'], 'E5', '-ascii', '-double', '-tabs');
0402             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_GAMMA.txt'], 'GAMMA', '-ascii', '-double', '-tabs');
0403             %save ([M_.fname '_ACESLQ_M.txt'], 'ACES_M', '-ascii', '-tabs');
0404             %save ([M_.fname '_ACESLQ_NM.txt'], 'ACES_NM', '-ascii', '-tabs');
0405             %save ([M_.fname '_ACESLQ_betap.txt'], 'betap', '-ascii', '-tabs');
0406             %save ([M_.fname '_ACESLQ_NI.txt'], 'num_inst', '-ascii', '-tabs');
0407             %save ([M_.fname '_ACESLQ_ND.txt'], 'NX', '-ascii', '-tabs');
0408             %save ([M_.fname '_ACESLQ_NY.txt'], 'NY', '-ascii', '-tabs');
0409             ACES_VARS=M_.endo_names;
0410             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_VARS.txt'], 'ACES_VARS', '-ascii', '-tabs');
0411             % added by BY
0412             % save the char array ACES_VARS into .txt as it is
0413             fid = fopen(strcat(ACES_DirectoryName,'/',M_.fname,'_ACESLQ_VARnames.txt'),'wt');
0414             ACES_VARS =[ACES_VARS repmat(sprintf('\n'),size(ACES_VARS,1),1)];
0415             fwrite(fid,ACES_VARS.');
0416             fclose(fid);
0417             % save as integers
0418             fid = fopen(strcat(ACES_DirectoryName,'/',M_.fname,'_ACESLQ_M.txt'),'wt');
0419             fprintf(fid,'%d\n',ACES_M);
0420             fclose(fid);
0421             fid = fopen(strcat(ACES_DirectoryName,'/',M_.fname,'_ACESLQ_NM.txt'),'wt');
0422             fprintf(fid,'%d\n',ACES_NM);
0423             fclose(fid);
0424             fid = fopen(strcat(ACES_DirectoryName,'/',M_.fname,'_ACESLQ_betap.txt'),'wt');
0425             fprintf(fid,'%d\n',betap);
0426             fclose(fid);
0427             fid = fopen(strcat(ACES_DirectoryName,'/',M_.fname,'_ACESLQ_NI.txt'),'wt');
0428             fprintf(fid,'%d\n',num_inst);
0429             fclose(fid);
0430             fid = fopen(strcat(ACES_DirectoryName,'/',M_.fname,'_ACESLQ_ND.txt'),'wt');
0431             fprintf(fid,'%d\n',NX);
0432             fclose(fid);
0433             fid = fopen(strcat(ACES_DirectoryName,'/',M_.fname,'_ACESLQ_NY.txt'),'wt');
0434             fprintf(fid,'%d\n',NY);
0435             fclose(fid);
0436             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_Q.txt'], 'DYN_Q', '-ascii', '-double', '-tabs');
0437             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_W.txt'], 'W', '-ascii', '-double', '-tabs');
0438             save ([ACES_DirectoryName,'/',M_.fname '_ACESLQ_SIGMAE.txt'], 'sigma_cov', '-ascii', '-double', '-tabs');
0439         end
0440 
0441     catch
0442         lerror=lasterror;
0443         if options_.ACES_solver==1
0444             disp('Problem with using Part Info ACES solver:');
0445             error(lerror.message);
0446         else
0447             disp('Problem with using Part Info solver');
0448             error(lerror.message);
0449         end
0450     end
0451 
0452     % TODO:
0453     % if options_.loglinear == 1
0454     % if exogenous deterministic variables
0455     
0456     return;

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