close all
clear all
clc

x = load('us2.txt');
t= x(:,1);
lgdp = log(x(:,2));
unr = x(:,end);

n = length(lgdp);

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

%1. model  
[unr_trend, unr_gap] = hp(unr,1600);

a = ols(lgdp_gap,unr_gap);
alpha = -a(1,1);

disp('1. model: y_gap_t = - alpha  u_gap_t')
alpha

figure
plot(t,[unr unr_trend])
legend('mira nezamestnanosti','trend (odhad HP)')

% 2. model
X2 = [ones(n,1) unr];
b = ols(lgdp_gap,X2);

disp('2. model:  y_gap_t = alpha uu - alpha u_t')
alpha2 = -b(2,1)
nairu2 = b(1,1)/alpha2

% 3. model

X3 = [ones(n,1) lgdp_gap];
c = ols(unr,X3);

disp('3. model: u_t = uu - 1/alpha y_gap_t')
nairu3 = c(1,1)
alpha3 = -1/c(2,1)

% 4. model

X4 = [ones(n,1) lag(unr,1) lgdp_gap];
d = ols(unr,X4);

disp('4. model:  u_t =  w * u_t-1 + (1 - w) [uu - 1/alpha y_t ]')
w = d(2,1)
nairu4 = d(1,1)/(1-w)
alpha4 = -(1-w)/d(3,1)





