*********************************************************************************** * ewar(final).prg * This RATS code estimates the extent to which movements in the change of the * exchange rate (ds) is due to movements in the unobservable shock nu. This * is quantified by the ratio variance(nu)/variance(ds). * This program only applies to bivariate AR processes. *********************************************************************************** * The methodology is due to Charles Engel and Kenneth West (2003). * Department of Economics. University of Wisconsin-Madison. * Program written by Camilo E. Tovar * Last updated November 16 2003. *********************************************************************************** disp 'PROGRAM USED: ewar(final)' CAL 1974 1 4 ALL 200 2003:1 OPEN DATA C:\Documents and Settings\ctovar\My Documents\Charles PA JOB\RATS\NEW\data_ew.rat DATA(FORMAT=wk1,ORG=obs) / s_ca mm_ca pp_ca yy_ca ii_ca mmyy_ca mmpp_ca mmsw_ca mmswyy_ca mmswpp_ca ppii_ca DATA(FORMAT=wk1,ORG=obs) / s_fr mm_fr pp_fr yy_fr ii_fr mmyy_fr mmpp_fr mmsw_fr mmswyy_fr mmswpp_fr ppii_fr DATA(FORMAT=wk1,ORG=obs) / s_ge mm_ge pp_ge yy_ge ii_ge mmyy_ge mmpp_ge mmsw_ge mmswyy_ge mmswpp_ge ppii_ge DATA(FORMAT=wk1,ORG=obs) / s_it mm_it pp_it yy_it ii_it mmyy_it mmpp_it mmsw_it mmswyy_it mmswpp_it ppii_it DATA(FORMAT=wk1,ORG=obs) / s_jp mm_jp pp_jp yy_jp ii_jp mmyy_jp mmpp_jp mmsw_jp mmswyy_jp mmswpp_jp ppii_jp DATA(FORMAT=wk1,ORG=obs) / s_uk mm_uk pp_uk yy_uk ii_uk mmyy_uk mmpp_uk mmsw_uk mmswyy_uk mmswpp_uk ppii_uk *********************************************************************************** * declare variables used decl series residuo decl rect A decl rect B decl real eta decl real z ******* SET THE FUNDAMENTAL: 1=MM ; 2=PP ; 3=YY ; 4=ii ; 5=MMYY **************** ******* 6=MMPP ; 7=MMSW ; 8=MMSWYY ; 9=MMSWPP ; 10=PPII **************** comp k=8 *********************************************************************************** print / 205 203 Dofor i=201 212 223 234 245 256 disp '****************************************************************' dofor j=1 2 3 4 if j==1; comp bvalue=0.9 else if j==2; comp bvalue=0.95 else if j==3; comp bvalue=0.99 else if j==4; comp bvalue=1 else; disp 'WARNING !!!!!! REVISE PROGRAM' disp 'COUNTRY DATA FOR:' if i==201; disp 'CANADA' else if i==212; disp 'FRANCE' else if i==223; disp 'GERMANY' else if i==234; disp 'ITALY' else if i==245; disp 'JAPAN' else if i==256; disp 'UNITED KINGDOM' else; disp 'WARNING !!!!!! REVISE PROGRAM' *end if disp '****************************************************************' comp s=i comp f=i+k disp 'THE SERIES BEING USED BY THE PROGRAM ARE:' disp 'EXCHANGE RATE:' %l(i) s disp 'FUNDAMENTAL:' %l(f) f disp '****************************************************************' disp 'THE DISCOUNT FACTOR IS:' bvalue disp '****************************************************************' ********************* Parameters Setting ************************* comp start=%cal(1974,1) ;** start: The start date of sample period comp end=%cal(2003,1) ;** end: The end date of sample period comp tlags = 4 ;** tlags: number of lags ****************************************************************** disp 'The number of lags being used is:' tlags *Take the first difference of the exchange rate and fundamentals diff s / ds diff f / df *print / s ds f df disp '****************************************************************' * Estimate autoregressive process and save residuals as residuo * also take the estimated coefficients and put them into a matrix A1 * multiply the coefficients by bvalue^lags and display it as matrix B * next, calculate the variance of the residuals SYSTEM(MODEL=EXMODEL) VARIABLES df LAGS 1 TO tlags DET constant END(SYSTEM) *DECLARE VECT[series] RESIDS8 *declare series residuo ESTIMATE(print,RESIDS=RESIDS8,coeffs=coef) start end residuo compute A1= %xsubmat(coef,1,tlags,1,1) *display 'A1' A1 *print / resids8 residuo *declare rect A dim A(1,tlags) comp A = %const(0) dofor i = 1 to tlags comp A(1,i) = A1(i,1) end dofor disp 'The values displayed should coincide with the regression coefficients' disp 'A' A *declare rect B dim B(1,tlags) comp B = %const(0) dofor i=1 to tlags comp be=bvalue**i comp B(1,i)= be*A(1,i) end dofor disp 'The output for A*(bvalue^lag) is' B disp '****************************************************************' * Calculate the variance of the residuals inquire(series=residuo) initial last disp 'The effective sample to be used is:' %datelabel(initial) %datelabel(last) disp '****************************************************************' statistics(noprint) residuo initial last comp varresiduo = %variance disp 'The variance of residuals is: ' varresiduo disp '****************************************************************' * Calculate eta matrix *decl real eta comp eta = 1 dofor i=1 to tlags compute phi= B(1,i) compute eta=eta-phi end dofor disp 'The inverse of zeta is: ' eta comp zeta = inv(eta) *decl real z comp z=zeta(1,1) disp 'The value for zeta is: ' z disp '****************************************************************' * Calculate dshat * then calculate its variance * Finally calculate nu=variance(ds)-var(dshat) set dshath = z*residuo statistics(noprint) dshath initial last comp vardshath = %variance comp obsavailable=%nobs disp 'The variance of dshath is: ' vardshath *comp comienzo=%regstart(dshath) disp '****************************************************************' *Calculate and display the variance of ds adjusted by missing observations statistics(noprint) ds initial last comp vards = %variance disp 'The variance of ds for the adjusted sample is:' vards disp '****************************************************************' * Calculate nu set nu = ds-dshath statistics(noprint) nu initial last comp varnu = %variance disp 'The variance of nu=variance(ds)-variance(dshath)is:' varnu disp '****************************************************************' * Calculate the ratio of the variance of nu to the variance of ds comp ratio = varnu/vards disp 'The ratio of variance(nu)to var(ds) is: ' ratio disp '****************************************************************' * Calculate the ratio of the variance of dshath to the variance of ds comp ratiods = vardshath/vards disp 'The ratio of the variances dshath to ds is: ' ratiods disp '****************************************************************' * Calculate the covariance of ds and dshath cross(covariances) ds dshath initial last 0 0 covadsdsh disp '****************************************************************' * Calculate zeta(bvalue)^2*variance(residuals) comp z2varres = (z**2) * varresiduo disp 'The value for zeta(bvalue)^2*var(residuals): ' z2varres disp '' disp '' end dofor * The series must be cleaned before being used again in the loop clear s ds f df disp '' disp '' end dofor