mu_a	=	0.282477238710735000	;
mu_bar_a	=	0.476287322349070000	;
hab_a	=   0.49430823988248700;  % 0.748045037838636000;
eta_a	=	0.978798953069214000	;

upsilon_a	=	4.950940456396190000	;
upsilon_p_a	=	69.810486611992200000	;
upsilon_w_a	=	61.801387405490500000	;

xip_a	=	0.351187547191756000	;
xiw_a	=	0.507403517488228000	;

eta_kG_a	=	0.083932208714118000	;
eta_nG_a	=	0.074302798757985500	;

rho_etauw_a	=	0.825931576173091000	;
rho_etauc_a	=	0.920601158040990000	;
rho_etausc_a	=	0.924865521659026000	;
rho_eg_a	=	0.822356083643030000	;
rho_einG_a	=	0.783423484437927000	;
rho_enG_a	=	0.951019923133490000	;
rho_eTR_a	=	0.843619277379409000	;
rho_eT_a	=	0.533263481090525000	;
rho_emg_a	=	0.896839087171709000	;

xi_b_etauw_a	=	-0.004672888129226880	;
xi_b_etausc_a	=	-0.007226040751017210	;
xi_b_eg_a	=	0.096938170950780100	;
xi_b_ein_a	=	0.219379534265127000	;
xi_b_eTR_a	=	0.165530467096634000	;
xi_b_eT_a	=	0.163396391108427000	;

xi_y_etauw_a	=	0.073188801245085200	;
xi_y_etausc_a	=	-0.005810721894570920	;
xi_y_eg_a	=	0.166475842825658000	;
xi_y_ein_a	=	0.199132812845768000	;
xi_y_eTR_a	=	0.197202888715513000	;
xi_y_eT_a	=	0.188279768710148000	;

psi_cG_a	=	0.776597272114415000	;
psi_inG_a	=	0.785480757328960000	;
psi_TR_a	=	0.725262270856316000	;
psi_T_a	=	0.802347279850517000	;
psi_tauw_a	=	0.605289321142294000	;
psi_tausc_a	=	0.681118557613049000	;
psi_tauc_a	=	0.561299099089667000	;
psi_nG_a	=	0.518745682043223000	;
psi_mg_a	=	0.748727862656477000	;

rho_a_i	=	0.840454065296516000	;
phi_a_pi	=	1.796006986201710000	;
phi_a_y	=	0.054033948356913700	;
rho_a_a	=	0.899238331477406000	;
rho_ein_a	=	0.757438246499296000	;
rho_eb_a	=	0.564543968129862000	;
rho_en_a	=	0.970835725680206000	;
rho_erp_a	=	0.771845035216218000	;
rho_erp_b	=	0.529155487135554000	;
rho_etheta_a	=	0.557694014418680000	;
rho_ethetaw_a	=	0.709153568277062000	;
rho_eRoE_a	=	0.936606103891553000	;
rho_eRoW_a	=	0.861180514202767000	;

mu_b	=	0.208628385317963000	;
mu_bar_b	=	0.356282857869388000	;
hab_b	=	0.748045037838636000	;
eta_b	=	0.893052672859960000	;

upsilon_b	=	4.929755999302440000	;
upsilon_p_b	=	67.315854957548200000	;
upsilon_w_b	=	79.885363045336300000	;

xip_b	=	0.447240087236102000	;
xiw_b	=	0.300897704295267000	;

eta_kG_b	=	0.069941117409300700	;
eta_nG_b	=	0.091619392655143900	;

rho_etauw_b	=	0.842012112212371000	;
rho_etauc_b	=	0.928804467566795000	;
rho_etausc_b	=	0.869254031381510000	;
rho_eg_b	=	0.919707454883866000	;
rho_einG_b	=	0.856730081685878000	;
rho_enG_b	=	0.982751143611852000	;
rho_eTR_b	=	0.940556719212743000	;
rho_eT_b	=	0.808108784868906000	;
rho_emg_b	=	0.881236728633140000	;

xi_b_etauw_b	=	0.021701933365160200	;
xi_b_etausc_b	=	0.006961683797481780	;
xi_b_eg_b	=	0.160924182266452000	;
xi_b_ein_b	=	0.196902075163885000	;
xi_b_eTR_b	=	0.127793318575280000	;
xi_b_eT_b	=	0.093881033640800000	;

