You are on page 1of 25

www.wunan.com.

tw
(02)2705-5066
www.wunan.com.tw
(02)2705-5066





STaTa SPSS
SASLISREL/HLMJMulTiGretlAMOSLIMDEP Eviews STaTa
(1)
(2) vs.
(3)
FRED(4)
panel (4) (5)
(6)
STaTa vs.
STaTa
Menu Menu STaTa
longitudinal-data panel-data
OLS STaTa

STaTa

1. STaTa
2. STaTa

3. STaTa

4. Panel-data STaTa

www.wunan.com.tw I
(02)2705-5066
5. STaTa
longitudinal-data ARMAARIMAVAR
VECM STaTa
panel-data Panel-data cross sec-
tionSTaTa




ARIMAARCH/GARCHVAR/Structural VAR
VECM
http://www.softhome.com.tw STaTa
STaTa

II
www.wunan.com.tw
(02)2705-5066

Chapter
01 Stata 1

1-1 Stata ...................................................................................................2


1-2 Stata ........................................................................................ 10
1-2-1 (Entering data) ........................................................... 13
1-2-2 (Exploring data) ......................................... 23
1-2-3 (Modifying data) ........................................................ 25
1-2-4 (Managing data) ......................................................... 28
1-2-5 (Operators) ................................................. 30
1-3 adoStata Package ........................................... 32
1-4 SSC ( ) ................................................................... 34
1-5 FRED .............................. 35
1-5-1 ........................................ 35
1-5-2
.................................................................................. 38
1-5-3
................................................................ 43

III
www.wunan.com.tw
(02)2705-5066
Chapter
02 49

2-1 ......................................................................................... 52
2-1-1 .................................................................................... 52
2-1-2 ................................................................................ 55
2-1-3 .................................................................................... 56
2-2 ............................................................................. 69
2-2-1 ( ) ................................................................... 72
2-2-2 ................................................ 73
2-2-3 ................................................................ 76
2-3 ............................................................................. 77
2-4 ....................................................................................... 106
2-5 ............................................................................................... 120
2-5-1 (Dummy variable) .................................................... 121
2-5-2120 ........................................................... 129

Chapter
03 135

3-1 ....................................................................................................... 136


3-1-1 .................................................................................. 136
3-1-2 .......................................................................... 137

IV
www.wunan.com.tw
(02)2705-5066
Contents

3-2 vs. ................................................................ 140


3-2-1 (OLS) .............................................. 142
3-2-2Stata (GLS) .......................................... 161
3-2-3 .............................................................. 166
3-2-4 AR(1) .................................................. 175
3-3 JB
ARCH-LM............................................................................................. 177
3-3-1MA(q)AR(P) .................................... 181
3-3-2 .............................................................. 182
3-3-3 .................................................................. 184
3-3-4 ARCH-LM ARCH(q) ........................................ 185
3-4 Stata GDP OLS vs. .............................................. 187
3-4-1 OLS ..................................... 187
3-4-2 (Dynamic models) .................................................. 224

Chapter
04 237

4-1 ........................................................................... 240


4-1-1 .......................................................... 241
4-1-2 .............................................................. 243
4-1-3Stata ..................................................................... 253
4-2 Continuous .................................................... 266
4-2-1 ( OLS reg) ...................................... 267
4-2-2 ( OLS reg) ...................................... 273

V
www.wunan.com.tw
(02)2705-5066
4-3 (rsquare ).......................... 289
4-4 3 Prais-Winsten (praisnewey
) ..................................................................................................... 304
4-5 OLS GLS (heteroskedasticity) ............................ 315
4-5-1OLS ( reg estat hettest) .......... 319
4-5-2OLS Robust (regress,vce(robust) ) ............ 327
4-5-3 (regress,[aweight= ] ) ..... 328
4-6 Single-equation instrumental-variables ........................................ 330
4-6-1a................................. 333
4-6-1b Hausman
(hausman ) ..................................................................... 349
4-6-1c (2SLS)(ivregress 2sls ) .................. 359
4-6-2 (limited-information max likelihood)
(ivregress liml ) ................................................................ 369
4-6-3 (Generalized Method of Moments)(ivregress
gmm ) ............................................................................... 371
4-7 (three-stage) (reg3 ) ........................................ 376
4-7-1 vs. ........................ 377
4-7-2 vs. ........ 386

Chapter
05 (Unit Root) 397

5-1 ............................................................................................... 399


5-1-1 .......................................................................... 401

VI
www.wunan.com.tw
(02)2705-5066
Contents

5-1-2 .......................................................... 402


