%%% THIS FILE SOLVES THE RICCATI EQUATION PRESENTED %%% IN LECTURE THREE OF RECURSIVE MACROECONOMICS OF MARTIN ELLISON %-------------------------------------------------------------------------- %The central bank asigns equal weights on inflation and output deviations from %the target and a smaller weight on deviations in the interest rate from the %target. Objective is to minimise the present discounted value of expected %losses. %-------------------------------------------------------------------------- % DEFINE PARAMETERS %-------------------------------------------------------------------------- clear; beta=0.99; Q=zeros(1,1); R=zeros(2,2); A=zeros(2,2); B=zeros(2,1); Q(1,1)=0.1; R(1,1)=1; R(1,2)=0; R(2,1)=0; R(2,2)=1; A(1,1)=0.75; A(1,2)=0; A(2,1)=0; A(2,2)=0.25; B(1,1)=-0.5; B(2,1)=-0.5; d=1; D=0; I=0; i=0; P0=-0.000001*eye(2); format long %-------------------------------------------------------------------------- % ITERATE THE RICCATI EQUATION %-------------------------------------------------------------------------- while d>0.0000000001 P1=R+beta*A'*P0*A-(beta*A'*P0*B)*(inv(Q+beta*B'*P0*B))*(beta*B'*P0*A); Pd=P1-P0; d=max(abs(Pd)); d=max(d'); D=[D d]; P0=P1; i=i+1; I=[I i]; end P=P0; %-------------------------------------------------------------------------- % CALCULATE THE POLICY FUNCTION COEFFICIENTS AND DISPLAY RESULTS %-------------------------------------------------------------------------- F=-inv(Q+beta*B'*P*B)*(beta*B'*P*A); ID=[I(2:length(I))' D(2:length(I))']; disp(' i d'); disp(ID); disp(' SOLUTIONS'); disp('F'); disp(F); disp('P'); disp(P);