clear all
close all

x = load('us.txt');
t = x(:,1);
gdp = x(:,2);
cpi = x(:,4);
lgdp = log(gdp);
lcpi = log(cpi);

figure
subplot(211)
plot(t,lgdp)
title('log HDP')
subplot(2,1,2)
plot(t,lcpi)
title('log CPI')

lgdp_trend = hp(lgdp,1600);
lgdp_gap = lgdp - lgdp_trend;

figure
plot(t,[lgdp lgdp_trend])
legend('log HDP','trend')
grid

figure
plot(t,lgdp_gap)
title('mezera HDP')
grid

pie4 = lcpi(5:end) - lcpi(1:end-4);
pie4 = [nan(4,1);pie4];

figure
plot(t,lgdp_gap,t,pie4,'r')
legend('mezera HDP','\pi_t')
grid

lgdp_gr = lgdp(2:end) - lgdp(1:end-1);
lgdp_gr = [nan;lgdp_gr];

figure
plot(t,lgdp_gr,t,pie4,'r')
legend('tempo rustu HDP','\pi_t')
grid

c1 = corrfn(lgdp,lcpi,0)
c2 = corrfn(lgdp_gap,pie4,0)













