clear cd D:\teaching\stata\time_series /* ワーキングディレクトリの指定 */ set logtype text log using mdemand.txt, replace /* logファイル名の指定 */ import delimited mdemand.csv, clear /* データファイルの読込 */ drop t /* 変数tを削除 */ gen t = tq(1967q1)+_n-1 /* 1967年第1四半期から始まる四半期データを示す変数tを新規作成 */ order t m p y r /* 変数の並べ替え */ format t %tq tsset t /* Stata上で時系列設定 */ gen mp = m/p /* 実質マネーストック */ gen lmp = ln(mp) /* 実質マネーストックの自然対数 */ gen ly = ln(y) /* 実質GDPの自然対数 */ tsline lmp ly /* 時系列プロット */ graph export tsplot1.tif, replace tsline r /* 時系列プロット */ graph export tsplot2.tif, replace scatter lmp ly /* 散布図 */ graph export lmp_ly.tif, replace scatter lmp r /* 散布図 */ graph export lmp_r.tif, replace reg lmp ly r, robust /* 最小2乗推定 (EHW-SE) */ estimates store reg1 estimates table reg1, b(%9.4f) se stats(N r2 r2_a) stfmt(%9.4f) style(noline) log close