xi_y_etauw_b	=	0.035944107701462800	;
xi_y_etausc_b	=	0.016376414288795700	;
xi_y_eg_b	=	0.184944995830773000	;
xi_y_ein_b	=	0.188800575641822000	;
xi_y_eTR_b	=	0.219552713235174000	;
xi_y_eT_b	=	0.193910514397887000	;

psi_cG_b	=	0.822519302825855000	;
psi_inG_b	=	0.764103197722301000	;
psi_TR_b	=	0.744004703867267000	;
psi_T_b	=	0.297703971950222000	;
psi_tauw_b	=	0.737950304365973000	;
psi_tausc_b	=	0.737798429223208000	;
psi_tauc_b	=	0.664352046313142000	;
psi_nG_b	=	0.655850748243596000	;
psi_mg_b	=	0.829545941189254000	;

rho_a_b	=	0.915134443546581000	;
rho_ein_b	=	0.720515979553970000	;
rho_eb_b	=	0.815139919204029000	;
rho_en_b	=	0.970682594671610000	;
rho_etheta_b	=	0.582024312094825000	;
rho_ethetaw_b	=	0.511860144017268000	;
rho_eRoE_b	=	0.929338466342018000	;
rho_eRoW_b	=	0.864026540437001000	;



eta_c	=	0.477981757337902000	;

a11	=	0.776167606195531000	;
a12	=	0.207902765062088000	;
a13	=	0.348053579664149000	;
a21	=	-0.053895843117779000	;
a22	=	0.514680362717915000	;
a23	=	0.532748186569371000	;
a24	=	-0.134100575515807000	;
c21	=	0.466675489839798000	;
c24	=	0.228228380609716000	;
a31	=	0.024470606672294800	;
a32	=	-0.002658659969743450	;
a33	=	0.925786973418931000	;
a34	=	-0.109029422496454000	;
c31	=	0.071931190596677100	;
c32	=	0.001956462802951850	;
c34	=	-0.108015662733109000	;
a44	=	0.791628592989840000	;

c11 = 1;
c22 = 1;
c33 = 1;
c44 = 1;

xi_y_emg_a = 0;
xi_y_emg_b = 0;



%% Steady-state values/parameters set/calibrated by authors

% set Taylor-rule growth coefficients to zero

phi_a_dpi	=	0;
phi_a_dy	=	0;

% Value-added Tax
tau_a = 0; 
tau_b = 0; 

% Labor Tax
tauw_a = 0.3039;
tauw_b = 0.2765;

% Social Security Contribution (employer)
tausc_a = 0.1667;
tausc_b = 0.2459;

% Capital Tax
tauk_a = 0.2143;
tauk_b = 0.3158;

% Consumption Tax
tauc_a = 0.1831;
tauc_b = 0.1960;

% discount factor
i_a_ts    = 0.025/4;
i_b_ts    = 0.025/4;

% Steady State Inflation (the same across countries)
pi_ts=1.00475;

% depreciation rate
delta_a   = 0.015;
delta_b   = 0.015;

% consumption elasticity
sigma_a   = 1;
sigma_b   = 1;

% Measures how valuable gov spending is for consumer 
alpha_G_a = 1;
alpha_G_b = 1;

% inverse Frisch elasticity (correct only in a labor market without UB)
psi_a     = 10;
psi_b     = 9;

% scaling parameter to create slugish adjustment of labor force (in kappa_w_a)
psi_l_a     = 0;
psi_l_b     = 0;

% capital share
rho_a   =   0.33;
rho_b   =   0.33;

% Price elasticity
theta_a =   4;
theta_b =   4;

% employment adjustment cost
upsilon_n_a  = 0;
upsilon_n_b  = 0;

% replacement ratio
rrs_a  = 0.3511;
rrs_b  = 0.3511;

% Labor force
l_a_ts = 0.4717;
l_b_ts = 0.4013;

% Unemployment rate
ur_a_ts = 0.0818;
ur_b_ts = 0.0946;

% Share of public employment of total employment
gn_a = 0.1278;
gn_b = 0.1848;

% Public markup over private wages
mg_a = 0.03;
mg_b = 0.03;

