function yf=bpf(y,up,dn,K); % bpf.m % Program to computeband-pass filtered series % Inputs are % y : data(rows=observations, columns=series) % up : period corresponding to highest freqnency(e.g.,6) % dn : period corresponding to lowest frequency(e.g.,32) % K : number of terms in approximating moving average % [calls filtk.m(filter with symmetric weights) as subroutine] x=[up dn]; disp('') disp('bpf(y,up,dn,K):band-pass filtering of series y with symmetric MA(2K+1)') disp('') disp(' for additional information see:') disp('') disp(' M.Baxter and R.G King ') disp('') disp(' Measuring Business Cycles: ') disp(' Approximate Band-Pass Filters') disp(' for Macroeconomic Time Series') disp('') disp('Filter extracts components between periods of:') disp(' up dn') disp(x) % pause(2) if(up>dn) disp('periods reversed: switching indices up & dn') disp('') dn=x(1);up=x(2); end if(up<2) up=2; disp('Higher periodicity>max: Setting up=2') disp('') end % convert to column vector [r c]=size(y); if(r1000) disp('dn>1000:assuming low pass filter') phi=1; else phi=0; end % sum of weights without constraint theta=akvec(1)+2*sum(akvec(2:K+1)); %amount to add to each nonzero lag/lead to get sum=phi theta=phi-(theta/(2*K+1)); % adjustment of weights akvec=akvec+theta; %filter the time series yf=filtk(y,akvec); if(r