clear all
close all

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

[lgdp_trend, lgdp_gap] = hp(lgdp,1600);

y = lgdp_gap(2:end);
X = lgdp_gap(1:end-1);

beta = ols(y,X);

per1 = (2:85);
per2 = (86:170);

% prvni obdobi
y1 = lgdp_gap(per1);
X1 = lgdp_gap(per1-1);

[beta1, vare1] = ols(y1,X1);
alpha1 = beta1(1,1);

n1 = log(0.1)/log(alpha1);
stdy1 = sqrt(vare1/(1-alpha1^2));

% druhe obdobi
y2 = lgdp_gap(per2);
X2 = lgdp_gap(per2-1);

[beta2, vare2] = ols(y2,X2);
alpha2 = beta2(1,1);

n2 = log(0.1)/log(alpha2);
stdy2 = sqrt(vare2/(1-alpha2^2));

disp('alpha: flexibilita ekonomiky')
disp([alpha1    alpha2])
disp('doba odezneni soku')
disp([n1    n2])
disp('smerodatna odchylka mezery vystupu (v %)')
disp([stdy1 stdy2]*100)

figure
plot(t,lgdp_gap*100)
title('mezera vystupu')
grid














    