% Public consumption as share of GDP
gc_a = 0.1112;
gc_b = 0.1006;
gc_c = 0.1059;

% Public transfers as share of GDP (including unemployment benefits)
gTR_a = 0.1900;
gTR_b = 0.1825;

% Public investment as share of GDP
gin_a = 0.0165;
gin_b = 0.0277;
gin_c = 0.0221;

% Consumption and investment share for RoW
c_c = 0.6; 
in_c = 0.2;

% Normalization of public good
yG_a_ts = 1;
yG_b_ts = 1;

% Targeting of one bond position
B_ba_ts  = 0;
  
% international risk premium parameter
phi   = 0.01;

% Trend growth of real variables
gamma_a = 0.003163327;
gamma_b = 0.001341793;

% population Size (A and B)
pop_a     = 1; % normalization. always to be 1
pop_b     = 2.6; % based on population average from Excel data sheet
pop_c     = 56; %based on population figures from wikipedia only for RoW countries 

GDP_a_ts = 1; %normalization
GDP_b_ts = 0.871*GDP_a_ts; %Based on GDP per Head in RoE

% AR coefficient unemployment benefits
rho_UB_a = 0;
rho_UB_b = 0;

 nu_etauw_a = 0;
 nu_etauw_b = 0;
 nu_eg_a = 0;
 nu_eg_b = 0;
 nu_eT_r_a = 0;
 nu_eT_r_b = 0;
 nu_ein_a = 0;
 nu_ein_b = 0;
 
 % Public markup over private wages
mg_a = 0.03;
mg_b = 0.03;

xi_b_emg_a = 0;
xi_b_emg_b = 0;

psi_mg_a = 0*0.757595;
psi_mg_b = 0*0.806443;

% AR coefficient (rho) and debt feedback (xi) of value-added tax
rho_etau_a = 0;
rho_etau_b = 0;

xi_b_etau_a = 0*0.05;
xi_b_etau_b = 0*0.05;

rho_etauk_a = 0;
rho_etauk_b = 0;
xi_b_etauk_a = 0;
xi_b_etauk_b = 0;
xi_y_etauk_a = 0;
xi_y_etauk_b = 0;
xi_b_etauc_a = 0;
xi_b_etauc_b = 0;
xi_y_etauc_a = 0;
xi_y_etauc_b = 0;
xi_b_enG_a = 0;
xi_b_enG_b = 0;
xi_y_enG_a = 0;
xi_y_enG_b = 0;
psi_tauk_a = 0;
psi_tauk_b = 0;

%% Steady State Calculations


pr_ts    = 1;

betta_a = pi_ts/(1 + i_a_ts);
betta_b = pi_ts/(1 + i_b_ts);
i_c_ts  = i_a_ts;

i_Ga_ts = i_a_ts;
i_Gb_ts = i_b_ts;

i_policy_ts=i_a_ts;

q_a_ts=1;
q_b_ts=1;

Rk_a_ts=i_a_ts;
Rk_b_ts=i_b_ts;

rk_a_ts=(((1+ Rk_a_ts)/pi_ts -tauk_a*delta_a) -(1-delta_a))/(1-tauk_a) ;
rk_b_ts=(((1+ Rk_b_ts)/pi_ts -tauk_b*delta_b) -(1-delta_b))/(1-tauk_b) ;
   
mcr_a_ts   = (1-tau_a)*((theta_a-1)/theta_a);
mcr_b_ts   = (1-tau_b)*((theta_b-1)/theta_b);

in_a_ts = 0.172*GDP_a_ts;
in_b_ts = 0.193*GDP_b_ts;

k_a_ts  = in_a_ts/delta_a;
k_b_ts  = in_b_ts/delta_b;

l_o_a_ts = l_a_ts;
l_o_b_ts = l_b_ts;

l_r_a_ts = l_a_ts;
l_r_b_ts = l_b_ts;

n_a_ts    = (1-ur_a_ts)*l_a_ts;   
n_b_ts    = (1-ur_b_ts)*l_b_ts;   

nG_a_ts = n_a_ts*gn_a;
nG_b_ts = n_b_ts*gn_b;

nP_a_ts = n_a_ts - nG_a_ts;
nP_b_ts = n_b_ts - nG_b_ts;

