% S T A T E _ U S . M % ################### %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % SESTAVENI A OVERENI STAVOVEHO MODELU EKONOMIKY USA % % ************************************************** % % % % Restrukturovani kvantifikovaneho ekonometrickeho modlu zadaneho ve tvaru % % x_t = A0*x_t + A1*x_t-1 + B1*u_t + C1*z_t % % do tvaru maticoveho stavoveho modelu % % x_t = As*x_t-1 + B*u_t + C*z_t % % respektive do tvaru prirustkoveho maticoveho stavoveho modelu % % x_t - x_t-1 = A*x_t-1 + B*u_t + C*z_t % % % % Zpracoval: Osvald Vasicek KAMI ESF MU Brno % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% close all clear all %...data_us load data_us [N,N2]=size(USAMACRO); % Promenne ekonometrickeho modelu % ******************************* % CC, I, Y, G, M [ billons of 1982 dollars] % R [ percent per year ] % t [ quarter ] % % Cas (t) CC =USAMACRO(5:N,2); % real aggregate personal consumption I =USAMACRO(5:N,3); % real gross domestic investment Y =USAMACRO(5:N,5); % real GNP ( net of export and imports ) G =USAMACRO(5:N,6); % real government spending M =USAMACRO(5:N,7); % real money stock ( M1 ) R =USAMACRO(5:N,4); % interest rate on 3-month Treasury bills t =USAMACRO(5:N,1); % time % Cas (t_1) CC_1=USAMACRO(4:N-1,2); I_1 =USAMACRO(4:N-1,3); Y_1 =USAMACRO(4:N-1,5); G_1 =USAMACRO(4:N-1,6); M_1 =USAMACRO(4:N-1,7); R_1 =USAMACRO(4:N-1,4); % Cas (t-2) C_2 =USAMACRO(3:N-2,2); I_2 =USAMACRO(3:N-2,3); Y_2 =USAMACRO(3:N-2,5); G_2 =USAMACRO(3:N-2,6); M_2 =USAMACRO(3:N-2,7); R_2 =USAMACRO(3:N-2,4); % Cas (t-3) R_3 =USAMACRO(2:N-3,4); % Cas (t-4) R_4 =USAMACRO(1:N-4,4); % 1.diference v case (t) d_C =USAMACRO(5:N,2)-USAMACRO(4:N-1,2); d_I =USAMACRO(5:N,3)-USAMACRO(4:N-1,3); d_R =USAMACRO(5:N,4)-USAMACRO(4:N-1,4); d_Y =USAMACRO(5:N,5)-USAMACRO(4:N-1,5); d_G =USAMACRO(5:N,6)-USAMACRO(4:N-1,6); d_M =USAMACRO(5:N,7)-USAMACRO(4:N-1,7); % 1.diference v case (t-1) d_C_1 =USAMACRO(4:N-1,2)-USAMACRO(3:N-2,2); d_I_1 =USAMACRO(4:N-1,3)-USAMACRO(3:N-2,3); d_R_1 =USAMACRO(4:N-1,4)-USAMACRO(3:N-2,4); d_Y_1 =USAMACRO(4:N-1,5)-USAMACRO(3:N-2,5); d_G_1 =USAMACRO(4:N-1,6)-USAMACRO(3:N-2,6); d_M_1 =USAMACRO(4:N-1,7)-USAMACRO(3:N-2,7); % Vektor jednicek pro urovnovou konstantu const=ones(size(G)); % P a r a m e t r y m o d e l u % ******************************* % Parametry ( odhadnuty metodou nejmensich ctvercu tzv. " O L S " ) % % C_t = c0 + c1*Y_t + c2*C_t-1 % __________________________________________________________ c0 = -9.4540; c1 = 0.05410; c2 = 0.9260; % (-2.01) (3.21) (36.73) % R2 = 0.999 s = 11.23 DW = 1.57 Durbin h = 2.69 % % I_t = i0 + i1*(Y_t-1 - Y_t-2) + i2*Y_t + i3*R_t-4 % __________________________________________________________ i0 = -66.1950; i1 = 0.16840; i2 = 0.2181; i3 = -11.2650; % (-8.12) (2.18) (38.53) (-9.20) % R2 = 0.968 s = 23.864 DW = 0.55 % % R_t = r0 + r1*Y_t + r2*(Y_t - Y_t-1) + r3*(M_t - M_t-1) + r4*(R_t-1 + R_t-2) % _____________________________________________________________________________ r0 = -0.5561; r1 = 0.00051; r2 = 0.0135; r3 = -0.0853; r4 = 0.4259; % (-1.853) (2.24) (4.32) (-5.75) (16.73) % R2 = 0.934 s = 0.854 DW = 1.37 Durbin h = 3.99 % 1. E k o n o m e t r i c k e r o v n i c e - strukturni tvar % ***************************************************************** C_e = c0 + c1*Y + c2*CC_1; I_e = i0 + i1*(Y_1 - Y_2) + i2*Y + i3*R_4; R_e = r0 + r1*Y + r2*(Y - Y_1) + r3*d_M + r4*(R_1 + R_2); Y_e = CC + I + G; % % 2. M a t i c o v y e k o n o m e t r i c k y m o d e l % x_t = A0*x_t + A1*x_t-1 + B1*u_t + C1*z_t % *********************************************************** % Exogenni, vstupni, stavovy vektor a pocatecni podminka % ------------------------------------------------------ % Koncovy krok modelu Nf=length(G); % tj. I.Q / 1988 % Pocatecni krok modelu Ns=9; % tj. I.Q / 1950 % Delka modelovaneho intervalu Nr=length((Ns:Nf)'); % Kalendarni cas modelovaneho intervalu t_e=t(Ns:Nf); % Exogenni vektor z_t % 1 z= [const(Ns:Nf)]; % Ridici vektor u_t % 1 2 u= [G(Ns:Nf) d_M(Ns:Nf)]; % Stavovy vektor x_t % 1 2 3 4 % 5 6 7 8 x= [CC(Ns:Nf) I(Ns:Nf) R(Ns:Nf) Y(Ns:Nf)... R_1(Ns:Nf) Y_1(Ns:Nf) R_2(Ns:Nf) R_3(Ns:Nf)]; % Zpozdeny stavovy vektor x_t-1 % 1 2 3 4 % 5 6 7 8 x_1= [CC_1(Ns:Nf) I_1(Ns:Nf) R_1(Ns:Nf) Y_1(Ns:Nf)... R_2(Ns:Nf) Y_2(Ns:Nf) R_3(Ns:Nf) R_4(Ns:Nf)]; % Pocatecni podminka x0 % 1 2 3 4 5 6 7 8 x0=[CC(Ns) I(Ns) R(Ns) Y(Ns) R_1(Ns) Y_1(Ns) R_2(Ns) R_3(Ns)]; % Matice parametru ekonometrickeho modelu A0, A1, B1, C1 % ------------------------------------------------------ % M a t i c e A0 (parametry endogennich promennych/ s t a v u) % 1 2 3 4 5 6 7 8 % CC I R Y R_1 Y_1 R_2 R_3 % ______________________________________________ A0=[ 0 0 0 c1 0 0 0 0 % 1 CC 0 0 0 i2 0 0 0 0 % 2 I 0 0 0 (r1+r2) 0 0 0 0 % 3 R 1 1 0 0 0 0 0 0 % 4 Y 0 0 0 0 0 0 0 0 % 5 R_1 0 0 0 0 0 0 0 0 % 6 Y_1 0 0 0 0 0 0 0 0 % 7 R_2 0 0 0 0 0 0 0 0 ];% 8 R_3 % M a t i c e A1 ( param.zpozd.endg.prom./ z p o z d .s t a v u) % 1 2 3 4 5 6 7 8 % CC_1 I_1 R_1 Y_1 R_2 Y_2 R_3 R_4 % ______________________________________________ A1=[ c2 0 0 0 0 0 0 0 % 1 CC 0 0 0 i1 0 -i1 0 i3 % 2 I 0 0 r4 -r2 r4 0 0 0 % 3 R 0 0 0 0 0 0 0 0 % 4 Y 0 0 1 0 0 0 0 0 % 5 R_1 0 0 0 1 0 0 0 0 % 6 Y_1 0 0 0 0 1 0 0 0 % 7 R_2 0 0 0 0 0 0 1 0 ];% 8 R_3 % M a t i c e B1 ( param.autonomnich exogennich prom./ r i z e n i) % 1 2 % G d_M % _________ B1=[ 0 0 % 1 CC 0 0 % 2 I 0 r3 % 3 R 1 0 % 4 Y 0 0 % 5 R_1 0 0 % 6 Y_1 0 0 % 7 R_2 0 0 ];% 8 R_3 % M a t i c e C1 ( param.ryze ex.prom./ n e r i z e n y c h v s t.) % 1 % const % _____ C1=[ c0 % 1 CC i0 % 2 I r0 % 3 R 0 % 4 Y 0 % 5 R_1 0 % 6 Y_1 0 % 7 R_2 0 ];% 8 R_3 % M a t i c o v y e k o n o m e t r i c k y m o d e l % ------------------------------------------------------- n=8; % rozmer endogenniho / stavoveho vektoru x_t r=2; % rozmer autonomniho exogenniho / ridiciho vektoru u_t s=1; % rozmer ryze exogeniho / nerizeneho vstupniho vektoru z_t % Pocatecni podminka x_e(1,1:n)= x0; % Maticovy ekonometricky model for t = 2 : Nr, disp('t_e ='); disp(t); x_e(t,1:n)=[A0*x(t,1:n)'+A1*x(t-1,1:n)'+B1*u(t,1:r)'+C1*z(t,1:s)']'; end % 3. M a t i c o v y s t a v o v y m o d e l % x_t = As*x_t-1 + B*u_t + C*z_t % ********************************************** % Jednotkova diagonalni matice Io = eye(n); % Matice parametru ekonometrickeho modelu A, B, C % ----------------------------------------------- % M a t i c e As ( parametry zpozdenych s t a v u x_t-1 ) As = [(Io - A0)^(-1)]*A1; % M a t i c e B ( parametry r i z e n y c h v s t u p u u_t ) B = [(Io - A0)^(-1)]*B1; % M a t i c e C ( parametry e x o g e n. v s t u p u z_t ) C = [(Io - A0)^(-1)]*C1; % M a t i c o v y s t a v o v y m o d e l % ------------------------------------------- % Pocatecni podminka x_s(1,1:n)= x0; for t = 2 : Nr, disp('t_s ='); disp(t); x_s(t,1:n)=[As*x_s(t-1,1:n)'+B*u(t,1:r)'+C*z(t,1:s)']'; end % 4. D i f e r e n c n i m a t i c o v y s t a v o v y m o d e l % x_t - x_t-1 = As*x_t-1 + B*u_t + C*z_t % **************************************** % M a t i c e A ( parametry zpozdenych s t a v u x_t-1 ) A = As -Io; % D i f e r e n c n i m a t i c o v y s t a v o v y m o d e l % ---------------------------------------------------------------- % Pocatecni podminka x_ss(1,1:n)= x0; for t = 2 : Nr, disp('t_ss ='); disp(t); d_x_ss(t,1:n)=[A*x_ss(t-1,1:n)'+B*u(t,1:r)'+C*z(t,1:s)']'; x_ss(t,1:n)=x_ss(t-1,1:n) + d_x_ss(t,1:n); end disp(' '); disp(' '); disp(' Model rizeneho systemu pro " L Q O C " je pripraven !!!'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t=USAMACRO(5:N,1); UDAT=[G d_M]; ZDAT=[const]; XDAT=[CC I R Y CC_1 I_1 R_1 Y_1 Y_2 R_2 R_3]; PARAM=[A B C]; save state_us CC I R Y CC_1 I_1 R_1 Y_1 Y_2 R_2 R_3... G d_M... const t... UDAT ZDAT XDAT... A B C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t_s=t_e; figure(1) clf set(gcf,'Name',' C = real aggregate personal consumption'); hndl2=plot(USAMACRO(:,1),USAMACRO(:,2),'r.-'); set(hndl2,'LineWidth',0.5); hold on plot(t,C_e,'g+-'); hold on plot(t_e,x_e(:,1),'mx-'); hold on plot(t_s,x_s(:,1),'yo-'); hold on plot(t_s,x_ss(:,1),'c*-'); hold off title('Real Aggregate Personal Consumption'); legend('historical natural values','strctural econometric model',... 'matrix econometric model','matrix state model',... 'difference matrix state model'); ylabel('State x1(t) = C [ billions of 1982 dollars ]'); xlabel('Time [ quarter ]'); grid figure(2) clf set(gcf,'Name',' I = real gross domestic investment'); hndl3=plot(USAMACRO(:,1),USAMACRO(:,3),'r.-'); set(hndl3,'LineWidth',0.5); hold on plot(t,I_e,'g+-'); hold on plot(t_e,x_e(:,2),'mx-'); hold on plot(t_s,x_s(:,2),'yo-'); hold on plot(t_s,x_ss(:,2),'c*-'); hold off title('Real Gross Domestic Investment'); legend('historical natural values','strctural econometric model',... 'matrix econometric model','matrix state model',... 'difference matrix state model'); ylabel('State x2(t) = I [ billions of 1982 dollars ]'); xlabel('Time [ quarter ]'); grid figure(3) clf set(gcf,'Name',' R = interest rate on 3-month Treasury bills'); hndl4=plot(USAMACRO(:,1),USAMACRO(:,4),'r.-'); set(hndl4,'LineWidth',0.5); hold on plot(t,R_e,'g+-'); hold on plot(t_e,x_e(:,3),'mx-'); hold on plot(t_s,x_s(:,3),'yo-'); hold on plot(t_s,x_ss(:,3),'c*-'); hold off title('Interest Rate on 3-Month Treasury Bills'); legend('historical natural values','strctural econometric model',... 'matrix econometric model','matrix state model',... 'difference matrix state model'); ylabel('State x3(t) = R [ percent per year ]'); xlabel('Time [ quarter ]'); grid figure(4) clf set(gcf,'Name',' Y = real GNP (net of exports and imports)'); hndl5=plot(USAMACRO(:,1),USAMACRO(:,5),'r.-'); set(hndl5,'LineWidth',0.5); hold on plot(t,Y_e,'g+-'); hold on plot(t_e,x_e(:,4),'mx-'); hold on plot(t_s,x_s(:,4),'yo-'); hold on plot(t_s,x_ss(:,4),'c*-'); hold off title('Real GNP (net export and import)'); legend('historical natural values','strctural econometric model',... 'matrix econometric model','matrix state model',... 'difference matrix state model'); ylabel('State x4(t) = Y [ billions of 1982 dollars ]'); xlabel('Time [ quarter ]'); grid figure(5) clf set(gcf,'Name',' G = real government expending'); hndl6=plot(USAMACRO(:,1),USAMACRO(:,6),'r-'); set(hndl6,'LineWidth',0.5); hold off title('Real Gavernment Spending'); ylabel('Control u1(t) = G [ billions of 1982 dollars'); xlabel('Time [ quarter ]'); grid figure(6) clf set(gcf,'Name',' d_M = differences of real money stock M1'); hndl7=plot(USAMACRO(2:N,1),(USAMACRO(2:N,7)-USAMACRO(1:N-1,7)),'r'); set(hndl7,'LineWidth',0.5); hold off title('First Diferences of Real Money Stock M1'); ylabel('Control u2(t) = d_M [ billions of 1982 dollars ]'); xlabel('Time [ quarter ]'); grid set(0,'DefaultAxesFontSize',7) figure(7) clf set(gcf,'Name','Observed Historical Data') subplot(321) hndl2=plot(USAMACRO(:,1),USAMACRO(:,2),'c'); set(hndl2,'LineWidth',0.5); hold off title('Real Aggregate Personal Consumption'); ylabel('C [ billions of 1982 dollars ]'); %...xlabel('Time [ quarter ]'); grid subplot(322) hndl3=plot(USAMACRO(:,1),USAMACRO(:,3),'c'); set(hndl3,'LineWidth',0.5); hold off title('Real Gross Domestic Investment'); ylabel('I [ billions of 1982 dollars ]'); %...xlabel('Time [ quarter ]'); grid subplot(323) hndl4=plot(USAMACRO(:,1),USAMACRO(:,4),'c'); set(hndl4,'LineWidth',0.5); hold off title('Interest Rate on 3-Month Treasury Bills'); ylabel('R [ percent per year ]'); %...xlabel('Time [ quarter ]'); grid subplot(324) hndl5=plot(USAMACRO(:,1),USAMACRO(:,5),'c'); set(hndl5,'LineWidth',0.5); hold off title('Real GNP (net export and import)'); ylabel('Y [ billions of 1982 dollars ]'); %...xlabel('Time [ quarter ]'); grid subplot(325) hndl6=plot(USAMACRO(:,1),USAMACRO(:,6),'r'); set(hndl6,'LineWidth',0.5); hold off title('Real Gavernment Spending'); ylabel('G [ billions of 1982 dollars'); xlabel('Time [ quarter ]'); grid subplot(326) hndl7=plot(USAMACRO(2:N,1),(USAMACRO(2:N,7)-USAMACRO(1:N-1,7)),'r'); set(hndl7,'LineWidth',0.5); hold off title('First Diferences of Real Money Stock M1'); ylabel('d_M [ billions of 1982 dollars ]'); xlabel('Time [ quarter ]'); grid