%path = @runpath
cd %path

'alpha cn   'country names (EZ only)
'cn(1) = "BE"
'cn(2) = "GER"
'cn(3) = "SPA"
'cn(4) = "FRA"
'cn(5) = "IRE"
'cn(6) = "ITA"
'cn(7) = "NET"
'cn(8) = "AUS"
'cn(9) = "FIN"
''cn(10) = "EZ"

matrix(11,6) coef5 ' declare a matrix for storing results

for !j=1 to 9

%x = cn(!j) ' pick a country name from cn vector

smpl if cntry = %x

equation reg5_{%x}_ar.ls lwb c lwb(-1) ' AR(1) regression, time-series (by country)
series res_ar5_{%x} = resid ' residuals

coef5(!j,1) = reg5_{%x}_ar.@coefs(2) ' fill matrix with coefficients

next

smpl @all if cntry="GER" or cntry="BE" or cntry="SPA" or cntry="FRA" or cntry="IRE" or cntry="ITA" or cntry="NET" or cntry="AUS" or cntry="FIN"  ' or c_id="EZ"

' create a group or residual series. Export them manually into matlab (no export function?)

group g5ar res_ar5_be res_ar5_ger res_ar5_spa res_ar5_fra res_ar5_ire res_ar5_ita res_ar5_net res_ar5_aus res_ar5_fin  '  res_ar_ez ' Traded