n_k_a = nP_a_ts/k_a_ts;
n_k_b = nP_b_ts/k_b_ts;

wr_a_ts    = rk_a_ts*n_k_a^(-1)*(1-rho_a)/(rho_a*(1+tausc_a));
wr_b_ts    = rk_b_ts*n_k_b^(-1)*(1-rho_b)/(rho_b*(1+tausc_b));


wrG_a_ts = wr_a_ts*(1+mg_a);
wrG_b_ts = wr_b_ts*(1+mg_b);

y_a_ts = GDP_a_ts - (1+tausc_a)*wrG_a_ts*nG_a_ts;
y_b_ts = GDP_b_ts - (1+tausc_b)*wrG_b_ts*nG_b_ts;

A_a = (wr_a_ts*(1+tausc_a)*n_k_a^rho_a)/(mcr_a_ts*(1-rho_a));
A_b = (wr_b_ts*(1+tausc_b)*n_k_b^rho_b)/(mcr_b_ts*(1-rho_b));


k_o_a_ts    = k_a_ts/(1-mu_a); 
k_o_b_ts    = k_b_ts/(1-mu_b);


in_o_a_ts    = in_a_ts/(1-mu_a); 
in_o_b_ts    = in_b_ts/(1-mu_b);

FC_a=A_a*(k_a_ts^rho_a)*(nP_a_ts^(1-rho_a)) - y_a_ts;
FC_b=A_b*(k_b_ts^rho_b)*(nP_b_ts^(1-rho_b)) - y_b_ts;

BG_a_ts = 2.4*GDP_a_ts;
BG_b_ts = 2.4*GDP_b_ts;
BG_EU_ts = 2.4*(pop_a*GDP_a_ts + pop_b*GDP_b_ts)/(pop_a+pop_b);

cG_a_ts = GDP_a_ts*gc_a;
cG_b_ts = GDP_b_ts*gc_b;

inG_a_ts = GDP_a_ts*gin_a;
inG_b_ts = GDP_b_ts*gin_b;

kG_a_ts = inG_a_ts/delta_a;
kG_b_ts = inG_b_ts/delta_b;

z_a = yG_a_ts/(kG_a_ts^eta_kG_a*nG_a_ts^eta_nG_a);
z_b = yG_b_ts/(kG_b_ts^eta_kG_b*nG_b_ts^eta_nG_b);

UB_a = rrs_a*wr_a_ts*(1-tauw_a);
UB_b = rrs_b*wr_b_ts*(1-tauw_b);

% If net exports=0 is assumed:
c_a_ts    = y_a_ts - in_a_ts - cG_a_ts - inG_a_ts; 
c_b_ts    = y_b_ts - in_b_ts - cG_b_ts - inG_b_ts;

y_c_ts = (y_a_ts+y_b_ts)/2;

cG_c_ts = gc_c*y_c_ts;
in_c_ts = in_c*y_c_ts;
c_c_ts = c_c*y_c_ts;

% Matching observed import shares to GDP ratios with openness parameters 
n_ab=0.130*GDP_a_ts/(c_a_ts+in_a_ts);
n_ac=0.229*GDP_a_ts/(c_a_ts+in_a_ts);
n_ba=0.066*GDP_b_ts/(c_b_ts+in_b_ts);
n_bc=n_ac;
%share in RoW consumption basket used to deliver trade balance = 0
n_ca=(n_ab*(c_a_ts+in_a_ts)+n_ac*(c_a_ts+in_a_ts)-pop_b/pop_a*n_ba*(c_b_ts+in_b_ts))/(pop_c/pop_a*(c_c_ts+in_c_ts));
n_cb=(n_ba*(c_b_ts+in_b_ts)+n_bc*(c_b_ts+in_b_ts)-pop_a/pop_b*n_ab*(c_a_ts+in_a_ts))/(pop_c/pop_b*(c_c_ts+in_c_ts));

n_aa=1-n_ab-n_ac;
n_bb=1-n_ba-n_bc;
n_cc=1-n_ca-n_cb;

% home bias calculation
 vtheta_ab    = n_ab/pop_b*(pop_a + pop_b + pop_c);
 vtheta_ac    = n_ac/pop_c*(pop_a + pop_b + pop_c);

 vtheta_ba   = n_ba/pop_a*(pop_a + pop_b + pop_c);
 vtheta_bc  = n_bc/(pop_c)*(pop_a + pop_b + pop_c);

