C ----------------------------------------------------------------------
C SR: hpfilt
C Kalman smoothing routine for HP filter written by E Prescott.
C y=data series, d=deviations from trend, t=trend, n=no. obs,
C s=smoothing parameter (eg, 1600 for std HP).
C Array v is scratch area and must have dimension at least 3n.
C If IOPT=1 and n and s are the same as for the previous call,
C the numbers in v are not recomputed. This reduces execution
C time by about 30 percent. Note that if this option is exercised,
C v cannot be used for other purposes between calls.
C This version does NOT release the trend in order to save memory.
C ----------------------------------------------------------------------
SUBROUTINE HPFILT(Y,D,V,N,S,IOPT)
REAL*8 Y(144),T(144),V(144,3),D(144),SS
REAL*8 M1,M2,V11,V12,V22,X,Z,B11,B12,B22,DET,E1,E2,S
INTEGER*2 IOPT,NN,I,I1,IB,N
DATA SS,NN/0.D0,0/
C
C compute sequences of covariance matrix for f[x(t),x(t-1) | y(