/* The following RATS program was used to generate Figure 1. */

cal 1947 1 12
all 2001:11
open data c:\cpi.prn
data(org=obs,format=prn) /

*The next line creates the inflation rate
set inf  = 1200*(cpi/cpi{1} - 1)

* Next, create the first difference
dif inf / dinf
* Perform a Dickey-Fuller Test
lin inf ; # constant inf{1 to 12}

* Initialize the maximum frequence at 3
com kmax = 3, up = 2*%pi*kmax/%nobs
compute rss = 10000000.

* Search using frequencies between 0 and 3 in steps of 1/512
do i = 1,512
	com w = i*up/512.
        set sinx = sin(w*t) ; set cosx = cos(w*t)
	lin(noprint) inf
	# constant sinx cosx inf{1 to 12}
	if %rss < rss
	    {
	    com wmax = w
            com rss = %rss
            }
end do i

* kstar contains the frequency with the best fir
com kstar = wmax*%nobs/(2*%pi)
dis 'The frequency is' kstar

* Estimate the model using the best fitting frequency
set sinx = sin(wmax*t)
set cosx = cos(wmax*t)
lin inf
# constant sinx cosx inf{1 to 12}
exclude ; # sinx cosx
******

* Create and scale the coefficient to fit on the graph
set coeff =  5*(%beta(1) + %beta(2)*sinx + %beta(3)*cosx) - 3

LABELS inf coeff
# 'Inflation' "Scaled Intercept"

gra(hea="Figure 1: A Structual Break in U.S. Inflation?",vla='percent per year',key=below,patterns) 2
# coeff
# inf