nfa_a_ts=0;
nfa_b_ts=0;
nfa_c_ts=0;

B_c_ts   = 0;
B_ba_ts  = 0;
B_a_ts   = 0;
B_ac_ts  = 0;
B_bc_ts  = 0;

c_r_a_ts    = c_a_ts; 
c_r_b_ts    = c_b_ts;

c_o_a_ts    = c_a_ts; 
c_o_b_ts    = c_b_ts;

c_tild_a_ts = c_o_a_ts;
c_tild_b_ts = c_o_b_ts;

lambda_o_a_ts = (c_tild_a_ts-hab_a*c_tild_a_ts)^(-sigma_a)/(1+tauc_a);
lambda_o_b_ts = (c_tild_b_ts-hab_b*c_tild_b_ts)^(-sigma_b)/(1+tauc_b);

kappaw_a_ts = lambda_o_a_ts*(wr_a_ts*(1-tauw_a)*nP_a_ts+wrG_a_ts*(1-tauw_a)*nG_a_ts+UB_a*(l_o_a_ts - n_a_ts))/(l_o_a_ts^psi_a*n_a_ts);
omega_o_a_ts = ((1-mu_a)*lambda_o_a_ts*UB_a)/(lambda_o_a_ts*UB_a-psi_a*l_o_a_ts^(psi_a-1)*n_a_ts*kappaw_a_ts);
omega_r_a_ts = ((mu_a)*lambda_o_a_ts*UB_a)/(lambda_o_a_ts*UB_a-psi_a*l_r_a_ts^(psi_a-1)*n_a_ts*kappaw_a_ts);

thetaw_a = (lambda_o_a_ts*wr_a_ts*(1-tauw_a)*(nP_a_ts - (omega_o_a_ts+omega_r_a_ts)*(nP_a_ts )))/(lambda_o_a_ts*nP_a_ts*wr_a_ts*(1-tauw_a) - kappaw_a_ts*nP_a_ts*n_a_ts^psi_a - UB_a*lambda_o_a_ts*nP_a_ts - (omega_o_a_ts+omega_r_a_ts)*(lambda_o_a_ts*wr_a_ts*(1-tauw_a)*nP_a_ts - UB_a*nP_a_ts*lambda_o_a_ts - kappaw_a_ts*nP_a_ts*l_o_a_ts^psi_a));    

kappaw_b_ts = lambda_o_b_ts*(wr_b_ts*(1-tauw_b)*nP_b_ts+wrG_b_ts*(1-tauw_b)*nG_b_ts+UB_b*(l_o_b_ts - n_b_ts))/(l_o_b_ts^psi_b*n_b_ts);
omega_o_b_ts = ((1-mu_b)*lambda_o_b_ts*UB_b)/(lambda_o_b_ts*UB_b-psi_b*l_o_b_ts^(psi_b-1)*n_b_ts*kappaw_b_ts);
omega_r_b_ts = ((mu_b)*lambda_o_b_ts*UB_b)/(lambda_o_b_ts*UB_b-psi_b*l_r_b_ts^(psi_b-1)*n_b_ts*kappaw_b_ts);

thetaw_b = (lambda_o_b_ts*wr_b_ts*(1-tauw_b)*(nP_b_ts - (omega_o_b_ts+omega_r_b_ts)*(nP_b_ts )))/(lambda_o_b_ts*nP_b_ts*wr_b_ts*(1-tauw_b) - kappaw_b_ts*nP_b_ts*n_b_ts^psi_b - UB_b*lambda_o_b_ts*nP_b_ts - (omega_o_b_ts+omega_r_b_ts)*(lambda_o_b_ts*wr_b_ts*(1-tauw_b)*nP_b_ts - UB_b*nP_b_ts*lambda_o_b_ts - kappaw_b_ts*nP_b_ts*l_o_b_ts^psi_b));    

ex_a_ts  = pop_b/pop_a*n_ba* (c_b_ts + in_b_ts) + pop_c/pop_a*n_ca*((c_c*y_c_ts) + (in_c*y_c_ts));
im_a_ts  = pr_ts*(n_ab*c_a_ts  + n_ab*in_a_ts)+ pr_ts*(n_ac*c_a_ts + n_ac*in_a_ts);

