clear all close all x = load('us.txt'); time = x(:,1); gdp = x(:,2); c = x(:,3); cpi = x(:,4); ir = x(:,5); w = x(:,6); inv = x(:,7); lgdp = log(gdp); lc = log(c); lcpi = log(cpi); ir = ir/100; lw = log(w); linv = log(inv); [lgdp_trend,lgdp_gap] = hp(lgdp,1600); [lc_trend,lc_gap] = hp(lc,1600); [linv_trend,linv_gap] = hp(linv,1600); figure plot(time,[lgdp_gap, lc_gap]) legend('gap gdp','gap c') figure plot(time,[lgdp_gap, linv_gap]) legend('gap gdp','gap inv') c1 = corrfn(lgdp_gap,lc_gap,5); c2 = corrfn(lgdp_gap,linv_gap,5); k = (5:-1:-5)'; [k c1] [k c2] figure bar(k,c1) xlabel('k') ylabel('corr. coef.') title('HDP_t vs. C_{t+k}') figure bar(k,c2) xlabel('k') ylabel('corr. coef.') title('HDP_t vs. INV_{t+k}') cy_ratio = c ./ gdp; iy_ratio = inv./ gdp; avg_cy = mean(cy_ratio); avg_iy = mean(iy_ratio); std_y = std(lgdp_gap); std_c = std(lc_gap); std_inv = std(linv_gap); disp('Share to GDP: C I') disp([avg_cy avg_iy]) disp('Standard deviation: Y C I') disp([std_y std_c std_inv]*100) % inflation pie4 = lcpi(5:end) - lcpi(1:end-4); pie4 = [nan(4,1);pie4]; %rir rir = ir(1:end-4) - pie4(5:end); rir = [rir;ones(4,1)*nan]; [pie4_trend,pie4_gap] = hp(pie4,1600); [rir_trend, rir_gap] = hp(rir,1600); c3 = corrfn(lgdp_gap,pie4_gap,5); c4 = corrfn(lgdp_gap,rir_gap,5); figure plot(time,[lgdp_gap, pie4_gap]) legend('gap gdp','gap \pi') figure plot(time,[lgdp_gap, rir_gap]) legend('gap gdp', 'gap rir') figure bar(k,c3) xlabel('k') ylabel('corr. coef.') title('HDP_t x \pi_{t+k}') figure bar(k,c4) xlabel('k') ylabel('corr. coef.') title('HDP_t x RIR_{t+k}') %% test vyznamnosti koeficientu korelace n = length(time); test.c = [c1 k corrtest(c1,n)]; test.i = [c2 k corrtest(c2,n)]; test.pie = [c3 k corrtest(c3,n-4)]; test.rir = [c4 k corrtest(c4,n-4)];