5-1-3 .................................................................. 407
5-1-4 ...................................................................... 410
5-1-5 .......................................................... 413
5-1-5aDickey-Fuller(DF) ............................................ 414
5-1-5bAugmented Dickey-Fuller(ADF) ....................... 417
5-1-5cPhillips & Perron(PP) ........................................ 420
5-1-5dKPSS .................................................................. 420
5-2 Stata .............................................................................. 421
5-3-1Augmented Dickey-Fuller (ADF) ........................ 426
5-3-2DF-GLS ............................................................... 439
5-3-3Phillips-Perron ..................................................... 442
5-3 (rst-difference) .................................... 444

Chapter
06 ARIMA 447

6-1 ARIMA ......................................................................................... 448


6-1-1ARIMA(p,d,q) vs. GARCH(p,q) .............................................. 450
6-1-2ARIMA ........................................................ 451
6-1-3ARIMA .................................................................... 453
6-1-4 .......................................................... 454
6-1-5ARIMA (postestimation command) .................... 456
6-2 (MA) ........................................................ 457
6-2-1MA(1) .............................................................................. 460

VII
www.wunan.com.tw
(02)2705-5066
6-2-2MA(2) .............................................................................. 463
6-2-3MA(q) .............................................................................. 465
6-2-4Stata MA(q) ............................................................ 467
6-3 (AR) ......................................................... 481
6-3-1AR(1) ............................................................................... 483
6-3-2AR(2) ............................................................................... 488
6-3-3Stata AR(p) ............................................................. 492
6-4 ARIMA .................................................................... 504
6-4-1ARIMA(p,d,q) ..................................................... 504
6-4-2ARIMA(p,0,q) ..................................................... 508
6-5 Stata ARIMA(p,d,q) .................................... 510
6-5-1ARIMA(1,1,4) ..................................................... 511
6-5-2Diebold-Mariano ...................................... 538

Chapter
07 ARCH-GARCH
MGARCH 543

7-1 ARCH(q) .................................................................................. 546


7-1-1 .................................................................. 547
7-1-2ARCH- GARCH ...................................................... 553
7-1-3 ARCH ................................................................. 555
7-2 GARCH(p, q) .................................................................. 561
7-3 GARCH ................................................... 565

VIII
www.wunan.com.tw
(02)2705-5066
Contents

7-4 MGARCH ................................................................................ 569


7-4-1 (multivariate) GARCH ....................................... 570
7-4-2Multivariate GARCH(1,1)BEKK ................................ 572
7-5 Stata ARCH/GARCH ....................................................... 579
7-5-1ARCH .............................................................................. 579
7-5-2 ARCH (Menu) .................................................... 588
7-6 Stata GARCH p q .............................................. 589
7-7 Stata ARCH/GARCH ............................................................... 600
7-7-1ARCH .............................................................................. 601
7-7-2ARCH Model with ARMA process .......................................... 608
7-7-3EGARCH ................................................. 612
7-7-4Asymmetric power ARCH model ............................................. 617
7-7-5ARCH model with nonnormal error ......................................... 624
7-7-6ARCH model with contraints ................................................... 629
7-8 Stata multivariate GARCH(p,q) ................................. 634

Chapter
08 ( )VECM 645

8-1 ........................................................................................... 651


8-1-1 .................................................................. 652
8-1-2 .................................................................. 653
8-1-3 (VECM) ................................................... 659
8-1-4 .......................................... 660
8-2 Granger ..................................................................... 661

IX
www.wunan.com.tw
(02)2705-5066
8-3 Stata cointegration .................................................... 665
8-3-1cointegration ............................................................ 665
8-3-2Stata cointegration ............................................... 668

Chapter
09
VECM 687

9-1 VECM .................................................................. 691


9-1-1VECM .................................................................. 692
9-1-2 .................................................. 693
9-2 (VECM) ................................................................ 694
9-2-1 .............................................................................. 695
9-2-2 (ECM) (VECM) .......... 701
9-3 Stata VECM ....................................................................... 702
9-3-1 Stata multivariate VECM ........................... 702
9-3-2Johansen VECM .......................................................... 703
9-3-3Stata VECM ................................................. 705

Chapter
10
VAR 759

10-1 ................................................................................... 761

X
www.wunan.com.tw
(02)2705-5066
Contents

10-1-1 ............................................................ 761