ex_b_ts  = pop_a/pop_b*n_ab*(c_a_ts + in_a_ts) + pop_c/pop_b*n_cb*((c_c*y_c_ts) + (in_c*y_c_ts));
im_b_ts  = pr_ts*(n_ba*c_b_ts + n_ba*in_b_ts) + pr_ts*(n_bc*c_b_ts + n_bc*in_b_ts);

TR_r_a_ts = ((1+tauc_a)*c_r_a_ts - (1-tauw_a)*(nP_a_ts*wr_a_ts+nG_a_ts*wrG_a_ts) - UB_a*(l_r_a_ts-n_a_ts));
TR_a_ts = gTR_a*y_a_ts - (l_a_ts-n_a_ts)*UB_a;
TR_o_a_ts = (TR_a_ts - mu_a*TR_r_a_ts)/(1-mu_a);


TR_r_b_ts = ((1+tauc_b)*c_r_b_ts - (1-tauw_b)*(nP_b_ts*wr_b_ts+nG_b_ts*wrG_b_ts) - UB_b*(l_r_b_ts-n_b_ts));
TR_b_ts = gTR_b*y_b_ts - (l_b_ts-n_b_ts)*UB_b;
TR_o_b_ts = (TR_b_ts - mu_b*TR_r_b_ts)/(1-mu_b);

% European equalization tax rates

tauw_EU    = (pop_a*tauw_a*(nP_a_ts*wr_a_ts + nG_a_ts*wrG_a_ts) + pop_b*tauw_b*(nP_b_ts*wr_b_ts + nG_b_ts*wrG_b_ts))/(pop_a*(nP_a_ts*wr_a_ts + nG_a_ts*wrG_a_ts) + pop_b*(nP_b_ts*wr_b_ts + nG_b_ts*wrG_b_ts));
tausc_EU   = (pop_a*tausc_a*(nP_a_ts*wr_a_ts + nG_a_ts*wrG_a_ts) + pop_b*tausc_b*(nP_b_ts*wr_b_ts + nG_b_ts*wrG_b_ts))/(pop_a*(nP_a_ts*wr_a_ts + nG_a_ts*wrG_a_ts) + pop_b*(nP_b_ts*wr_b_ts + nG_b_ts*wrG_b_ts));
tauc_EU    = (pop_a*tauc_a*c_a_ts + pop_b*tauc_b*c_b_ts)/(pop_a*c_a_ts + pop_b*c_b_ts);
tauk_EU    = (pop_a*tauk_a*(rk_a_ts - delta_a)*k_a_ts + pop_b*tauk_b*(rk_b_ts - delta_b)*k_b_ts)/(pop_a*(rk_a_ts - delta_a)*k_a_ts + pop_b*(rk_b_ts - delta_b)*k_b_ts);

cG_EU_ts   = (pop_a*cG_a_ts + pop_b*cG_b_ts)/(pop_a+pop_b);
inG_EU_ts  = (pop_a*inG_a_ts + pop_b*inG_b_ts)/(pop_a+pop_b);
nG_EU_ts  = (pop_a*nG_a_ts + pop_b*nG_b_ts)/(pop_a+pop_b);
wrG_EU_ts  = (pop_a*wrG_a_ts + pop_b*wrG_b_ts)/(pop_a+pop_b);
UB_EU  = (pop_a*UB_a + pop_b*UB_b)/(pop_a+pop_b);

TR_EU_ts  = (pop_a*TR_a_ts + pop_b*TR_b_ts)/(pop_a+pop_b);
TR_r_EU_ts  = (pop_a*mu_a*TR_r_a_ts + pop_b*mu_b*TR_r_b_ts)/(mu_a*pop_a+mu_b*pop_b);
TR_o_EU_ts = ((pop_a+pop_b)*TR_EU_ts - (pop_a*mu_a+pop_b*mu_b)*TR_r_EU_ts)/(pop_a*(1-mu_a)+pop_b*(1-mu_b));

% European budget 

