Stata 1.4 (データ要約) ビデオ解説
import delimited C:\beer.csv
summarize tmp bh
correlate tmp bh
correlate tmp bh, covariance
twoway (scatter bh tmp)
Stata 1.12 (データの読み込み)
import delimited C:\beer.csv
Stata 2.4 (単回帰) ビデオ解説
import delimited C:\mm.csv
generate time=_n
tsset time
generate y=(a-L.a)/L.a*100
generate x=(topix-L.topix)/L.topix*100
regress y x
twoway (lfitci y x) (scatter y x)
Stata 3.3 (生産関数の推定と一次同次性) ビデオ解説
import delimited C:\seisan.csv
generate ly=log(y)
generate lk=log(k)
generate ll=log(l)
regress ly lk ll
display invFtail(2,21,0.05)
test (lk+ll=1)
display invFtail(1,21,0.05)
Stata 3.7 (構造変化の仮説検定) ビデオ解説
import delimited C:\ch.csv
tsset year, yearly
generate d=0
replace d=1 if year>=2001
generate dydh=d*ydh
generate dwh =d*wh
regress ch ydh wh d dydh dwh
test (d dydh dwh)
display invFtail(3,16,0.05)
補論 Stata 3.13 (シャープな回帰の不連続デザイン)
import delimited C:\srdd.csv
generate xtilde = x-40
generate dxtilde = d*xtilde
regress y xtilde d dxtilde
predict yhat, xb
twoway (scatter y x, msize(vsmall)) (scatter yhat x, msize(vsmall))
Stata 4.10 (回帰の診断)
ビデオ解説 (AICとBICの求め方) ビデオ解説 (VIFの求め方) ビデオ解説 (残差のプロット)
import delimited C:\ch2001.csv
tsset year, yearly
regress ch ydh wh
estat ic
estat vif
predict yhat, xb
predict sres, rstandard
twoway (scatter sres yhat)
twoway (tsline sres, recast(connected))
estat hettest
estat durbinalt, small
Stata 4.11 (頑健な回帰)
import delimited C:\ch2001.csv
tsset year, yearly
regress ch ydh wh, vce(robust)
newey ch ydh wh, lag(1)
prais ch ydh wh, rhotype(regress) vce(robust)
Stata 5.9 (パネルデータ)
ビデオ解説(1/5) ビデオ解説(2/5) ビデオ解説(3/5) ビデオ解説(4/5) ビデオ解説(5/5)
import delimited C:\panel.csv
regress y x
xtset id year, yearly
xtdescribe
xtsum y x
xtline y if id <=4
xtline y if id <=4, overlay
xtreg y x, fe
predict u_est, u
estimates store fixed
xtreg y x, re
estimates store random
xttest0
hausman fixed random
補論 Stata 5.11 (差の差の分析 パネルデータ) ビデオ解説
import delimited C:\scrap.csv
xtset id year, yearly
xtreg y d2 dtd2, fe
regress d.y dt
Stata 6.5 (ロジット・プロビットモデル ) ビデオ解説(1/2) ビデオ解説(2/2)
import delimited C:\vote.csv
logistic y i.x1 i.x2 x3 x4, coef
estat classification
margins, dydx(*) atmeans
probit y i.x1 i.x2 x3 x4
estat classification
margins, dydx(*) atmeans
Stata 6.10 (順序ロ ジット・プロビットモデル ) ビデオ解説
import delimited C:\mental.csv
tabulate y
ologit y i.x1 x2
predict pr1 pr2 pr3 pr4, p
oprobit y i.x1 x2
predict opr1 opr2 opr3 opr4, p
Stata 6.13 (多項ロ ジット・プロビットモデル ) ビデオ解説
import delimited C:\rate.csv
mlogit y x1-x6, baseoutcome(2)
predict pr1 pr2 pr3, p
mprobit y x1-x6, baseoutcome(2)
predict pr1 pr2 pr3, p
補論 Stata 6.17 (因果効果の分析 )ビデオ解説(1/3) ビデオ解説(2/3) ビデオ解説(3/3)
use http://www.stata-press.com/data/r16/cattaneo2.dta
generate magesq = mage*mage
teffects ipw (bweight) (mbsmoke mmarried mage magesq fbaby medu)
teffects overlap
teffects ipw (bweight) (mbsmoke mmarried mage magesq fbaby medu, probit)
teffects ipw (bweight) (mbsmoke mmarried mage magesq fbaby medu), atet
teffects aipw (bweight prenatal1 mmarried mage fbaby) (mbsmoke mmarried mage magesq fbaby medu)
teffects aipw (bweight prenatal1 mmarried mage fbaby) (mbsmoke mmarried mage magesq fbaby medu), pomeans aequations
teffects psmatch (bweight) (mbsmoke mmarried mage magesq fbaby medu)
補論 ROC曲線, 感度・特異度プロット
import delimited C:\vote.csv
logistic y i.x1 i.x2 x3 x4, coef
lroc
lsens, genprob(mycutoff) gensens(mysens) genspec(myspec)
Stata 7.4 (サンプルセレクションモデル ) ビデオ解説
import delimited C:\wage.csv
heckman wage edu year, select(work = edu year age child hinc)
Stata 7.8 (計数データモデル )
import delimited C:\poisson.csv
poisson y x
estat gof
estat ic
nbreg y x, dispersion(mean)
estat ic
Stata 7.13 (継続時間の回帰モデル)
import delimited C:\strike.csv
stset y, failure(status==1) scale(1)
streg x, distribution(weibull) nohr
stcurve, survival
stcurve, hazard
sts graph
Stata 7.14 (サンプル・セレクションモデル(2段階推定法) )
import delimited C:\wage.csv
heckman y x1...xp, twostep select(z=w1...wq) rhosigma
補論 Stata 7.15 (コックス回帰モデル )
import delimited C:\strike.csv
stset y, failure(status==1) scale(1)
stcox x, nohr
stcurve, survival
stcurve, hazard
Stata 8.8 (同時方程式の推定・検定と動的予測)
import delimited C:\klein.csv
tsset year, yearly
ivregress 2sls c L.p (p w = t wg g a L.k L.y), small
estat overid
estat endogenous
reg3 (c = p L.p w) (i = p L.p L.k) (wp = y L.y a), exog(t wg g) endog(w p y) small
estimates store kleineqs
forecast create kleinmodel
forecast estimates kleineqs
forecast identity y = c+i+g
forecast identity p=y-t-wp
forecast identity k=L.k+i
forecast identity w=wg+wp
forecast solve, begin(1937)
twoway (tsline c f_c)
Stata 8.10 (見かけ上無関係な回帰モデル )
import delimited C:\sur.csv
sureg (i_ge = f_ge k_ge) (i_ibm = f_ibm k_ibm) (i_wh = f_wh k_wh), small corr
補論 Stata 8.12 (局所平均処置効果 )
import delimited C:\late.csv
ivregress 2sls y (d = z)
補論 Stata 8.14 (ファジーな回帰の不連続デザイン )
import delimited C:\frdd.csv
generate xtilde = x-5
generate dxtilde = d*xtilde
generate z = 0
replace z = 1 if x >= 5
generate zxtilde = z*xtilde
twoway (scatter y x if d==1, msize(small) msymbol(triangle)) (scatter y x if d==0, msize(small))
twoway (scatter y x if d==1, msize(small) msymbol(triangle)) (scatter y x if d==0, msize(small)) if x >= 3 & x <=7
regress y xtilde d dxtilde
Stata 9.6 (ARMA(1,1)モデル)
import delimited C:\arma.csv
tsset time
twoway (tsline y)
ac y
pac y
arima y, arima(1,0,1)
estimates store arma11
arima y, arima(1,0,0)
estimates store ar1
arima y, arima(0,0,1)
estimates store ma1
estimates stats ar1 ma1 arma11
Stata 9.8 (単位根検定)
import delimited C:\unit.csv
tsset time
dfuller y1, trend lags(0)
dfuller y2, trend lags(1)
Stata 9.12 (共和分検定)
import delimited C:\coint.csv
tsset time
varsoc y x
vecrank y x, trend(constant) lags(1)
vec y x, trend(constant) lags(1)
Stata 9.14 (GARCHモデル)
import delimited C:\garch.csv
tsset time
arch y, arch(1) garch(1)