10-1-2VARVECM ............................................ 765
10-1-3VAR ........................................................................... 769
10-1-4VAR VECM ...................................................... 771
10-2 (VAR) ................................................................... 773
10-2-1VAR VAR(1) ................................. 774
10-2-2a (structural form)
(reduced form) ...................................................................... 786
10-2-2bStructural VARReduced-form VARRecursive VAR ..... 790
10-2-3Stata VAR ......................................................... 798
10-2-4Sims VAR(p) .................................................................. 803
10-2-5Diebold-Mariano .................................... 807
10-2-6VAR ............................................................... 809
10-3 VAR .................................................................................. 811
10-3-1Granger .......................................................... 811
10-3-2Stata JMulTi VAR ................................ 814
10-3-3 ........................................................................ 816
10-3-4 (FEVD) .............................................. 822
10-4 ................................................................................... 827
10-4-1 Chow ............................................................. 829
10-4-2Chow test chowreg ............................................ 831
10-4-3 Chow test suchowtest ........................... 839
10-4-4 Chow test suchowtest ........... 853
10-4-5Chow (LR) ................................................ 864
10-4-6Threshold autoregression for time-to-event analysis .............. 866
10-5 Stata VAR ........................................................................ 873

XI
www.wunan.com.tw
(02)2705-5066
10-5-1Stata VAR ......................................................... 875
10-5-2Stata 1 VAR .............................................. 876
10-5-3Diebold-Mariano ........................ 929
10-5-4Stata 2VAR model with exogenous variables ............ 932
10-5-5Stata 3VAR model with constraints ........................... 936

Chapter
11 Structural VAR
(SVAR) 941

11-1 SVAR ............................................................................................ 942


11-1-1Structural VAR SVAR(1) .......... 946
11-1-2Structural VAR ........................................................... 953
11-1-3Stata SVAR ........................................................ 964
11-1-4 SVAR A-B Stata ....................................... 964
11-1-5 Blanchard-Quah SVAR ......................................... 974
11-1-6SVAR ......... 977
11-2 Stata Structural VAR ........................................................... 985
11-2-1 Structural SVAR(A-B ) ............................................. 985
11-2-2 Blanchard-Quah SVAR .................................................. 996

1019

XII
www.wunan.com.tw
(02)2705-5066
t e r
p

01
a
Ch

Stata

www.wunan.com.tw
(02)2705-5066
Stata

Stata analysis Stata v12


CD *.dta Excel *.csv (
)StataData Edit

1-1 Stata
Stata (Computer Resource Center)


1985
Menu Stata
Stata (multilevel mixed
models) (exact logistic regression) (multiple
correspondence analysis) (time-and-date variables)
(www.stata.com) Stata regress
screenshot
Stata Stata


Stata (survival
models with frailty) (dynamic panel data regressions)
(GEE)ARCH
(GLM) / (regressions
with count or binary outcomes)ANOVA/ MANOVA
(autoregressive integrated moving average model, ARIMA)
(standardization of rates) (casecontrol analysis)
(structural equation modeling, SEM)Contrasts and pairwise comparisons
(multiple imputation) Time series(UCM--unobserved-components
modelsARFIMASpectral density with parametric estimates after ARIMA,
ARFIMA and UCM)Stata Stata

2
www.wunan.com.tw
(02)2705-5066
Chapter
Stata 01

Stata
excel byte
integerlongfloatdouble stringStata
panel/longitudinal (binaryordered
Multinomialcount ) ( )


Stata regression fit
distributional plots (Poisson Zero-inated Poisson )
time-series graphs survival plots

Stata (www.stata.com)
1-1

www.wunan.com.tw3
(02)2705-5066
Stata

1-1 Stata (www.stata.com/stata13/)

4
www.wunan.com.tw
(02)2705-5066
Chapter
Stata 01
Stata
(linear models)
regression; bootstrap, jackknife, and robust Huber/White/sandwich variance estimates;
instrumental variables; three-stage least squares;constraints; quantile regression; GLS
(multilevel mixed-effects models)
continuous, binary, and count outcomes; two-, three-, and multi-way random-intercepts
and random-coefficients models; crossed random effects; ML and REML estimation;
BLUPs of effects and fitted values; hierarchical models
(binary, count, and limited dependent variables)
logistic, probit, tobit; Poisson and negative-binomial; conditional, multinomial, nested,
ordered, rank-ordered, and stereotype logistic; multinomial probit; zero-inflated and
zero-truncated count models; selection models; marginal effects
/ / (panel data/cross-sectional/time-series)
random- and fixed-effects with robust standard errors, linear mixed models, random-
effects probit, GEE, random- and fixed-effects Poisson, dynamic panel data models, and
instrumental variables regression; AR(1) disturbances
(GLM)(generalized linear models, GLMs)
ten link functions, user-defined links, seven distributions, ML and Iteratively Reweighted
Least Square(IRLS) estimation, nine variance estimators, seven residuals
(nonparametric methods)
WilcoxonMannWhitney, Wilcoxon signed ranks and KruskalWallis tests; Spearman
and Kendall correlations; KolmogorovSmirnov tests; exact binomial CIs
(exact statistics)
exact logistic and Poisson regression, exact casecontrol statistics, binomial tests, Fishers
exact test for r c tables
ANOVA/MANOVA
balanced and unbalanced designs; factorial, nested, and mixed designs; repeated
measures
(multivariate methods)
factor analysis; principal components; discriminant analysis; rotation; multidimensional
scaling; Procrustean analysis; correspondence analysis; biplots; dendrograms; user-
extensible analyses
Cluster analysis
hierarchical clustering; kmeans and kmedian nonhierarchical clustering; dendrograms;
stopping rules; user-extensible analyses