G_EU_ts   = cG_EU_ts + inG_EU_ts + (1+tausc_EU)*wrG_EU_ts*nG_EU_ts + ((l_a_ts-n_a_ts) + (l_b_ts-n_b_ts))*UB_EU + TR_EU_ts;
Rev_EU_ts = (tauc_EU*(pop_a*c_a_ts + pop_b*c_b_ts) + tauk_EU*(pop_a*(rk_a_ts - delta_a)*k_a_ts + pop_b*(rk_b_ts - delta_b)*k_b_ts)  + (tauw_EU+tausc_EU)*(wr_a_ts*pop_a*nP_a_ts+wrG_a_ts*pop_a*nG_a_ts + wr_b_ts*pop_b*nP_b_ts + wrG_b_ts*pop_b*nG_b_ts) )/(pop_a+pop_b);
T_EU_ts = ((G_EU_ts - Rev_EU_ts + (1+i_Ga_ts)*BG_EU_ts/pi_ts - BG_EU_ts)/(1-mu_a));


G_a_ts = cG_a_ts + inG_a_ts + (1+tausc_a)*wrG_a_ts*nG_a_ts + (l_a_ts-n_a_ts)*UB_a + TR_a_ts;
Rev_a_ts = (1-Switch)*((tauw_a+tausc_a)*(nP_a_ts*wr_a_ts+nG_a_ts*wrG_a_ts) + tauk_a*(rk_a_ts-delta_a)*k_a_ts + tau_a*y_a_ts + tauc_a*c_a_ts) + Switch*(Rev_EU_ts + ((tauw_a-tauw_EU+tausc_a-tausc_EU)*(wr_a_ts*nP_a_ts+wrG_a_ts*nG_a_ts) + (tauk_a-tauk_EU)*(rk_a_ts-delta_a)*k_a_ts + (tauc_a-tauc_EU)*c_a_ts) );
T_a_ts = ((G_a_ts - Rev_a_ts + (1+i_Ga_ts)*BG_a_ts/pi_ts - BG_a_ts)/(1-mu_a));


G_b_ts = cG_b_ts + inG_b_ts + (1+tausc_b)*wrG_b_ts*nG_b_ts + (l_b_ts-n_b_ts)*UB_b + TR_b_ts;
Rev_b_ts = (1-Switch)*((tauw_b+tausc_b)*(nP_b_ts*wr_b_ts+nG_b_ts*wrG_b_ts) + tauk_b*(rk_b_ts-delta_b)*k_b_ts + tau_b*y_b_ts + tauc_b*c_b_ts) + Switch*(Rev_EU_ts + ((tauw_b-tauw_EU+tausc_b-tausc_EU)*(wr_b_ts*nP_b_ts+wrG_b_ts*nG_b_ts) + (tauk_b-tauk_EU)*(rk_b_ts-delta_b)*k_b_ts + (tauc_b-tauc_EU)*c_b_ts) );
T_b_ts = ((G_b_ts - Rev_b_ts + (1+i_Gb_ts)*BG_b_ts/pi_ts - BG_b_ts)/(1-mu_b));


%% Supranational authority feedback parameters
rho_etauw_EU	=	(pop_a*rho_etauw_a+pop_b*rho_etauw_b)/(pop_a+pop_b)	;
rho_etauc_EU	=	(pop_a*rho_etauc_a+pop_b*rho_etauc_b)/(pop_a+pop_b)	;
rho_etausc_EU	=	(pop_a*rho_etausc_a+pop_b*rho_etausc_b)/(pop_a+pop_b)	;
rho_eg_EU       =	(pop_a*rho_eg_a+pop_b*rho_eg_b)/(pop_a+pop_b)	;
rho_einG_EU     =	(pop_a*rho_einG_a+pop_b*rho_einG_b)/(pop_a+pop_b)	;
rho_enG_EU      =	(pop_a*rho_enG_a+pop_b*rho_enG_b)/(pop_a+pop_b)	;
rho_eTR_EU      =	(pop_a*rho_eTR_a+pop_b*rho_eTR_b)/(pop_a+pop_b)	;
rho_eT_EU       =	(pop_a*rho_eT_a+pop_b*rho_eT_b)/(pop_a+pop_b)	;
rho_emg_EU      =	(pop_a*rho_emg_a+pop_b*rho_emg_b)/(pop_a+pop_b)	;

