* * SV.RPF * RATS Version 8, User's Guide, Example 10.2 * open data xrates.xls data(format=xls,org=columns) 1 946 usxuk usxger usxjpn usxsui * * meanx2=mean of log chi-square,varx2=variance of log chi-square * compute meanx2=%digamma(0.5)-log(0.5) compute varx2 =%trigamma(0.5) * * The "gamma" and "phi" variables are very highly correlated when phi is near 1, * which makes estimation by general hill-climbing procedures somewhat tricky. * Instead, we reparameterize this to use gammax=gamma(1-phi) in place of gamma. * set dlogp = log(usxuk{0}/usxuk{1}) diff(center) dlogp / demean nonlin phi sw gammax set ysq = log(demean**2)-meanx2 * * Get initial guess values from ARMA(1,1) model * boxjenk(ar=1,ma=1,constant,noprint) ysq * * phi is taken directly as the AR(1) coefficient The variance sw is backed out by * matching first order autocorrelations in the MA term. gamma is chosen to * reproduce the mean of the ysq series * compute phi=%beta(2),sw=-phi*varx2*(1+%beta(3)**2)/%beta(3)-(1+phi**2)*varx2 compute sw=%if(sw<0,.1,sw) compute gammax=%mean * * Estimate the unconstrained model * dlm(method=bfgs,sw=sw,sv=varx2,y=ysq,type=filter,c=1.0, $ sx0=sw/(1-phi**2),x0=gammax,a=phi,z=gammax*(1-phi)) 2 * states * * Estimate the RW model * nonlin sw dlm(method=bfgs,sw=sw,sv=varx2,y=ysq,type=filter,c=1.0, $ exact,a=1.0,vhat=e,svhat=s) 2 * states