Home > matlab > set_shocks.m

set_shocks

PURPOSE ^

function set_shocks(flag,k,ivar,values)

SYNOPSIS ^

function set_shocks(flag,k,ivar,values)

DESCRIPTION ^

 function set_shocks(flag,k,ivar,values)
 writes a deterministic shock into exo_simul or exo_det_simul

 INPUTS
    flag=0:    replaces exo_simul  
    flag=1:    multiplicative shock into exo_simul
    flag=2:    replaces exo_det_simul
    flag=3:    multipliczative shock into exo_det_simul
    k:         period
    ivar:      indice of exogenous variables
    values:    shock values

 OUTPUTS
    none
        
 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function set_shocks(flag,k,ivar,values)
0002 
0003 % function set_shocks(flag,k,ivar,values)
0004 % writes a deterministic shock into exo_simul or exo_det_simul
0005 %
0006 % INPUTS
0007 %    flag=0:    replaces exo_simul
0008 %    flag=1:    multiplicative shock into exo_simul
0009 %    flag=2:    replaces exo_det_simul
0010 %    flag=3:    multipliczative shock into exo_det_simul
0011 %    k:         period
0012 %    ivar:      indice of exogenous variables
0013 %    values:    shock values
0014 %
0015 % OUTPUTS
0016 %    none
0017 %
0018 % SPECIAL REQUIREMENTS
0019 %    none
0020 
0021 % Copyright (C) 2003-2011 Dynare Team
0022 %
0023 % This file is part of Dynare.
0024 %
0025 % Dynare is free software: you can redistribute it and/or modify
0026 % it under the terms of the GNU General Public License as published by
0027 % the Free Software Foundation, either version 3 of the License, or
0028 % (at your option) any later version.
0029 %
0030 % Dynare is distributed in the hope that it will be useful,
0031 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0032 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0033 % GNU General Public License for more details.
0034 %
0035 % You should have received a copy of the GNU General Public License
0036 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0037 
0038 global oo_ M_
0039 
0040 k = k + M_.maximum_lag;
0041 n1 = size(oo_.exo_simul,1);
0042 n2 = size(oo_.exo_det_simul,1);
0043 if k(end) > n1 && flag <= 1
0044     oo_.exo_simul = [oo_.exo_simul; repmat(oo_.exo_steady_state',k(end)-n1,1)];
0045 elseif k(end) > n2 && flag > 1
0046     oo_.exo_det_simul = [oo_.exo_det_simul; repmat(oo_.exo_det_steady_state',k(end)-n2,1)];
0047 end
0048 
0049 switch flag
0050   case 0
0051     if size(values,1) == 1
0052         oo_.exo_simul(k,ivar) = repmat(values,length(k),1);
0053     else
0054         oo_.exo_simul(k,ivar) = values;
0055     end
0056   case 1
0057     oo_.exo_simul(k,ivar) = oo_.exo_simul(k,ivar).*values;
0058   case 2
0059     if size(values,1) == 1
0060         oo_.exo_det_simul(k,ivar) = repmat(values,length(k),1);
0061     else
0062         oo_.exo_det_simul(k,ivar) = values;
0063     end
0064   case 3
0065     oo_.exo_det_simul(k,ivar) = oo_.exo_det_simul(k,ivar).*values;
0066 end
0067

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