xi_b_etauw_EU	=	(pop_a*xi_b_etauw_a+pop_b*xi_b_etauw_b)/(pop_a+pop_b)	;
xi_b_etausc_EU	=	(pop_a*xi_b_etausc_a+pop_b*xi_b_etausc_b)/(pop_a+pop_b)	;
xi_b_eg_EU      =	(pop_a*xi_b_eg_a+pop_b*xi_b_eg_b)/(pop_a+pop_b)	;
xi_b_ein_EU     =	(pop_a*xi_b_ein_a+pop_b*xi_b_ein_b)/(pop_a+pop_b)	;
xi_b_eTR_EU     =	(pop_a*xi_b_eTR_a+pop_b*xi_b_eTR_b)/(pop_a+pop_b)	;
xi_b_eT_EU      =	(pop_a*xi_b_eT_a+pop_b*xi_b_eT_b)/(pop_a+pop_b)	;

xi_y_etauw_EU	=	(pop_a*xi_y_etauw_a+pop_b*xi_y_etauw_b)/(pop_a+pop_b)	;
xi_y_etausc_EU	=	(pop_a*xi_y_etausc_a+pop_b*xi_y_etausc_b)/(pop_a+pop_b)	;
xi_y_eg_EU      =	(pop_a*xi_y_eg_a+pop_b*xi_y_eg_b)/(pop_a+pop_b)	;
xi_y_ein_EU     =	(pop_a*xi_y_ein_a+pop_b*xi_y_ein_b)/(pop_a+pop_b)	;
xi_y_eTR_EU     =	(pop_a*xi_y_eTR_a+pop_b*xi_y_eTR_b)/(pop_a+pop_b)	;
xi_y_eT_EU      =	(pop_a*xi_y_eT_a+pop_b*xi_y_eT_b)/(pop_a+pop_b)	;

psi_cG_EU       =	(pop_a*psi_cG_a+pop_b*psi_cG_b)/(pop_a+pop_b)	;
psi_inG_EU      =	(pop_a*psi_inG_a+pop_b*psi_inG_b)/(pop_a+pop_b)	;
psi_TR_EU       =	(pop_a*psi_TR_a+pop_b*psi_TR_b)/(pop_a+pop_b)	;
psi_T_EU        =	(pop_a*psi_T_a+pop_b*psi_T_b)/(pop_a+pop_b)	;
psi_tauw_EU     =	(pop_a*psi_tauw_a+pop_b*psi_tauw_b)/(pop_a+pop_b)	;
psi_tausc_EU	=	(pop_a*psi_tausc_a+pop_b*psi_tausc_b)/(pop_a+pop_b)	;
psi_tauc_EU     =	(pop_a*psi_tauc_a+pop_b*psi_tauc_b)/(pop_a+pop_b)	;
psi_nG_EU       =	(pop_a*psi_nG_a+pop_b*psi_nG_b)/(pop_a+pop_b)	;
psi_mg_EU       =	(pop_a*psi_mg_a+pop_b*psi_mg_b)/(pop_a+pop_b)	;

mu_bar_EU       =   (pop_a*mu_bar_a + pop_b*mu_bar_b)/(pop_a+pop_b);

xi_y_etauc_EU   = 0;
xi_b_etauc_EU   = 0;

%% Welfare equations

Welf_opt_a_ts = ( log((1-hab_a)*c_o_a_ts) - kappaw_a_ts*n_a_ts^(1+psi_a)/(1+psi_a) )/(1-betta_a);
Welf_rot_a_ts = ( log((1-hab_a)*c_r_a_ts) - kappaw_a_ts*n_a_ts^(1+psi_a)/(1+psi_a) )/(1-betta_a);

Welf_opt_alt_a_ts = Welf_opt_a_ts;
Welf_rot_alt_a_ts = Welf_rot_a_ts;

Welf_opt_b_ts = ( log((1-hab_b)*c_o_b_ts) - kappaw_b_ts*n_b_ts^(1+psi_b)/(1+psi_b) )/(1-betta_b);
Welf_rot_b_ts = ( log((1-hab_b)*c_r_b_ts) - kappaw_b_ts*n_b_ts^(1+psi_b)/(1+psi_b) )/(1-betta_b);

Welf_opt_alt_b_ts = Welf_opt_b_ts;
Welf_rot_alt_b_ts = Welf_rot_b_ts;


