I'm keen to mimick a model written by Shintani, M, Terada-Hagiwara, A and Yabu, T 'Exchange rate pass-through and inflation: a nonlinear time series analysis’ Journal of International Money and Finance 32 (2013). I've seen Trubador's LSTAR's sample code and I’ve followed his lead. It should be straightforward but I'm screwing something up.
I started off with their data in order to ensure I was getting it right. The data is attached to this post.
The authors provide the code, which you can find here (the comments are mine):
Code: Select all
*****************************************************************
* This program is to estimate ESTAR
*****************************************************************
CALENDAR 1975 1 12
ALLOCATE 2007:12
open data data.xls
data(format=xls,org=columns)
/*
imp is the seasonally adjusted US import price index
ppi is the seasonally adjusted US producer price index
*/
*variables used in the regressions*
set p = ppi
set s = imp
set dp = 100*log(p/p{1})
set ds = 100*log(s/s{1})
*******
*ESTAR*
'why estar -reasonable to think there are costs of adjustment in either direction
*******
'the transition function is a moving average of 3 lags of producer price inflation
set z = (dp{1}+dp{2}+dp{3})/3
STATISTICS(fractiles, noprint) z
compute std = sqrt(%variance)
set z_big = (z>%FRACT90)+(z<%FRACT10)
'z is the transition variable
'c is the threshold
'which one is the speed and smoothness parameter (is it gamma?)
'this sets free parameters for non linear estimation
nonlin(paraset=base) c0 $
bp1 bp3 bp4 $
bs0 bs1 bs4 bs5 $
c0_out bp5_out $
bs2_out bs4_out gam
'gamma is the speed and smoothness parameter
nonlin(paraset=const) gam>=0
frml estar1 = c0 $
+bp1*dp{1}+bp3*dp{3}+bp4*dp{4} $
+bs0*ds+bs1*ds{1}+bs4*ds{4}+bs5*ds{5} $
+(c0_out+bp5_out*dp{5} $
+(1-bs0)*ds+bs2_out*ds{2}+bs4_out*ds{4}) $
*(1-exp(-gam*(z/std)**2))
'six lags of import prices times the transition function
set ds_big = z_big*ds
set ds_big1 = z_big*ds{1}
set ds_big2 = z_big*ds{2}
set ds_big3 = z_big*ds{3}
set ds_big4 = z_big*ds{4}
set ds_big5 = z_big*ds{5}
set dp_big1 = z_big*dp{1}
set dp_big2 = z_big*dp{2}
set dp_big3 = z_big*dp{3}
set dp_big4 = z_big*dp{4}
set dp_big5 = z_big*dp{5}
set dp_big6 = z_big*dp{6}
'now regress the producer price index on own lags, lags of import prices and the transition function(s).
linreg(noprint) dp
# constant dp{1 to 6} ds{0 to 5} $
ds_big ds_big1 ds_big2 ds_big3 ds_big4 ds_big5 $
dp_big1 dp_big2 dp_big3 dp_big4 dp_big5 dp_big6
compute c0=%beta(1), $
bp1=%beta(2), bp2=%beta(3), bp3=%beta(4), bp4=%beta(5), bp5=%beta(6), bp6=%beta(7),$
bs0=%beta(8), bs1=%beta(9),bs2=%beta(10), bs3=%beta(11),bs4=%beta(12),bs5=%beta(13), $
bs1_out=%beta(15), bs2_out=%beta(16), bs3_out=%beta(17), bs4_out=%beta(18), bs5_out=%beta(19), $
bp1_out=%beta(20), bp2_out=%beta(21), bp3_out=%beta(22), bp4_out=%beta(23), bp5_out=%beta(24), bp6_out=%beta(25), $
gam=1, c0_out=0
nlls(frml=estar1, paraset=base+const, iterations=300, method=gauss, subiterations=30, vcv) dpCode: Select all
'change path to program path
%path = @runpath
cd %path
'create workfile
wfcreate JPNPT M 1975:1 2007:12
read(a2,s=basics) H:\NonlinearERPT\data.xls 2
series p = ppi
series s = imp
series dp = 100*d(log(p),0,1)
series ds = 100*d(log(s),0,1)
'the transition variable z is the moving average of lagged producer price inflation
series z = (dp(-1)+dp(-2)+dp(-3))/3
'create series with values in the 90th and above and in the 5th and below quantiles
series z_big = @recode((z>@quantile(z, 0.90))+(z<@quantile(z,0.1)), z, NA)
smpl @first @first
series dpf = 1
'declare coefficients
coef(1) c0
coef(1) bp1
coef(1) bp3
coef(1) bs4
coef(1) bs5
coef(1) c0_out
coef(1) bp5_out
coef(1) bs2_out
coef(1) bs4_out
coef(1) gam
coef(1) sig
'starting values
c0(1) = 1
bp1(1) = 1
c(1) = 1
bp1(1) = 1
bp3(1) =1
bs4(1) = 1
bs5(1) = 1
c0_out(1) = 1
bp5_out(1) = 1
bs2_out(1) = 1
bs4_out(1) = 1
gam = 10
sig(1) = 1
series ds_big = z_big*ds
series ds_big1 = z_big*ds(-1)
series ds_big2 = z_big*ds(-2)
series ds_big3 = z_big*ds(-3)
series ds_big4 = z_big*ds(-4)
series ds_big5 = z_big*ds(-5)
series dp_big1 = z_big*dp(-1)
series dp_big2 = z_big*dp(-2)
series dp_big3 = z_big*dp(-3)
series dp_big4 = z_big*dp(-4)
series dp_big5 = z_big*dp(-5)
series dp_big6 = z_big*dp(-6)
logl estar
estar.append @logl logl
estar.append dpf = c0 + bp1*dp(-1) + bp3*dp(-3) + bp4*dp(-4) + bs0*ds + bs1*ds(-1) + bs4*ds(-4) + bs5*ds(-5) + (c0_out + bp5_out*dp(-5) + (1-bs0)*ds + bs2_out*ds(-2) + bs4_out*ds(-4))*(1-exp(-gam*(z/(@stdev(z))^2)
estar.append res =dp - dpf
estar.append var = sig(1)^2
estar.append s = res/@sqrt(var)
estar.append logl = log(@dnorm(s)) - log(var)/2
smpl @first+1 @last
estar.ml(showopts, m=1000, c=1e-5)
show estar.output
smpl @all