Home > documentation > graphs.m

graphs

PURPOSE ^

GRAPHS.m

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 GRAPHS.m

 Computes rational expectations solution to Ireland's (2004) model and
 uses the solution to plot linear aggregate demand and aggregate
 supply curves in output growth-inflation space.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % GRAPHS.m
0002 %
0003 % Computes rational expectations solution to Ireland's (2004) model and
0004 % uses the solution to plot linear aggregate demand and aggregate
0005 % supply curves in output growth-inflation space.
0006 
0007 solmat
0008 
0009 shocks=1; % if 1, draw curves for shock processes
0010 estimated=1; % if 1, draw observed data points and curves through those points
0011 
0012 samplesize = 200;      
0013 gmin = -2;%-.02; %Change this depending on the scale of the graph
0014 gmax = 2;%.02; %Change this depending on the scale of the graph
0015 step = .0005;
0016 gvec = gmin:step:gmax;
0017 [rows cols] = size(gvec); 
0018 
0019 g_ssvec = (g_ss)*ones(rows,cols);
0020 ppi_ssvec = (ppi_ss)*ones(rows,cols);
0021 
0022 % Create tensors to store demand and supply curves
0023 ppi_ad_ss = zeros(rows,cols,samplesize);
0024 ppi_as_ss = zeros(rows,cols,samplesize);
0025 
0026 for t = 1:samplesize
0027     ppi_ad_ss(:,:,t) = ad(gvec,ad_slope,0,ad_constant);
0028     ppi_as_ss(:,:,t) = as(gvec,as_slope,0,as_constant);
0029 end
0030 
0031 figure; plot(gvec,ppi_ssvec); % Plots the steady-state curves
0032 hold on;
0033 line([g_ss g_ss],[-4 4])
0034 plot(gvec,ppi_as_ss(:,:,1));
0035 plot(gvec,ppi_ad_ss(:,:,1));
0036 title('Steady State')
0037 %xlim([0 1])
0038 %ylim([0 1])
0039 
0040 if shocks
0041 ppi_ad_eps_e = zeros(rows,cols,samplesize);
0042 ppi_as_eps_e = zeros(rows,cols,samplesize);
0043 ppi_ad_eps_a = zeros(rows,cols,samplesize);
0044 ppi_as_eps_a = zeros(rows,cols,samplesize);
0045 ppi_ad_eps_z = zeros(rows,cols,samplesize);
0046 ppi_as_eps_z = zeros(rows,cols,samplesize);
0047 ppi_ad_eps_r = zeros(rows,cols,samplesize);
0048 ppi_as_eps_r = zeros(rows,cols,samplesize);
0049 
0050 ppi_eps_e = (ppihat_eps_e + ones(samplesize,1)*ppi_ss);
0051 g_eps_e = (ghat_eps_e + ones(samplesize,1)*g_ss);
0052 
0053 ppi_eps_a = (ppihat_eps_a + ones(samplesize,1)*ppi_ss);
0054 g_eps_a = (ghat_eps_a + ones(samplesize,1)*g_ss);
0055 
0056 ppi_eps_z = (ppihat_eps_z + ones(samplesize,1)*ppi_ss);
0057 g_eps_z = (ghat_eps_z + ones(samplesize,1)*g_ss);
0058 
0059 ppi_eps_r = (ppihat_eps_r + ones(samplesize,1)*ppi_ss);
0060 g_eps_r = (ghat_eps_r + ones(samplesize,1)*g_ss);
0061 
0062 for t = 1:samplesize
0063     ppi_ad_eps_e(:,:,t) = ad(gvec,ad_slope,adt_eps_e(t),ad_constant);
0064     ppi_as_eps_e(:,:,t) = as(gvec,as_slope,ast_eps_e(t),as_constant);
0065     ppi_ad_eps_a(:,:,t) = ad(gvec,ad_slope,adt_eps_a(t),ad_constant);
0066     ppi_as_eps_a(:,:,t) = as(gvec,as_slope,ast_eps_a(t),as_constant);
0067     ppi_ad_eps_z(:,:,t) = ad(gvec,ad_slope,adt_eps_z(t),ad_constant);
0068     ppi_as_eps_z(:,:,t) = as(gvec,as_slope,ast_eps_z(t),as_constant);
0069     ppi_ad_eps_r(:,:,t) = ad(gvec,ad_slope,adt_eps_r(t),ad_constant);
0070     ppi_as_eps_r(:,:,t) = as(gvec,as_slope,ast_eps_r(t),as_constant);
0071 end
0072 
0073 
0074 from = 1; % First period to draw curves for
0075 to = 5; % Second period to draw curves for
0076 
0077 figure; plot(gvec,ppi_ssvec);
0078 hold on;
0079 line([g_ss g_ss],[-4 4])
0080 plot(gvec,ppi_as_eps_e(:,:,from));
0081 plot(gvec,ppi_as_eps_e(:,:,to),'r');
0082 plot(gvec,ppi_ad_eps_e(:,:,from),':');
0083 plot(gvec,ppi_ad_eps_e(:,:,to),':r');
0084 title('Shock e')
0085 scatter(g_eps_e,ppi_eps_e);
0086 
0087 figure; plot(gvec,ppi_ssvec);
0088 hold on;
0089 line([g_ss g_ss],[-4 4])
0090 plot(gvec,ppi_as_eps_a(:,:,from));
0091 plot(gvec,ppi_as_eps_a(:,:,to),'r');
0092 plot(gvec,ppi_ad_eps_a(:,:,from),':');
0093 plot(gvec,ppi_ad_eps_a(:,:,to),':r');
0094 title('Shock a')
0095 scatter(g_eps_a,ppi_eps_a);
0096 
0097 figure; plot(gvec,ppi_ssvec);
0098 hold on;
0099 line([g_ss g_ss],[-4 4])
0100 plot(gvec,ppi_as_eps_z(:,:,from));
0101 plot(gvec,ppi_as_eps_z(:,:,to),'r');
0102 plot(gvec,ppi_ad_eps_z(:,:,from),':');
0103 plot(gvec,ppi_ad_eps_z(:,:,to),':r');
0104 title('Shock z')
0105 scatter(g_eps_z,ppi_eps_z);
0106 
0107 figure; plot(gvec,ppi_ssvec);
0108 hold on;
0109 line([g_ss g_ss],[-4 4])
0110 %line([0.999 0.9995], [ad(0.999,ad_slope,adt_eps_r(from),ad_constant) ad(0.9995,ad_slope,adt_eps_r(from),ad_constant)]);
0111 plot(gvec,ppi_as_eps_r(:,:,from));
0112 plot(gvec,ppi_as_eps_r(:,:,to),'r');
0113 plot(gvec,ppi_ad_eps_r(:,:,from),':');
0114 plot(gvec,ppi_ad_eps_r(:,:,to),':r');
0115 title('Shock r')
0116 scatter(g_eps_r,ppi_eps_r);
0117 end
0118 
0119 if estimated % For drawing curves with estimates
0120     first = dates.Q200700; %2007Q1 Coloured scatter
0121     second = dates.Q201050; %2010Q3 Coloured scatter
0122     period1 = dates.Q200725; %2007Q2 drawing ASAD for this period
0123     period2 = dates.Q200875; %2008Q4 drawing ASAD for this period
0124     
0125     samplesize=length(ppihat);
0126     
0127     ppi_ad_data = zeros(rows,cols,samplesize);
0128     ppi_as_data = zeros(rows,cols,samplesize);
0129         
0130         for t = dates.Q199000:dates.Q201050
0131             ppi_ad_data(:,:,t) = ad(gvec,ad_slope,oo_.SmoothedVariables.adt(t,1),ad_constant);
0132             ppi_as_data(:,:,t) = as(gvec,as_slope,oo_.SmoothedVariables.ast(t,1),as_constant);
0133         end
0134      
0135     figure; plot(gvec,ppi_ssvec,'r','LineWidth',2);
0136     hold on;
0137     line([g_ss g_ss],[-4 4],'Color','r','LineWidth',2)
0138     plot(gvec(1,5991:6021),ppi_as_data(:,5991:6021,period1));
0139     plot(gvec(1,1:6016),ppi_ad_data(:,1:6016,period1));
0140     plot(gvec(1,1:5981),ppi_as_data(:,1:5981,period2),'r');
0141     plot(gvec(1,5959:5961),ppi_ad_data(:,5959:5961,period2),'r');    
0142     scatter(ghat(dates.Q199000:dates.Q201050,1)+g_ss,ppihat(dates.Q199000:dates.Q201050,1)+ppi_ss);
0143     for i=first:second
0144         Y=scatter(ghat(first:second,1)+g_ss,ppihat(first:second,1)+ppi_ss,'filled');
0145     end
0146     for i=first:(second-1)
0147         Y=line([ghat(i,1)+g_ss,ghat(i+1,1)+g_ss],[ppihat(i,1)+ppi_ss,ppihat(i+1,1)+ppi_ss]);
0148     end
0149     title('History')
0150     %ylim([-1 2])
0151     
0152     asthistory = [ ...
0153         oo_.SmoothedVariables.ast(dates.Q200800:dates.Q201050,1) ...
0154         oo_.SmoothedVariables.astppihat(dates.Q200800:dates.Q201050,1) ...
0155         oo_.SmoothedVariables.astyhat(dates.Q200800:dates.Q201050,1) ...
0156         oo_.SmoothedVariables.astz(dates.Q200800:dates.Q201050,1) ...
0157         oo_.SmoothedVariables.asta(dates.Q200800:dates.Q201050,1) ...
0158         oo_.SmoothedVariables.aste(dates.Q200800:dates.Q201050,1) ...
0159         ]'; % For table
0160     
0161     adthistory = [ ...
0162         oo_.SmoothedVariables.adt(dates.Q200800:dates.Q201050,1) ...
0163         oo_.SmoothedVariables.adtx(dates.Q200800:dates.Q201050,1) ...
0164         oo_.SmoothedVariables.adtppihat(dates.Q200800:dates.Q201050,1) ...
0165         oo_.SmoothedVariables.adtyhat(dates.Q200800:dates.Q201050,1) ...
0166         oo_.SmoothedVariables.adtrhat(dates.Q200800:dates.Q201050,1) ...
0167         oo_.SmoothedVariables.adtz(dates.Q200800:dates.Q201050,1) ...
0168         oo_.SmoothedVariables.adta(dates.Q200800:dates.Q201050,1) ...
0169         oo_.SmoothedVariables.adteps_r(dates.Q200800:dates.Q201050,1) ...
0170         ]'; % For table
0171     
0172 end
0173 
0174 ast_eps_r_contributions = [astppihat_eps_r astyhat_eps_r asta_eps_r aste_eps_r astz_eps_r]./[ast_eps_r*ones(1,5)];
0175 ast_eps_a_contributions = [astppihat_eps_a astyhat_eps_a asta_eps_a aste_eps_a astz_eps_a]./[ast_eps_a*ones(1,5)];
0176 ast_eps_e_contributions = [astppihat_eps_e astyhat_eps_e asta_eps_e aste_eps_e astz_eps_e]./[ast_eps_e*ones(1,5)];
0177 ast_eps_z_contributions = [astppihat_eps_z astyhat_eps_z asta_eps_z aste_eps_z astz_eps_z]./[ast_eps_z*ones(1,5)];
0178 
0179 adt_eps_r_contributions = [adtx_eps_r adtppihat_eps_r adtyhat_eps_r adtrhat_eps_r adtz_eps_r adta_eps_r adteps_r_eps_r]./[adt_eps_r*ones(1,7)];
0180 adt_eps_a_contributions = [adtx_eps_a adtppihat_eps_a adtyhat_eps_a adtrhat_eps_a adtz_eps_a adta_eps_a adteps_r_eps_a]./[adt_eps_a*ones(1,7)];
0181 adt_eps_e_contributions = [adtx_eps_e adtppihat_eps_e adtyhat_eps_e adtrhat_eps_e adtz_eps_e adta_eps_e adteps_r_eps_e]./[adt_eps_e*ones(1,7)];
0182 adt_eps_z_contributions = [adtx_eps_z adtppihat_eps_z adtyhat_eps_z adtrhat_eps_z adtz_eps_z adta_eps_z adteps_r_eps_z]./[adt_eps_z*ones(1,7)];
0183 
0184 adt_contributions = [adt_eps_r_contributions(1,:)' adt_eps_a_contributions(1,:)' adt_eps_e_contributions(1,:)' adt_eps_z_contributions(1,:)'];
0185 ast_contributions = [ast_eps_r_contributions(1,:)' ast_eps_a_contributions(1,:)' ast_eps_e_contributions(1,:)' ast_eps_z_contributions(1,:)'];

Generated on Mon 07-Feb-2011 12:06:56 by m2html © 2005