www.wunan.com.tw5
(02)2705-5066
Stata

(resampling and simulation methods)


bootstrapping, jackknife and Monte Carlo simulation; permutation tests
Model testing and postestimation support
Wald tests; LR tests; linear and nonlinear combinations, tests, and predictions; marginal
effects; adjusted means; Hausman tests
(graphics)
line charts, scatterplots, bar charts, pie charts, hilo charts, Graph editor, regression
diagnostic graphs, survival plots, nonparametric smoothers, distribution QQ plots
(survey methods)
sampling weights, multistage designs; stratification, poststratification; deff; means,
proportions, ratios, totals; summary tables; bootstrap, jackknife, and linearization-based
variance estimation; regression, instrumental variables, probit, Cox regression
(survival analysis)
KaplanMeier and NelsonAalen estimators, Cox regression (frailty); parametric models
(frailty); hazards; time-varying covariates; left and right censoring, Weibull, exponential,
and Gompertz analysis; sample size and power analysis
(tools for epidemiologists)
standardization of rates, casecontrol, cohort, matched casecontrol, MantelHaenszel,
pharmacokinetics, ROC analysis, ICD-9-CM
(time series)
ARIMA, ARCH/GARCH, VAR, VECM, high-frequency data, correlograms,
periodograms, white-noise tests, unit root tests, HoltWinters smoothers, Haver Analytics
data, rolling and recursive estimation
Maximum likelihood
user-specified functions; NR, DFP, BFGS, BHHH; OIM, OPG, robust, bootstrap, and
jackknife matrices; Wald tests; survey data; numeric or analytic derivatives
Transforms and normality tests
BoxCox transforms, power transforms, ShapiroWilk and ShapiroFrancia tests
(other statistical methods)
sample size and power, nonlinear regression, imputations, stepwise regression, statistical
and mathematical functions
/ (programming language)
adding new commands, command scripting, if, while, command parsing, debugging,
menu and dialog-box programming, markup and control language

6
www.wunan.com.tw
(02)2705-5066
Chapter
Stata 01
(matrix programmingMata)
interactive sessions, large-scale development projects, optimization, matrix inversions,
decompositions, eigen values and eigenvectors, LAPACK engine, real and complex
numbers, string matrices, interface to Stata datasets and matrices
(SEM)
(SEM)
(SEM)
(Factor analysis) (path
analysis) OLS SEM SEM (1)
(Measurement invariance) MCFA IRT-LR
DFIT (2) (Multiple group modeling)(3) Latent growth
modeling(4) (Hierarchical/multilevel) (4)
(item response theory models)(5) Mixture model (latent class) SEMStata
Robust Survey (Multi-
method multi-trait models)SEM (Trees) Structural Equation Models
(decision trees)

www.wunan.com.tw7
(02)2705-5066
Stata

Stata
http://www.ats.ucla.edu/stat/stata/ado/analysis/

1-2 Stata http://www.ats.ucla.edu/stat/stata/ado/analysis/

8
www.wunan.com.tw
(02)2705-5066
Chapter
Stata 01
Stata
http://www.softhome.com.tw/html/

1-3 (http://www.softhome.com.tw)

www.wunan.com.tw9
(02)2705-5066
Stata

1-2 Stata
Stata
Stata 4.03MB
SETUP SnCode Key
Intercooled
Small
Intercooled

1-4 Stata


Stata > > Stata
Stata

10
www.wunan.com.tw
(02)2705-5066
Stata
. ., 2016.11

ISBN 978-957-11-8862-1 ()

1.2.

512.4 105018098

1HA8

Stata

106 3 3 9 4

(02)2705-5066(02)2706-6100

http://www.wunan.com.tw

wunanwunan.com.tw

0 1 0 6 8 9 5 3

2 0 1 6 1 1

1 0 0 0


www.wunan.com.tw
(02)2705-5066