You are on page 1of 38

2.

11(p24)
1 2.1.2 E(Y|X=800) stata

sum y if x==800

Variable Obs Mean Std. Dev. Min Max


y

605 34.78505 561 638

sum y if x==1100

Variable Obs Mean Std. Dev. Min Max


y

825 121.698

638 968

sum
summarize

if

sum y if x==1400

Variable Obs Mean Std. Dev. Min Max


y

11 1045 116.3091 869 1210

2 2.1.1

twoway(scatter y x )(lfit y x ),title("


")xtitle(" ")ytitle("
")xtick(500(500)4000)ytick(0(500)3500)

Scatter
lfit title
xtick
5005004000

4000

2.31p37
stata

1
total xiyi

Total Std. Err.


xiyi

4974750

return list
scalars:
r(skip)
r(first)
r(k_term)
r(k_operator)
r(k)
r(k_level)
r(output)
r(b)
r(se)
g a=r(b) in 1
total xi2

=
=
=
=
=
=
=
=
=

1507821

[95% Conf. Interval]


1563822

0
1
0
0
0
0
1
4974750
1507820.761894463

8385678

Total return list

xiyi
b xi
a b bata

return list
g b=r(b) in 1
di a/b
.67
(2)
mean Yi

gen m=r(b) in 1
mean Xi

g n=r(b) in 1
di m-n*0.67
142.4
Y=142.4+0.67Xi

2.62(p53)

reg y x

2 X :

mean x
Mean estimation

Number of obs
Mean

11363.69

31

Std. Err.

[95% Conf. Interval]

591.7041

10155.27

12572.11

sum x ,dd detail


x
Percentiles
8871.27
8920.59
9000.35
9267.7

1%
5%
10%
25%
50%

Obs
Sum of Wgt.

9898.75

75%
90%
95%
99%

di

Smallest
8871.27
8920.59
8941.08
9000.35
Largest
16015.58
18265.1
19977.52
20667.91

12192.24
16015.58
19977.52
20667.91

31
31

Mean
Std. Dev.

11363.69
3294.469

Variance
Skewness
Kurtosis

1.09e+07
1.691973
4.739267

r(Var) Var
10853528

2.6.2P56
1reg Y X
Source

SS

df

MS

Model
Residual

2.4819e+09
30259023.9

1
27

2.4819e+09
1120704.59

Total

2.5122e+09

28

89720219.8

Coef.

X
_cons

.4375268
2091.295

Std. Err.
.0092973
334.987

t
47.06
6.24

Number of obs
F( 1,
27)
Prob > F
R-squared
Adj R-squared
Root MSE

=
29
= 2214.60
= 0.0000
= 0.9880
= 0.9875
= 1058.6

P>|t|

[95% Conf. Interval]

0.000
0.000

.4184503
1403.959

2 2.6.1
twoway (line Y X year),title(" X Y ")

.4566033
2778.632


3.2.2p72
reg Y X1 X2
Source

SS

df

MS

Model
Residual

166971988
4170092.27

2
28

83485994.2
148931.867

Total

171142081

30

5704736.02

Coef.

X1
X2
_cons

.5556438
.2500854
143.3266

Std. Err.
.0753076
.1136343
260.4032

Number of obs
F( 2,
28)
Prob > F
R-squared
Adj R-squared
Root MSE

P>|t|

7.38
2.20
0.55

0.000
0.036
0.586

=
=
=
=
=
=

31
560.57
0.0000
0.9756
0.9739
385.92

[95% Conf. Interval]


.4013831
.0173161
-390.0851

.7099046
.4828547
676.7383

3.51p85
g lnP1=ln(P1)
g lnP0=ln(P0)
g lnQ=ln(Q)
g lnX=ln(X)
Source

SS

df

MS

Model
Residual

.765670868
.017748183

3
18

.255223623
.00098601

Total

.783419051

21

.037305669

lnQ

Coef.

lnX
lnP1
lnP0
_cons

.5399167
-.2580119
-.2885609
5.53195

drop lnX lnP1 lnP0


g lnXP0=ln(X/P0)
g lnP1P0=ln(P1/P0)
reg lnQ lnXP0 lnP1P0

Std. Err.
.0365299
.1781856
.2051844
.0931071

t
14.78
-1.45
-1.41
59.41

Number of obs
F( 3,
18)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.165
0.177
0.000

=
=
=
=
=
=

22
258.84
0.0000
0.9773
0.9736
.0314

[95% Conf. Interval]


.4631703
-.632366
-.7196373
5.336339

.6166631
.1163422
.1425155
5.727561

Source

SS

df

MS

Model
Residual

.765632331
.01778672

2
19

.382816165
.000936143

Total

.783419051

21

.037305669

lnQ

Coef.

lnXP0
lnP1P0
_cons

.5344394
-.2753473
5.524569

Std. Err.
.0231984
.1511432
.0831077

Number of obs
F( 2,
19)
Prob > F
R-squared
Adj R-squared
Root MSE

P>|t|

23.04
-1.82
66.47

0.000
0.084
0.000

=
=
=
=
=
=

22
408.93
0.0000
0.9773
0.9749
.0306

[95% Conf. Interval]


.4858846
-.5916936
5.350622

.5829942
.040999
5.698515

13p105
g lnY=ln(Y)
g lnK=ln(K)
g lnL=ln(L)
reg lnY lnK lnL
Source

SS

df

MS

Model
Residual

21.6049266
5.07030244

2
28

10.8024633
.18108223

Total

26.6752291

30

.889174303

lnY

Coef.

lnK
lnL
_cons

.6092356
.3607965
1.153994

test b_[lnk]+b_[lnl]==1

Std. Err.
.1763779
.2015915
.7276114

t
3.45
1.79
1.59

Number of obs
F( 2,
28)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.002
0.084
0.124

=
=
=
=
=
=

31
59.66
0.0000
0.8099
0.7963
.42554

[95% Conf. Interval]


.2479419
-.0521449
-.33645

.9705293
.7737378
2.644439


4.14 (P116)
1
g lnY=ln(Y)
g lnX1=ln(X1)
g lnX2=ln(X2)
reg lnY lnX1 lnX2
Source

SS

df

MS

Model
Residual

2.9609923
.835744123

2
28

1.48049615
.029848004

Total

3.79673642

30

.126557881

lnY

Coef.

lnX1
lnX2
_cons

.1502137
.4774534
3.266068

Std. Err.
.1085379
.0515951
1.041591

t
1.38
9.25
3.14

Number of obs
F( 2,
28)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

31
49.60
0.0000
0.7799
0.7642
.17277

P>|t|

[95% Conf. Interval]

0.177
0.000
0.004

-.072116
.3717657
1.132465

lnY=3.266+0.1502lnX1+0.4775lnX2

2
predict e, resid
g ei2=e^2

scatter ei2 lnX2,title(" 4.1.3 ")xtick(6(0.4)9.2)ytick(0(0.04)0.24)

predict

.3725435
.5831412
5.39967

3G-Q
sort X2
drop in 13 /19
reg lnY lnX1 lnX2 in 1/12
Source

SS

df

MS

Model
Residual

.19947228
.070196863

2
9

.09973614
.007799651

Total

.269669142

11

.024515377

lnY

Coef.

lnX1
lnX2
_cons

.3983847
.2347508
3.141209

Number of obs
F( 2,
9)
Prob > F
R-squared
Adj R-squared
Root MSE

Std. Err.

P>|t|

.0787908
.1097475
1.122358

5.06
2.14
2.80

0.001
0.061
0.021

=
=
=
=
=
=

12
12.79
0.0023
0.7397
0.6818
.08832

[95% Conf. Interval]


.2201475
-.0135153
.6022575

.5766219
.4830169
5.68016

reg lnY lnX1 lnX2 in 13/24


Source

SS

df

MS

Model
Residual

1.36238223
.191197445

2
9

.681191114
.021244161

Total

1.55357967

11

.141234516

lnY

Coef.

lnX1
lnX2
_cons

-.113766
.6201685
3.993643

Std. Err.
.1599622
.1116539
1.884053

t
-0.71
5.55
2.12

di F=0.1911/0.0702
2.72364672.7222222

4
reg lnY lnX1 lnX2
predict e ,resid
g e2=e^2
g lnX12=(lnX1)^2
g lnX22=(lnX2)^2
g lnX1X2=lnX1*lnX2
reg e2 lnX1 lnX2 lnX12 lnX22 lnX1X2

Number of obs
F( 2,
9)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.495
0.000
0.063

=
=
=
=
=
=

12
32.06
0.0001
0.8769
0.8496
.14575

[95% Conf. Interval]


-.4756257
.3675898
-.2683811

.2480937
.8727472
8.255668

Source

SS

df

MS

Model
Residual

.035298411
.017947599

5
25

.007059682
.000717904

Total

.05324601

30

.001774867

e2

Coef.

lnX1
lnX2
lnX12
lnX22
lnX1X2
_cons

-2.32907
-.4573069
.1491144
.0211007
.0193327
10.24328

Std. Err.

Number of obs
F( 5,
25)
Prob > F
R-squared
Adj R-squared
Root MSE

1.116442
.4540203
.0581072
.0133574
.0412645
5.474522

P>|t|

-2.09
-1.01
2.57
1.58
0.47
1.87

=
=
=
=
=
=

31
9.83
0.0000
0.6629
0.5955
.02679

[95% Conf. Interval]

0.047
0.323
0.017
0.127
0.643
0.073

-4.628426
-1.392379
.0294404
-.0064095
-.0656532
-1.031707

-.0297138
.4777655
.2687884
.0486109
.1043186
21.51827

reg e2 lnX1 lnX2 lnX12 lnX22


Source

SS

df

MS

Model
Residual

.035140831
.018105178

4
26

.008785208
.000696353

Total

.05324601

30

.001774867

e2

Coef.

lnX1
lnX2
lnX12
lnX22
_cons

-1.851123
-.2581661
.1261597
.0172142
7.763275

Std. Err.

.4467273
.1571598
.0307668
.0103109
1.375323

-4.14
-1.64
4.10
1.67
5.64

Number of obs
F( 4,
26)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.112
0.000
0.107
0.000

=
=
=
=
=
=

31
12.62
0.0000
0.6600
0.6077
.02639

[95% Conf. Interval]


-2.769384
-.5812127
.0629176
-.0039802
4.936257

-.932862
.0648806
.1894018
.0384085
10.59029

g lne2= ln(e2)
reg lne2 lnX2 lnX22
Source

SS

df

MS

Model
Residual

29.2575216
115.374726

2
28

14.6287608
4.12052593

Total

144.632248

30

4.82107492

lne2

Coef.

lnX2
lnX22
_cons

-25.97629
1.701071
93.19585

Std. Err.
9.860002
.6414051
37.65529

t
-2.63
2.65
2.47

Number of obs
F( 2,
28)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.014
0.013
0.020

=
=
=
=
=
=

31
3.55
0.0423
0.2023
0.1453
2.0299

[95% Conf. Interval]


-46.17359
.3872121
16.06249

-5.778992
3.01493
170.3292

. predict m ,xb

. predictnl n=exp(xb())
. g wi=sqrt(n)
. vwls lnX1 lnX2,sd(wi)

Variance-weighted least-squares regression


Goodness-of-fit chi2(28) = 73.28
Prob > chi2
= 0.0000
lnY

Coef.

lnX1
lnX2
_cons

.3177322
.428669
2.338164

Std. Err.
.0514579
.0275805
.4472981

Number of obs
Model chi2(2)
Prob > chi2
z

6.17
15.54
5.23

P>|z|

[95% Conf. Interval]

0.000
0.000
0.000

.2168765
.3746122
1.461476

4.21
reg Y X
Source

SS

df

MS

Model
Residual

2.4819e+09
30259023.9

1
27

2.4819e+09
1120704.59

Total

2.5122e+09

28

89720219.8

Coef.

X
_cons

.4375268
2091.295

Std. Err.
.0092973
334.987

t
47.06
6.24

=
31
= 263.97
= 0.0000

Number of obs
F( 1,
27)
Prob > F
R-squared
Adj R-squared
Root MSE

=
29
= 2214.60
= 0.0000
= 0.9880
= 0.9875
= 1058.6

P>|t|

[95% Conf. Interval]

0.000
0.000

.4184503
1403.959

.4566033
2778.632

predict e,resid
tsset year
time variable: year, 1978 to 2006
delta: 1 unit
line e year,title("")xtick(1978(5)2006)ytick(-3000(1000)3000)

.4185879
.4827257
3.214852

scatter e e1,title("")xtick(-2000(1000)3000)ytick(-3000(1000)3000)

g T=_n
g T2=T^2
reg Y X T2
Source

SS

df

MS

Model
Residual

2.5061e+09
6054792.7

2
26

1.2531e+09
232876.642

Total

2.5122e+09

28

89720219.8

Coef.

X
T2
_cons

.1761519
21.65582
3328.191

Std. Err.
.0259858
2.124183
195.0326

t
6.78
10.19
17.06

Number of obs
F( 2,
26)
Prob > F
R-squared
Adj R-squared
Root MSE

=
29
= 5380.77
= 0.0000
= 0.9976
= 0.9974
= 482.57

P>|t|

[95% Conf. Interval]

0.000
0.000
0.000

.1227374
17.2895
2927.296

.2295664
26.02215
3729.086

reg e X T2 e1
Source

SS

df

MS

Model
Residual

25597419.6
3153351.72

3
24

8532473.19
131389.655

Total

28750771.3

27

1064843.38

Coef.

X
T2
e1
_cons

-.1435191
11.04582
.6186482
910.3409

Std. Err.
.0335797
2.915754
.1467037
172.739

t
-4.27
3.79
4.22
5.27

Number of obs
F( 3,
24)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.001
0.000
0.000

=
=
=
=
=
=

28
64.94
0.0000
0.8903
0.8766
362.48

[95% Conf. Interval]


-.2128242
5.028004
.3158666
553.8251

-.074214
17.06365
.9214297
1266.857

g e2=e[_n-1]
reg e X T2 e1 e2
Source

SS

df

MS

Model
Residual

25598535.3
3152235.94

4
23

6399633.84
137053.737

Total

28750771.3

27

1064843.38

Coef.

X
T2
e1
e2
_cons

-.1421776
10.80845
.6192203
4.183503
886.1107

Std. Err.
.0373799
3.973581
.1499666
46.36562
321.3096

t
-3.80
2.72
4.13
0.09
2.76

Number of obs
F( 4,
23)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.001
0.012
0.000
0.929
0.011

=
=
=
=
=
=

28
46.69
0.0000
0.8904
0.8713
370.21

[95% Conf. Interval]


-.2195039
2.58847
.3089908
-91.73108
221.4311

-.0648513
19.02843
.9294498
100.0981
1550.79

prais Y X T2,rhotype(orrc)
Prais-Winsten AR(1) regression -- iterated estimates
Source

SS

df

MS

Model
Residual

215943215
2434113.93

2
26

107971607
93619.7664

Total

218377329

28

7799190.31

Coef.

X
T2
_cons

.1896298
20.79527
3118.169

rho

.764553

Std. Err.
.0292979
2.693162
329.4324

t
6.47
7.72
9.47

Durbin-Watson statistic (original)


0.442033
Durbin-Watson statistic (transformed) 1.361658

newey lnY lnX, lag(2)

4.3.1P140
g lnX1=ln(X1)
g lnX2=ln(X2)
g lnX3=ln(X3)
g lnX4=ln(X4)
g lnX5=ln(X5)
g lnY=ln(Y)
reg lnY lnX1 lnX2 lnX3 lnX4 lnX5

Number of obs
F( 2,
26)
Prob > F
R-squared
Adj R-squared
Root MSE

=
29
= 1153.30
= 0.0000
= 0.9889
= 0.9880
= 305.97

P>|t|

[95% Conf. Interval]

0.000
0.000
0.000

.1294071
15.25939
2441.011

.2498524
26.33114
3795.327

Source

SS

df

MS

Model
Residual

.205495866
.003852744

5
19

.041099173
.000202776

Total

.209348611

24

.008722859

lnY

Coef.

lnX1
lnX2
lnX3
lnX4
lnX5
_cons

.3811446
1.222289
-.0811099
-.0472287
-.1011737
-4.173174

Std. Err.

.050242
.1351786
.0153037
.0447674
.0576866
1.923624

7.59
9.04
-5.30
-1.05
-1.75
-2.17

Number of obs
F( 5,
19)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.000
0.000
0.305
0.096
0.043

.275987
.9393566
-.1131409
-.1409279
-.2219131
-8.199365

lnX1

lnX2

lnX3

lnX4

lnX5

1.0000
-0.5687
0.4517
0.9644
0.4402

1.0000
-0.2141
-0.6976
-0.0733

1.0000
0.3988
0.4113

1.0000
0.2795

1.0000

stepwise, pr(0.05) : reg Y X1 X2 X3 X4 X5


stepwise, pe(0.05) : reg Y X1 X2 X3 X4 X5
reg lnY lnX1 lnX2 lnX3
Source

SS

df

MS

Model
Residual

.204871849
.004476761

3 .068290616
21 .000213179

Total

.209348611

24 .008722859

lnY

Coef.

lnX1
lnX2
lnX3
_cons

.3233849
1.290729
-.0867539
-5.999638

Std. Err.
.0108608
.0961534
.0151549
1.162078

t
29.78
13.42
-5.72
-5.16

Number of obs
F( 3,
21)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.000
0.000
0.000

25
202.68
0.0000
0.9816
0.9768
.01424

[95% Conf. Interval]

corr lnX1 lnX2 lnX3 lnX4 lnX5

lnX1
lnX2
lnX3
lnX4
lnX5

=
=
=
=
=
=

=
=
=
=
=
=

25
320.34
0.0000
0.9786
0.9756
.0146

[95% Conf. Interval]


.3007987
1.090767
-.1182702
-8.416312

.3459711
1.490691
-.0552376
-3.582964

.4863022
1.505221
-.0490789
.0464705
.0195656
-.1469838

4.41P151
reg X1 X2 Z
Source

SS

df

MS

Model
Residual

323280649
2323912.12

2
28

161640324
82996.8616

Total

325604561

30

10853485.4

X1

Coef.

X2
Z
_cons

-.470904
1.460539
132.7416

Std. Err.

Number of obs
F( 2,
28)
Prob > F
R-squared
Adj R-squared
Root MSE

.1154633
.0860022
194.2843

P>|t|

-4.08
16.98
0.68

0.000
0.000
0.500

=
31
= 1947.55
= 0.0000
= 0.9929
= 0.9924
= 288.09

[95% Conf. Interval]


-.7074199
1.284372
-265.2317

-.2343881
1.636707
530.7149

predict v,resid
reg Y X1 X2 v
Source

SS

df

MS

Model
Residual

169977392
1164688.99

3
27

56659130.6
43136.6292

Total

171142081

30

5704736.02

Coef.

X1
X2
v
_cons

.4502363
.4025897
1.191137
155.6975

Std. Err.
.042451
.0638268
.1427031
140.1522

Number of obs
F( 3,
27)
Prob > F
R-squared
Adj R-squared
Root MSE

t
10.61
6.31
8.35
1.11

=
31
= 1313.48
= 0.0000
= 0.9932
= 0.9924
= 207.69

P>|t|

[95% Conf. Interval]

0.000
0.000
0.000
0.276

.3631339
.2716278
.8983341
-131.871

.5373386
.5335515
1.483939
443.266

ivreg Y X2 (X1=Z)
Instrumental variables (2SLS) regression
Source

SS

df

MS

Model
Residual

166680210
4461870.66

2
83340105
28 159352.524

Total

171142081

30 5704736.02

Coef.

X1
X2
_cons

.4502363
.4025897
155.6975

reg Y X1 X2

Number of obs
F( 2,
28)
Prob > F
R-squared
Adj R-squared
Root MSE

Std. Err.

P>|t|

.0815915
.122676
269.3743

5.52
3.28
0.58

0.000
0.003
0.568

=
=
=
=
=
=

31
513.69
0.0000
0.9739
0.9721
399.19

[95% Conf. Interval]


.2831037
.1512992
-396.0907

.6173688
.6538801
707.4858

Source

SS

df

MS

Model
Residual

166971988
4170092.27

2
28

83485994.2
148931.867

Total

171142081

30

5704736.02

Coef.

X1
X2
_cons

.5556438
.2500854
143.3266

Std. Err.
.0753076
.1136343
260.4032

Number of obs
F( 2,
28)
Prob > F
R-squared
Adj R-squared
Root MSE

P>|t|

7.38
2.20
0.55

=
=
=
=
=
=

31
560.57
0.0000
0.9756
0.9739
385.92

[95% Conf. Interval]

0.000
0.036
0.586

.4013831
.0173161
-390.0851

.7099046
.4828547
676.7383

4 8P154
(1)
rename var1 X
rename var2 Y
reg Y X
Source

SS

df

MS

Model
Residual

49342144
846742.352

1
18

49342144
47041.2418

Total

50188886.4

19

2641520.34

Coef.

X
_cons

.755125
272.3635

Std. Err.
.0233157
159.6772

t
32.39
1.71

Number of obs
F( 1,
18)
Prob > F
R-squared
Adj R-squared
Root MSE

=
20
= 1048.91
= 0.0000
= 0.9831
= 0.9822
= 216.89

P>|t|

[95% Conf. Interval]

0.000
0.105

.7061404
-63.1059

.8041095
607.8329

2(4 )
predict e,resid
g e2=e^2
scatter e2 X

ii
p <0.05,

imtest,white
White's test for Ho: homoskedasticity
against Ha: unrestricted heteroskedasticity
chi2(2)
Prob > chi2

=
=

12.65
0.0018

Cameron & Trivedi's decomposition of IM-test


Source

chi2

df

Heteroskedasticity
Skewness
Kurtosis

12.65
5.16
1.85

2
1
1

0.0018
0.0232
0.1733

Total

19.66

0.0006

3
predict e,residuals
g e2=e^2
reg le2 X
Source

SS

df

MS

Model
Residual

18.3174302
42.2889689

1
18

18.3174302
2.34938716

Total

60.6063991

19

3.18981048

le2

Coef.

X
_cons

.0004601
6.825132

Std. Err.
.0001648
1.128446

t
2.79
6.05

Number of obs
F( 1,
18)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

20
7.80
0.0120
0.3022
0.2635
1.5328

P>|t|

[95% Conf. Interval]

0.012
0.000

.0001139
4.454355

.0008063
9.19591

predict m,xb
predictnl h=exp(xb())
reg Y X [w=1/h]
Source

SS

df

MS

Model
Residual

11254461.3
472402.755

1
18

11254461.3
26244.5975

Total

11726864.1

19

617203.372

Coef.

X
_cons

.7399551
359.3844

Std. Err.
.0357325
197.876

t
20.71
1.82

Number of obs
F( 1,
18)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.086

=
=
=
=
=
=

20
428.83
0.0000
0.9597
0.9575
162

[95% Conf. Interval]


.664884
-56.33756

.8150263
775.1064

9p155
g lnX=ln(X)
g lnY=ln(Y)
reg lnY lnX
Source

SS

df

MS

Model
Residual

45.5793477
.328192471

1
26

45.5793477
.012622787

Total

45.9075401

27

1.70027926

lnY

Coef.

lnX
_cons

.8544154
1.588478

e-t DW
predict e ,resid
line e year

Std. Err.
.0142188
.1342196

t
60.09
11.83

Number of obs
F( 1,
26)
Prob > F
R-squared
Adj R-squared
Root MSE

=
28
= 3610.88
= 0.0000
= 0.9929
= 0.9926
= .11235

P>|t|

[95% Conf. Interval]

0.000
0.000

.8251883
1.312586

.8836426
1.86437

scatter e l.e

tsset year
time variable: year, 1980 to 2007
delta: 1 unit
estat dwatson
Durbin-Watson d-statistic( 2,
28) = .3793231

prais lnY lnX ,corc

Cochrane-Orcutt AR(1) regression -- iterated estimates


Source

SS

df

MS

Model
Residual

.083721114
.079800977

1
25

.083721114
.003192039

Total

.163522091

26

.006289311

lnY

Coef.

lnX
_cons

.504519
11.95764

rho

.9924519

Std. Err.
.0985131
3.631466

t
5.12
3.29

Durbin-Watson statistic (original)


0.379323
Durbin-Watson statistic (transformed) 0.832823

Number of obs
F( 1,
25)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

27
26.23
0.0000
0.5120
0.4925
.0565

P>|t|

[95% Conf. Interval]

0.000
0.003

.3016274
4.478499

.7074106
19.43679

reg e lnX L.e


Source

SS

df

MS

Model
Residual

.188756553
.102659588

2
24

.094378277
.004277483

Total

.291416141

26

.011208313

Std. Err.

Number of obs
F( 2,
24)
Prob > F
R-squared
Adj R-squared
Root MSE

P>|t|

=
=
=
=
=
=

27
22.06
0.0000
0.6477
0.6184
.0654

Coef.

[95% Conf. Interval]

lnX

.0057439

.0087579

0.66

0.518

-.0123316

.0238194

e
L1.

.7661694

.1166684

6.57

0.000

.5253777

1.006961

_cons

-.0642313

.0833749

-0.77

0.449

-.2363086

.107846

reg e lnX L.e l2.e


Source

SS

df

MS

Model
Residual

.18949079
.070047033

3
22

.063163597
.003183956

Total

.259537823

25

.010381513

Std. Err.

Number of obs
F( 3,
22)
Prob > F
R-squared
Adj R-squared
Root MSE

P>|t|

=
=
=
=
=
=

26
19.84
0.0000
0.7301
0.6933
.05643

Coef.

[95% Conf. Interval]

lnX

.0078685

.0082029

0.96

0.348

-.0091433

.0248803

e
L1.
L2.

1.152102
-.5101045

.1778105
.1680217

6.48
-3.04

0.000
0.006

.7833456
-.8585601

1.520858
-.1616488

_cons

-.0813209

.078954

-1.03

0.314

-.2450615

.0824196

reg e lnX L.e l2.e l3.e


Source

SS

df

MS

Model
Residual

.194368268
.064523896

4
20

.048592067
.003226195

Total

.258892163

24

.010787173

Std. Err.

Number of obs
F( 4,
20)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|

=
=
=
=
=
=

25
15.06
0.0000
0.7508
0.7009
.0568

Coef.

[95% Conf. Interval]

lnX

.0025104

.0092842

0.27

0.790

-.0168561

.021877

e
L1.
L2.
L3.

1.202647
-.4914312
.005666

.2201807
.3070908
.2038663

5.46
-1.60
0.03

0.000
0.125
0.978

.7433583
-1.132011
-.4195916

1.661936
.1491489
.4309235

_cons

-.0269681

.0902114

-0.30

0.768

-.2151459

.1612096

newey lnY lnX, lag(2)


Regression with Newey-West standard errors
maximum lag: 2

lnY

Coef.

lnX
_cons

.8544154
1.588478

Newey-West
Std. Err.
.0212596
.2087091

Number of obs
F( 1,
26)
Prob > F

t
40.19
7.61

=
=
=

28
1615.20
0.0000

P>|t|

[95% Conf. Interval]

0.000
0.000

.8107157
1.15947

.8981152
2.017486

g X1=X-L.X
g Y1=Y-L.Y
reg Y1 X1
Source

SS

df

MS

Model
Residual

485227703
30520493.1

1
25

485227703
1220819.73

Total

515748196

26

19836469.1

Y1

Coef.

X1
_cons

.5964135
889.3387

estat dwatson
Durbin-Watson d-statistic(

Std. Err.

.0299158
260.8835

2,

19.94
3.41

Number of obs
F( 1,
25)
Prob > F
R-squared
Adj R-squared
Root MSE

=
=
=
=
=
=

27
397.46
0.0000
0.9408
0.9385
1104.9

P>|t|

[95% Conf. Interval]

0.000
0.002

.5348008
352.0391

.6580262
1426.638

27) = .9608428

4- 10P155
reg Y X1 X2
Source

SS

df

MS

Model
Residual

855305.867
33694.1329

2
7

427652.934
4813.44755

Total

889000

98777.7778

Coef.

X1
X2
_cons

.5684245
-.0058326
245.5158

Std. Err.
.7160975
.0702937
69.52348

t
0.79
-0.08
3.53

5.1.1(P160)
reg Y1 X1

Number of obs
F( 2,
7)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.453
0.936
0.010

=
=
=
=
=
=

10
88.85
0.0000
0.9621
0.9513
69.379

[95% Conf. Interval]


-1.124877
-.1720507
81.11887

2.261726
.1603855
409.9127

Source

SS

df

MS

Model
Residual

182436639
9072820.63

1
29

182436639
312855.884

Total

191509460

30

6383648.66

Y1

Coef.

X1
_cons

.6919714
450.3413

Std. Err.

Number of obs
F( 1,
29)
Prob > F
R-squared
Adj R-squared
Root MSE

.0286553
388.9091

P>|t|

24.15
1.16

0.000
0.256

=
=
=
=
=
=

31
583.13
0.0000
0.9526
0.9510
559.34

[95% Conf. Interval]


.6333648
-345.0672

.750578
1245.75

reg Y2 X2
Source

SS

df

MS

Model
Residual

60399153.9
7066328.2

1
29

60399153.9
243666.49

Total

67465482.1

30

2248849.4

Y2

Coef.

X2
_cons

.7195035
179.1848

Std. Err.
.0456999
221.5788

Number of obs
F( 1,
29)
Prob > F
R-squared
Adj R-squared
Root MSE

P>|t|

15.74
0.81

0.000
0.425

31
247.88
0.0000
0.8953
0.8916
493.63

[95% Conf. Interval]


.6260367
-273.9948

tab(region),g(D)

region

Freq.

Percent

Cum.

31
31

50.00
50.00

50.00
100.00

Total

62

100.00

drop D1
g DX=D2*X
reg Y X D2 DX

=
=
=
=
=
=

.8129703
632.3644

Source

SS

df

MS

Model
Residual

828461102
16139148.8

3
58

276153701
278261.187

Total

844600251

61

13845905.8

Coef.

X
D2
DX
_cons

.6919714
-271.1565
.0275321
450.3413

Std. Err.
.0270245
436.5699
.0558151
366.7772

t
25.61
-0.62
0.49
1.23

Number of obs
F( 3,
58)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.537
0.624
0.224

=
=
=
=
=
=

62
992.43
0.0000
0.9809
0.9799
527.5

[95% Conf. Interval]


.6378759
-1145.046
-.0841939
-283.843

.7460669
602.7331
.1392581
1184.526

Number of obs
F( 3,
17)
Prob > F
R-squared
Adj R-squared
Root MSE

=
21
= 1187.99
= 0.0000
= 0.9953
= 0.9944
= .03753

5.2.2P168

g X1=X[_n-1]
g X2=X[_n-2]
g X3=X[_n-3]
g X4=X[_n-4]
g X5=X[_n-5]
g X6=X[_n-6]
g X7=X[_n-7]
g lnX=ln(X)
g lnX1=ln(X1)
g lnX2=ln(X2)
g lnX3=ln(X3)
g lnX4=ln(X4)
g lnX5=ln(X5)
g lnX6=ln(X6)
g lnX7=ln(X7)
g lnY=ln(Y)
g W0=lnX+lnX1+lnX2+lnX3+lnX4+lnX5+lnX6+lnX7
g W1=lnX1+2*lnX2+3*lnX3+lnX*4+lnX5*5+lnX6*6+lnX7*7
g W2=4*lnX2+9*lnX3+lnX4*16+lnX5*25+lnX6*36+lnX7*49
reg lnY W0 W1 W2
Source

SS

df

MS

Model
Residual

5.01994038
.023944895

3
17

1.67331346
.001408523

Total

5.04388527

20

.252194264

lnY

Coef.

W0
W1
W2
_cons

.142537
-.0580477
.0062676
6.708366

Std. Err.
.023324
.0206204
.002926
.0426449

t
6.11
-2.82
2.14
157.31

P>|t|

[95% Conf. Interval]

0.000
0.012
0.047
0.000

.0933277
-.101553
.0000942
6.618393

.1917464
-.0145424
.012441
6.798339

5.2.2P173
tsset year
time variable: year, 1978 to 2007
delta: 1 unit
g Yt1=Y[_n-1]
reg Y X P Yt1
Source

SS

df

MS

Model
Residual

2.2684e+09
3220932.79

3 756146042
25 128837.312

Total

2.2717e+09

28 81130680.7

Coef.

X
P
Yt1
_cons

.0357098
7.455727
.7236337
-202.5274

Std. Err.
.012565
3.065732
.1327963
221.9648

Number of obs
F( 3,
25)
Prob > F
R-squared
Adj R-squared
Root MSE

P>|t|

2.84
2.43
5.45
-0.91

0.009
0.023
0.000
0.370

=
=
=
=
=
=

29
5869.00
0.0000
0.9986
0.9984
358.94

[95% Conf. Interval]


.0098317
1.141733
.4501346
-659.6724

.061588
13.76972
.9971328
254.6176

5P186
5.2.3
1 Y*

tsset year
time variable: year, 1970 to 1991
delta: 1 unit
g Yt1=Y[_n-1]
reg Y X Yt1
Source

SS

df

MS

Model
Residual

51963.6177
752.640861

2
18

25981.8089
41.8133812

Total

52716.2586

20

2635.81293

Coef.

X
Yt1
_cons

.6480192
.2415177
-14.5344

Std. Err.
.1034473
.1223811
4.87717

t
6.26
1.97
-2.98

Number of obs
F( 2,
18)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.064
0.008

=
=
=
=
=
=

21
621.38
0.0000
0.9857
0.9841
6.4663

[95% Conf. Interval]


.4306844
-.0155954
-24.78095

.865354
.4986308
-4.287846

Y*
(2)
g lnY=ln(Y)
g lnYt1=ln(Yt1)
g lnX=ln(X)

reg lnY lnX lnYt1


Source

SS

df

MS

Model
Residual

6.15325454
.054092643

2
18

3.07662727
.003005147

Total

6.20734719

20

.310367359

lnY

Coef.

lnX
lnYt1
_cons

.9837083
.1866692
-1.134494

Std. Err.
.1342437
.1068091
.2164561

t
7.33
1.75
-5.24

Number of obs
F( 2,
18)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|

=
21
= 1023.79
= 0.0000
= 0.9913
= 0.9903
= .05482

[95% Conf. Interval]

0.000
0.098
0.000

.7016728
-.0377283
-1.589251

1.265744
.4110668
-.6797361

3 X* X Xt-1 Y
Y01
g Xt1=X[_n-1]
reg Y X Xt1
Source

SS

df

MS

Model
Residual

51955.8336
760.425036

2
18

25977.9168
42.2458353

Total

52716.2586

20

2635.81293

Coef.

X
Xt1
_cons

.4240542
.4196949
-16.1012

Std. Err.
.22186
.2190631
4.505287

t
1.91
1.92
-3.57

Number of obs
F( 2,
18)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.072
0.071
0.002

=
=
=
=
=
=

21
614.92
0.0000
0.9856
0.9840
6.4997

[95% Conf. Interval]


-.0420564
-.0405395
-25.56645

.8901649
.8799293
-6.635942


6.4.1P215
2SLS
tsset year
g Ct=C[_n-1]
reg Y Ct G
Source

SS

df

MS

Model
Residual

1.4148e+11
506704733

2
26

7.0741e+10
19488643.6

Total

1.4199e+11

28

5.0710e+09

Coef.

Ct
G
_cons

1.258635
2.794437
1291.153

Std. Err.

Number of obs
F( 2,
26)
Prob > F
R-squared
Adj R-squared
Root MSE

.1354676
.2190344
1317.612

P>|t|

9.29
12.76
0.98

0.000
0.000
0.336

=
29
= 3629.86
= 0.0000
= 0.9964
= 0.9962
= 4414.6

[95% Conf. Interval]


.9801776
2.344205
-1417.237

1.537093
3.244668
3999.543

predict m,xb
. reg C m Ct
Source

SS

df

MS

Model
Residual

1.9921e+10
49857078.8

2
26

9.9604e+09
1917579.95

Total

1.9971e+10

28

713236666

Coef.

m
Ct
_cons

.0851009
.8617011
886.5725

Std. Err.
.0245869
.0728371
400.8777

Number of obs
F( 2,
26)
Prob > F
R-squared
Adj R-squared
Root MSE

t
3.46
11.83
2.21

=
29
= 5194.25
= 0.0000
= 0.9975
= 0.9973
= 1384.8

P>|t|

[95% Conf. Interval]

0.002
0.000
0.036

.0345618
.7119823
62.55666

.1356401
1.01142
1710.588

8P228
2SLS
reg M Y P
Source

SS

df

MS

Model
Residual

2.3413e+11
1.8229e+09

2
15

1.1707e+11
121525509

Total

2.3596e+11

17

1.3880e+10

Coef.

Y
P
_cons

1.810219
-147.4108
2067.01

predict m,xb
reg Y M C I

Std. Err.
.0631125
62.84855
14473.77

t
28.68
-2.35
0.14

Number of obs
F( 2,
15)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.000
0.033
0.888

=
=
=
=
=
=

18
963.31
0.0000
0.9923
0.9912
11024

[95% Conf. Interval]


1.675698
-281.3693
-28783.1

1.94474
-13.45225
32917.12

Source

SS

df

MS

Model
Residual

8.1426e+10
12079846.3

3
14

2.7142e+10
862846.166

Total

8.1438e+10

17

4.7905e+09

Coef.

M
C
I
_cons

-.0217166
1.601022
.8974178
541.9417

Std. Err.
.0195131
.0577308
.0368883
803.0233

t
-1.11
27.73
24.33
0.67

Number of obs
F( 3,
14)
Prob > F
R-squared
Adj R-squared
Root MSE
P>|t|
0.284
0.000
0.000
0.511

=
18
=31456.30
= 0.0000
= 0.9999
= 0.9998
=
928.9

[95% Conf. Interval]


-.063568
1.477202
.8183003
-1180.372

.0201348
1.724843
.9765352
2264.255

1. estout stata
ssc install estout, replace
EST http://repec.org/bocode/e/estout/installation.html
2. regression
3. esttab using test.rtfWORD
my documentstata
stata do file do excel
.xls .csv
4. regressionest store m1
m1 model m1 est store m2

5.esttab m1 m2 ... using test.rtf

Breusch-Pagan test in STATA


estat hettest var1 var2 var3
var1 var2 var3

P-Value 0.05
White
OLS
imtest white
P-Value 0.05

WLS
WLS GLS GLS WLS WLS

stata WLS
reg 1 2 [aweight=]
aweight


stata
OLS
reg 1 2
predict r, resid
logusq

gen logusq=ln(r^2)
reg logusq ( 1) 2
predict g, xb
gen h=exp(g)
h WLS
reg 1 2 [aweight=h]
GLS
OLS GLS

HC SE
There are 3 kinds of HC SE
1Huber-White Robust Standard Errors HC1
reg var1 var2 var3, robust
White1980asymptotically valid

2MacKinnon-White SE HC2
reg var1 var2 var3, hc2
3Long-Ervin SE HC3
reg var1 var2 var3, hc3

x y

test x=y
1
test x+y=1
P-Value 0.05

gen n=_n
tsset n
n t

tsset n

Predict error, stdp

plot error n
error n

D-W
D-W

D-W

reg Variable1 Variable2 Variable3VariableM


OLS
dwstat
DW

estat durbinalt
Durbin
Breusch-GodfreyTest in STATA
error
et = 0 + 1 et-1 + 2 et-2 + k et-p + 1 x1t + 2 x2t +k xkt +t
BG H0 1 = 2 = p =0

bgodfrey , lags(p)
p p-value 0.05
p p-value
0.05 p

GLS
GLS

1 Cochrane-Orcutt estimator Prais-Winsten estimator

prais var1 var2 var3, corc


2 Newey-West standard errors

newey var1 var2 var3, lag(3)


lag3 p

lagp

t g,f,c _26 26
reg t g f c if _n!=26

predict taxpredict if _n==26

predictnl py=predict(xb),ci(lb ub) l(95)

adjust g=117251.9 f=24649.95 c=99.9,stdf ci level(95)

Hausman
Wald

.hausman name-constistent [name-efficent] [,options]


name-cosistent name-efficent

Option
constant

allegs
skipeqs(eqlist) eqlist
equation(matchlist)
force

df(#)
sigmamore
sigmaless

tconsistent(string)

tefficient(string)

.ivregress esitimator depvar [varlist1] [varlist2=varlist_iv] [if] [in]


[weight][,options]
estimator 2sls,gmm,liml varlist1 varlist2
varlist_iv
Nonconstant
Hascons

CMM
wmatrix(wmtype)
center

robust,cluster clustvar,hac kernel, unadjusted

igmm GMM
eps(#) epsle-6
weps(#)

w eps(le-6)

Vce(vcetype) unajusted,robust,cluster clustvar,bootstrap,jackknife,hac kernel


level(#)
First
Small
.estat firststage [,all forcenonrobust]

All stata
R2 R2 R2 F stata Shea
R2 R2
forcenonrobust

estat overid[,lag(#) forceweights forcenonrobust]


2sls Stata Sargans(1958)
Basmans(1960) Wooldridge(1995
liml stata Anderson and Rubins(1950) Basmann F
GMM stata hansens(1982)J Lags(#)
HAC
lag(0), lag(1) 2sls
vce(hac)
Forceweight

aweights,pweights iweights Stata

fweights
Forcenonrobust

2sls LIML Sargan and

Basmann

log(wage)=a+b*educ+c*exper+d*expersq+u
educfatheduc,motheduc
educ
1 2SLS
.ivregress 2sls lwage exper expersq (educ=fatheduc motheduc),first

educhat=9.1+0.19fatheduc+0.16motheduc+0.05exper
(21.34)

(5.62)

(4.39)

(1.12)
- 0.001expersq
(-0.84)

lwagehat=0.05+0.06educ+0.04exper-0.001expersq
(0.12)
(-2.24)

(1.95)

(5.29)

2 educ
.quietly

ivreg

iwage exper expersq {educ=fatheduc motheduc}

.est store IV_reg


.quietly regress lwage exper expersq educ
.est store LS_reg
.hausman IV_reg LS_reg
hausman =2.7P =0.44 educ
(3)
.estat overid
Sargan =0.38P =0.54

tsset company year


tsset industry year
gen newvar=human*lnrd
Gen fiscal(2)=L2.fiscal
Gen fiscal(D)=D.fiscal

xtdes Panel Data


Xtsum
xttab

Stata xtreg
xtreg depvar [varlist] [if exp] , model_type [level(#) ]
Model

type

be

Between-effects estimator

fe

Fixed-effects estimator

re

GLS Random-effects estimator

pa

GEE population-averaged estimator

mle

Maximum-likelihood Random-effects estimator

xtreg

Fixed-, between- and random-effects, and population-averaged linear

models
xtregarFixed- and random-effects linear models with an AR(1) disturbance
xtpcse OLS or Prais-Winsten models with panel-corrected standard errors
xtrchh Hildreth-Houck random coefficients models
xtivreg Instrumental variables and two-stage least squares for panel-data models
xtabondArellano-Bond linear, dynamic panel data estimator
xttobit Random-effects tobit models
xtlogit Fixed-effects, random-effects, population-averaged logit models
xtprobit Random-effects and population-averaged probit models
xtfrontier Stochastic frontier models for panel-data
xtrc gdp invest culture edu sci health social admin,beta

xtreg
tsset

sheng t

xtsum gdp invest sci admin


1.
xtreg

gdp invest culture sci health admin techno,fe

( sigma u sigma e
(rho)
F P

2.
xtreg

gdp invest culture sci health admin techno,re

OLS
xttest0
P 0.0000 OLS
3. Ml
xtreg

gdp invest culture sci health admin techno,mle

Hausman
Hausman

xtreg

gdp invest culture sci health admin techno,fe

est store fe

xtreg

gdp invest culture sci health admin techno,re

est store re
hausman
hausman fe
Hausman
H=(b-B)[Var(b)-Var(B)]-1(b-B)x2(k)
Hausman k 2 H

hausman Hausman

hausman
hausman fe, sigmaless

Xtserial gdp invest culture sci health admin techno

xtreg

gdp invest culture sci health admin techno,fe

xttest3 (Modified Wald statistic for groupwise heteroskedasticity in fixed effect


model)

xtreg

gdp invest culture sci health admin techno,re

Xttest1
Xttest1 ()

xtgls
xtgls

gdp invest culture sci health admin techno, panels(hetero)

xtgls

gdp invest culture sci health admin techno, panels(correlated)

xtgls

gdp invest culture sci health admin techno, panels(hetero) corr(ar1)

ar(1)

You might also like