---------------------------------------------------------------------------------------------------------------------------------- name: log: C:\Users\rwr\Dropbox\basu-house\build\code\../temp/fred4cycregs.log log type: text opened on: 17 Jul 2016, 12:11:48 . /*********************************************************************************************/ > > /*** Smoothing parameters ***/ > local smooth_macrowage = 1600; . local smooth_ur = 500000; . /*** QUARTERLY > Nonfarm Business Sector: Real Compensation Per Hour > 2015:Q2: 102.409 Index 2009=100 (+ see more) > Quarterly, Seasonally Adjusted, COMPRNFB, Updated: 2015-09-02 10:01 AM CDT > > Nonfarm Business Sector: Compensation Per Hour > 2015:Q3: 113.938 Index 2009=100 (+ see more) > Quarterly, Seasonally Adjusted, COMPNFB, Updated: 2015-11-05 8:51 AM CST > > Nonfarm Business Sector: Implicit Price Deflator > 2015:Q3: 109.194 Index 2009=100 (+ see more) > Quarterly, Seasonally Adjusted, IPDNBS, Updated: 2015-11-05 8:51 AM CST > > Real Gross Domestic Product > 2015:Q2: 16,324.3 Billions of Chained 2009 Dollars (+ see more) > Quarterly, Seasonally Adjusted Annual Rate, GDPC1, Updated: 2015-08-27 8:51 AM CDT > ***/ > /*** first grab CPI to deflate "Macro Wage" > Consumer Price Index for All Urban Consumers: All Items > 2015-09: 237.566 Index 1982-1984=100 (+ see more) > Monthly, Seasonally Adjusted, CPIAUCSL, Updated: 2015-10-15 8:11 AM CDT > ***/ > freduse CPIAUCSL, clear; (834 observations read) . gen datem = mofd(daten); . gen dateq = qofd(daten); . rename CPIAUCSL cpi; . gen junk1 = cpi if datem == ym(2009,1); (833 missing values generated) . egen junk2 = max(junk1); . replace cpi = 100*cpi/junk2; (834 real changes made) . collapse cpi, by(dateq); . keep cpi dateq; . save `tempdata'cpi_temp, replace; (note: file ../temp/cpi_temp.dta not found) file ../temp/cpi_temp.dta saved . freduse COMPRNFB COMPNFB IPDNBS GDPC1, clear; (277 observations read) (277 observations read) (277 observations read) (277 observations read) . gen dateq = qofd(daten); . tsset dateq; time variable: dateq, -52 to 224 delta: 1 unit . gen year = yofd(daten); . rename COMPRNFB macrowage; . rename GDPC1 rgdp; . gen lmacrowage = log(macrowage); . gen lrgdp = log(rgdp); . gen lmacrowage_ipd = log(100*COMPNFB/IPDNBS); . merge 1:1 dateq using `tempdata'cpi_temp, keep(master match) nogen; Result # of obs. ----------------------------------------- not matched 0 matched 277 ----------------------------------------- . gen lmacrowage_cpi = log(100*COMPNFB/cpi); . tsline lmacrowage lmacrowage_ipd lmacrowage_cpi; . hprescott lrgdp, stub(hp) smooth(`smooth_macrowage'); . rename hp_lrgdp_sm_1 hp_lrgdp_trend; . rename hp_lrgdp_1 hp_lrgdp_twiddle; . collapse macrowage lmacrowage lmacrowage_cpi lmacrowage_ipd hp_lrgdp_trend hp_lrgdp_twiddle, by(year); . la var macrowage "Nonfarm Business Sector: Compensation Per Hour"; . la var lmacrowage "Log(Nonfarm Business Sector: Compensation Per Hour)"; . la var hp_lrgdp_trend "Trend real GDP (smooth = `smooth_macrowage')"; . la var hp_lrgdp_twiddle "Cyclical component of real GDP (smooth = `smooth_macrowage')"; . save `tempdata'macrowage, replace; (note: file ../temp/macrowage.dta not found) file ../temp/macrowage.dta saved . tsset year; time variable: year, 1947 to 2016 delta: 1 unit . tsline hp_lrgdp_twiddle if year >= 1978, lc(dknavy) lw(0.8) > xtitle("") ytitle("Log(Billions of Chained 2009 Dollars)") ylabel(,angle(h) grid) > xlabel(1978(5)2014) xmtick(1978(1)2014) > plotregion(lstyle(none)) yscale(noline axis(1)) > yline(0, lc(black)) > legend(label(1 "HP Filtered GDP") region(lstyle(none))); . graph export `slides'fig_`prg'_hp_lrgdp_twiddle.eps, logo(off) replace; (note: file ../../slides/fig_fred4cycregs_hp_lrgdp_twiddle.eps not found) (file ../../slides/fig_fred4cycregs_hp_lrgdp_twiddle.eps written in EPS format) . /****************************************************************************/ > /*** PADDED UNEMPLOYMENT RATE ***/ > /****************************************************************************/ > /*** MONTHLY FOR OUT-OF-SAMPLE FORECAST > Civilian Unemployment Rate > 2015-11: 5.0 Percent (+ see more) > Monthly, Seasonally Adjusted, UNRATE, Updated: 2015-12-04 8:01 AM CST > ***/ > freduse UNRATE, clear; (822 observations read) . gen datem = mofd(daten); . tsset datem; time variable: datem, -144 to 677 delta: 1 unit . format datem %tm; . /*** Need to change start of prediction as update data ***/ > local pstart_temp = r(tmax); . local pstart_temp = `pstart_temp' + 1; . local pstart_year : di %tm+CCYY `pstart_temp'; . local pstart_month : di %tm+nn `pstart_temp'; . local pstart : di %tm `pstart_temp'; . local pstartm `pstart_year',`pstart_month'; . di "`pstart_temp'"; 678 . di "`pstart'"; 2016m7 . di "`pstart_year'"; 2016 . di "`pstart_month'"; 7 . di "`pstartm'"; 2016, 7 . rename UNRATE ur; . drop if datem < ym(1985,1); (444 observations deleted) . /* add 10 years = 12*10 = 120 */ > tsappend, add(120); . arima ur L(1/6).ur; (setting optimization to BHHH) Iteration 0: log likelihood = 195.74599 Iteration 1: log likelihood = 195.74599 ARIMA regression Sample: 1985m7 - 2016m6 Number of obs = 372 Wald chi2(6) = 43444.65 Log likelihood = 195.746 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ | OPG ur | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ur | ur | L1. | .9588796 .0454978 21.08 0.000 .8697056 1.048054 L2. | .1526784 .0694113 2.20 0.028 .0166348 .288722 L3. | .069932 .0769771 0.91 0.364 -.0809403 .2208044 L4. | -.0550719 .0757202 -0.73 0.467 -.2034806 .0933369 L5. | .0750784 .0724534 1.04 0.300 -.0669276 .2170845 L6. | -.2147232 .0467267 -4.60 0.000 -.3063057 -.1231406 | _cons | .0777431 .0319406 2.43 0.015 .0151407 .1403454 -------------+---------------------------------------------------------------- /sigma | .1429676 .0046706 30.61 0.000 .1338134 .1521217 ------------------------------------------------------------------------------ Note: The test of the variance against zero is one sided, and the two-sided confidence interval is truncated at zero. . predict urhat if tin(`pstart',), dynamic(tm(`pstartm')); (option xb assumed; predicted values) (378 missing values generated) . la var urhat "dynamic UR forecast"; . tsline ur urhat, lc(dknavy red) lw(0.8 0.8) > xtitle("") ytitle("Percent") ylabel(,angle(h) grid) > tlabel(1985m1(120)2020m1) tmtick(1985m1(12)2020m1) > plotregion(lstyle(none)) yscale(noline axis(1)) > /* yline(0, lc(black)) */ > legend(label(1 "Unemployment Rate") label(2 "Dynamic Forecast") region(lstyle(none))); . graph export `slides'fig_`prg'_ur_forecast.eps, logo(off) replace; (note: file ../../slides/fig_fred4cycregs_ur_forecast.eps not found) (file ../../slides/fig_fred4cycregs_ur_forecast.eps written in EPS format) . keep if datem >= ym(`pstartm'); (378 observations deleted) . /* first forecast period */ > save `tempdata'ur_extended, replace; (note: file ../temp/ur_extended.dta not found) file ../temp/ur_extended.dta saved . /*** MONTHLY > Employment Cost Index: Total compensation: All Civilian > 2015:Q2: 123.8 Index Dec 2005=100 (+ see more) > Quarterly, Seasonally Adjusted, ECIALLCIV, Updated: 2015-07-31 9:01 AM CDT > > Civilian Unemployment Rate > 2015-07: 5.6 Percent (+ see more) > Monthly, Not Seasonally Adjusted, UNRATENSA, Updated: 2015-08-07 8:06 AM CDT > ***/ > freduse UNRATE CPIAUCSL UNRATENSA /* ECIALLCIV */, clear; (822 observations read) (834 observations read) (822 observations read) . gen year = yofd(daten); . gen datem = mofd(daten); . format datem %tm; . rename UNRATE ur; . tsset datem; time variable: datem, 1947m1 to 2016m6 delta: 1 month . /*** Base HP trend on "padded" UR series ***/ > append using `tempdata'ur_extended; . replace ur = urhat if datem >= ym(`pstartm'); (120 real changes made) . hprescott ur, stub(hp) smooth(`smooth_ur'); . drop if datem >= ym(2015,1); (138 observations deleted) . /* drop if datem >= ym(2015,2); */ > > rename hp_ur_sm_1 ur_trend; . rename hp_ur_1 hp_ur; . la var ur_trend "Trend unemployment rate (smooth=`smooth_ur')"; . la var hp_ur "Cyclical component of unemployment rate (smooth=`smooth_ur')"; . preserve; . gen dateq = qofd(daten); . format dateq %tq; . collapse (mean) ur ur_trend hp_ur, by(dateq); . la var ur "Quarterly avg of monthly values of SA unemployment rate"; . la var ur_trend "Quarterly avg of monthly values of trend ur (smooth=`smooth_ur')"; . la var hp_ur "Quarterly avg of monthly values of cyclical component of UR (smooth=`smooth_ur')"; . save `myinput'fred_quarterly, replace; file fred_quarterly.dta saved . restore; . collapse (mean) ur ur_trend hp_ur, by(year); . la var ur "Annual avg of monthly values of SA unemployment rate"; . la var ur_trend "Annual avg of monthly values of trend ur (smooth=`smooth_ur')"; . la var hp_ur "Annual avg of monthly values of cyclical component of UR (smooth=`smooth_ur')"; . tsset year; time variable: year, 1947 to 2014 delta: 1 unit . tsline ur ur_trend if year >= 1978, lc(dknavy maroon) lw(0.8 0.8) > xtitle("") ytitle("Percent") ylabel(,angle(h) grid) > tlabel(1978(5)2014) tmtick(1978(1)2014) > plotregion(lstyle(none)) yscale(noline axis(1)) > yline(0, lc(black)) > legend(label(1 "Unemployment Rate") label(2 "HP Trend") region(lstyle(none))); . graph export `slides'fig_`prg'_ustar_padded.eps, logo(off) replace; (note: file ../../slides/fig_fred4cycregs_ustar_padded.eps not found) (file ../../slides/fig_fred4cycregs_ustar_padded.eps written in EPS format) . merge 1:1 year using `tempdata'macrowage, keep(match) nogen; Result # of obs. ----------------------------------------- not matched 0 matched 68 ----------------------------------------- . save `myoutput'`prg'_data, replace; (note: file ../output/fred4cycregs_data.dta not found) file ../output/fred4cycregs_data.dta saved . end of do-file . do fred2dta.do; . /****************************************************************** > Program: fred2dta.do > Purpose: Get data from FRED and put into Stata-readable format. > > * The QUARTERLY data needs to be run before the MONTHLY data because > some of the quarterly data will be interpolated to a monthly > frequency and saved as part of the monthly dataset. > > Date Started: 20 Dec 2015 > Date Revised: 14 Jul 2016 > ******************************************************************/ . #delimit ; delimiter now ; . clear all; . set mo off; . set scheme s1color; . capture log close;