version 10.0 set more on, permanently log using chap14, replace use returns, clear * ---------------------------------------------- * Create dates and declare time series -- method 1 * ---------------------------------------------- gen month = mod(_n-1,12) + 1 egen year = seq(), f(1988) t(2004) b(12) gen date = ym(year,month) format %tm date tsset date * ---------------------------------------------- * Create dates and declare time series -- method 2 * ---------------------------------------------- drop date gen date = m(1988m1) + _n - 1 format date %tm tsset date * ---------------------------------------------- * Time series plots and histograms * ---------------------------------------------- twoway(tsline RUS) more twoway(tsline ROZ) more twoway(tsline RJAP) more twoway(tsline RHK) more histogram RUS, normal more histogram ROZ, normal more histogram RJAP, normal more histogram RHK, normal more * ---------------------------------------------- * Load byd, create dates and declare time series * ---------------------------------------------- use byd, clear gen time = _n tsset time tsline r more * ---------------------------------------------- * LM test for ARCH(1) * ---------------------------------------------- regress r predict ehat, residual gen ehat2 = ehat * ehat regress ehat2 L.ehat2 scalar NR2 = e(N)*e(r2) scalar pvalue = chi2tail(1,NR2) scalar list NR2 pvalue * ---------------------------------------------- * Built-in LM Test for ARCH(1) * ---------------------------------------------- regress r estat archlm, lags(1) * ---------------------------------------------- * ARCH(1) * ---------------------------------------------- arch r, arch(1) predict htarch, variance tsline htarch more * ---------------------------------------------- * GARCH(1,1) * ---------------------------------------------- arch r, arch(1) garch(1) predict htgarch, variance tsline htgarch more * ---------------------------------------------- * Threshold GARCH * ---------------------------------------------- arch r, arch(1) garch(1) tarch(1) predict httgarch, variance tsline httgarch more * ---------------------------------------------- * GARCH in mean * ---------------------------------------------- arch r, archm arch(1) garch(1) tarch(1) predict m_mgarch, xb predict htmgarch, variance tsline m_mgarch more tsline htmgarch more summarize m_mgarch r, detail histogram m_mgarch, normal log close translate chap14.smcl chap14.txt, replace