Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Tải file dữ liệu chạy trong stata

File => Import (Chọn 1 file excel là đơn giản nhất)

Kiểm tra lại dữ liệu bằng Data Editor:


Thường biến mã định danh như mã công ty (mã cổ phiếu) hay tên riêng gì đó để phân loại trong
biến và biến giả sẽ hay bị nhận diện sai định dạng nên cần phải ép lại dữ liệu cho đúng định
dạng của stata như các biến khác, không những thế, việc này còn tạo dữ liệu thành dữ liệu mảng,
và chuỗi của stata, điều này lý giải tại sao cùng 1 bộ dữ liệu, khi chạy trên eview, spss,
stata cùng 1 mô hình nhưng cho kết quả khác nhau, bởi trên stata là dữ liệu mảng

Màn hình dữ liệu hiện ra với các dữ liệu màu đỏ tức là chưa được định dạng đúng theo stata bao
gồm biến N (Mã cổ phiếu) và biến giả SIZE (Quy mô BIG hoặc SMALL) => Chuyển 2 biến này để
định dạng hợp lệ theo stata

Trường hợp bộ data này là Firm nhé.

Khai báo biến cho hợp lệ theo định dạng của Stata:
- Chuyển mã cổ phiếu (N) thành dạng số bằng cách gõ lệnh vào ô Command: encode N, gen(N1)
-> enter.
Kiểm tra lại dữ liệu bằng Data Editor lúc này xuất hiện thêm cột N1 chuyển sang màu xanh.

- Khai báo dữ liệu bảng:


Câu lệnh: xtset N1 T

(Trong đó T là biến thời gian trong bảng dữ liệu ban đầu)

- Khai báo biến giả:


Câu lệnh: gen LARGE = inlist(SIZE,"BIG")

Kiểm tra lại dữ liệu bằng Data Editor lúc này xuất hiện thêm cột LARGE (Trong đó các ô có giá
trị BIG ở cột SIZE sẽ chuyển thành giá trị 1 tương ứng ở cột LARGE và các ô có giá trị SMALL
sẽ chuyển thành giá trị 0)

Phân tích tương quan

1/ pwcorr MVA Cash OCF SG Size RONA NOPAT EBITDAgrowth CEV LEV,sig

| MVA Cash OCF SG Size RONA NOPAT

-------------+---------------------------------------------------------------

MVA | 1.0000

Cash | 0.6672 1.0000

| 0.0000

OCF | 0.5613 0.4312 1.0000

| 0.0000 0.0000

SG | -0.0684 -0.0132 -0.0166 1.0000

| 0.1643 0.8410 0.7282

Size | 0.8687 0.6140 0.4789 -0.0260 1.0000

| 0.0000 0.0000 0.0000 0.5870

|
RONA | 0.0212 0.0058 0.0347 0.5266 0.0127 1.0000

| 0.6642 0.9296 0.4643 0.0000 0.7898

NOPAT | 0.8371 0.6309 0.5131 0.0342 0.8211 0.1203 1.0000

| 0.0000 0.0000 0.0000 0.4913 0.0000 0.0142

EBITDAgrowth | 0.0401 0.0083 -0.0156 0.0011 0.0239 0.0084 0.0238

| 0.4386 0.9052 0.7572 0.9835 0.6346 0.8676 0.6477

CEV | 0.6265 0.5030 0.4289 -0.1036 0.6846 -0.0463 0.6155

| 0.0000 0.0000 0.0000 0.0415 0.0000 0.3591 0.0000

LEV | 0.2397 0.1419 0.0908 0.0223 0.2513 0.0717 0.1142

| 0.0000 0.0300 0.0553 0.6412 0.0000 0.1303 0.0200

| EBITDA~h CEV LEV

-------------+---------------------------

EBITDAgrowth | 1.0000

CEV | 0.0180 1.0000

| 0.7361

LEV | 0.0927 0.2232 1.0000

| 0.0651 0.0000

Hồi qui

2/ regress MVA Cash OCF Size NOPAT CEV LEV, beta

Source | SS df MS Number of obs = 189

-------------+---------------------------------- F(6, 182) = 229.29

Model | 642.052914 6 107.008819 Prob > F = 0.0000

Residual | 84.9405697 182 .466706427 R-squared = 0.8832

-------------+---------------------------------- Adj R-squared = 0.8793

Total | 726.993484 188 3.86698662 Root MSE = .68316

------------------------------------------------------------------------------

MVA | Coef. Std. Err. t P>|t| Beta

-------------+----------------------------------------------------------------
Cash | .1151382 .032887 3.50 0.001 .1178194

OCF | 9.52e-08 2.06e-08 4.62 0.000 .1439891

Size | .6861976 .0683233 10.04 0.000 .5209918

NOPAT | .3119616 .0502867 6.20 0.000 .2977605

CEV | -.067418 .0362613 -1.86 0.065 -.0662981

LEV | 1.316185 .2951466 4.46 0.000 .1163958

_cons | 2.034282 .5950499 3.42 0.001 .

------------------------------------------------------------------------------

Đa cộng tuyến

3/ estat vif

Variable | VIF 1/VIF

-------------+----------------------

Size | 4.19 0.238568

NOPAT | 3.59 0.278660

CEV | 1.98 0.504865

Cash | 1.76 0.566854

OCF | 1.51 0.660258

LEV | 1.06 0.942317

-------------+----------------------

Mean VIF | 2.35

FEM

4/ xtreg MVA Cash OCF Size NOPAT CEV LEV, fe

Fixed-effects (within) regression Number of obs = 189

Group variable: Firm1 Number of groups = 56

R-sq: Obs per group:

within = 0.6857 min = 1

between = 0.9096 avg = 3.4

overall = 0.8758 max = 6

F(6,127) = 46.17

corr(u_i, Xb) = -0.4465 Prob > F = 0.0000

------------------------------------------------------------------------------

MVA | Coef. Std. Err. t P>|t| [95% Conf. Interval]

-------------+----------------------------------------------------------------

Cash | .0691185 .0366715 1.88 0.062 -.0034478 .1416848


OCF | 1.29e-07 4.32e-08 2.98 0.003 4.32e-08 2.14e-07

Size | .712079 .1220374 5.83 0.000 .470589 .953569

NOPAT | .3840138 .0542117 7.08 0.000 .2767387 .4912889

CEV | .0224108 .0529855 0.42 0.673 -.0824379 .1272595

LEV | .9787578 .4708591 2.08 0.040 .0470126 1.910503

_cons | .4887508 1.487098 0.33 0.743 -2.453947 3.431449

-------------+----------------------------------------------------------------

sigma_u | .67684447

sigma_e | .52047909

rho | .62840577 (fraction of variance due to u_i)

------------------------------------------------------------------------------

F test that all u_i=0: F(55, 127) = 3.39 Prob > F = 0.0000

Lưu lại FEM

5/ est store feMVA

REM

6/ xtreg MVA Cash OCF Size NOPAT CEV LEV, re

Random-effects GLS regression Number of obs = 189

Group variable: Firm1 Number of groups = 56

R-sq: Obs per group:

within = 0.6791 min = 1

between = 0.9186 avg = 3.4

overall = 0.8812 max = 6

Wald chi2(6) = 827.17

corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000

------------------------------------------------------------------------------

MVA | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------

Cash | .0909232 .032001 2.84 0.004 .0282024 .153644

OCF | 8.80e-08 2.31e-08 3.82 0.000 4.28e-08 1.33e-07

Size | .6683006 .0775867 8.61 0.000 .5162333 .8203678

NOPAT | .3434611 .0483028 7.11 0.000 .2487892 .4381329

CEV | -.0147188 .0409039 -0.36 0.719 -.094889 .0654514

LEV | 1.185644 .3390668 3.50 0.000 .5210853 1.850203

_cons | 1.66554 .7770097 2.14 0.032 .1426289 3.188451

-------------+----------------------------------------------------------------
sigma_u | .46848001

sigma_e | .52047909

rho | .44756536 (fraction of variance due to u_i)

------------------------------------------------------------------------------

Lưu lại REM

7/ est store reMVA

Chọn REM/FEM

8/ hausman feMVA reMVA

Note: the rank of the differenced variance matrix (5) does not equal the number of
coefficients being tested

(6); be sure this is what you expect, or there may be problems computing the test.
Examine the output

of your estimators for anything unexpected and possibly consider scaling your
variables so that the

coefficients are on a similar scale.

---- Coefficients ----

| (b) (B) (b-B) sqrt(diag(V_b-V_B))

| feMVA reMVA Difference S.E.

-------------+----------------------------------------------------------------

Cash | .0691185 .0909232 -.0218047 .0179091

OCF | 1.29e-07 8.80e-08 4.07e-08 3.66e-08

Size | .712079 .6683006 .0437784 .0941989

NOPAT | .3840138 .3434611 .0405527 .0246118

CEV | .0224108 -.0147188 .0371296 .0336798

LEV | .9787578 1.185644 -.2068862 .326714

------------------------------------------------------------------------------

b = consistent under Ho and Ha; obtained from xtreg

B = inconsistent under Ha, efficient under Ho; obtained from xtreg

Test: Ho: difference in coefficients not systematic

chi2(5) = (b-B)'[(V_b-V_B)^(-1)](b-B)

= 7.22

Prob>chi2 = 0.2051  Chọn rem

Phương sai sai số thay đổi

. xttest0

---- Nếu là fem thì chạy . xttest3 (có khi phải cài ssc install xttest3 trong máy nếu chưa
có nhé)
Breusch and Pagan Lagrangian multiplier test for random effects

MVA[Firm1,t] = Xb + u[Firm1] + e[Firm1,t]

Estimated results:

| Var sd = sqrt(Var)

---------+-----------------------------

MVA | 3.866987 1.966466

e | .2708985 .5204791

u | .2194735 .46848

Test: Var(u) = 0

chibar2(01) = 23.63

Prob > chibar2 = 0.0000

 Có hiện tượng phương sai sai số thay đổi

Khắc phục phương sai sai số thay đổi

xtreg MVA Cash OCF Size NOPAT CEV LEV, robust re

Random-effects GLS regression Number of obs = 189

Group variable: Firm1 Number of groups = 56

R-sq: Obs per group:

within = 0.6791 min = 1

between = 0.9186 avg = 3.4

overall = 0.8812 max = 6

Wald chi2(6) = 763.73

corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000

(Std. Err. adjusted for 56 clusters in Firm1)

------------------------------------------------------------------------------

| Robust

MVA | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------

Cash | .0909232 .029394 3.09 0.002 .0333121 .1485343

OCF | 8.80e-08 2.81e-08 3.13 0.002 3.29e-08 1.43e-07

Size | .6683006 .0683456 9.78 0.000 .5343457 .8022554

NOPAT | .3434611 .050455 6.81 0.000 .2445712 .4423509

CEV | -.0147188 .0670614 -0.22 0.826 -.1461568 .1167192


LEV | 1.185644 .2628906 4.51 0.000 .670388 1.7009

_cons | 1.66554 .7624173 2.18 0.029 .1712296 3.15985

-------------+----------------------------------------------------------------

sigma_u | .46848001

sigma_e | .52047909

rho | .44756536 (fraction of variance due to u_i)

------------------------------------------------------------------------------

Kiểm tra tự tương quan

xtserial MVA Cash OCF Size NOPAT CEV LEV

Wooldridge test for autocorrelation in panel data

H0: no first-order autocorrelation

F( 1, 16) = 2.204

Prob > F = 0.1571

 Không có tự tương quan


 OK

. pwcorr EPS Cash OCF SG Size RONA NOPAT EBITDAgrowth CEV LEV,sig

| EPS Cash OCF SG Size RONA NOPAT

-------------+---------------------------------------------------------------

EPS | 1.0000

Cash | 0.1976 1.0000

| 0.0024

OCF | 0.2252 0.4312 1.0000

| 0.0000 0.0000

SG | -0.1046 -0.0132 -0.0166 1.0000

| 0.0286 0.8410 0.7282

Size | 0.0482 0.6140 0.4789 -0.0260 1.0000

| 0.3096 0.0000 0.0000 0.5870

RONA | 0.0399 0.0058 0.0347 0.5266 0.0127 1.0000

| 0.4002 0.9296 0.4643 0.0000 0.7898

|
NOPAT | 0.3076 0.6309 0.5131 0.0342 0.8211 0.1203 1.0000

| 0.0000 0.0000 0.0000 0.4913 0.0000 0.0142

EBITDAgrowth | 0.0032 0.0083 -0.0156 0.0011 0.0239 0.0084 0.0238

| 0.9500 0.9052 0.7572 0.9835 0.6346 0.8676 0.6477

CEV | 0.1409 0.5030 0.4289 -0.1036 0.6846 -0.0463 0.6155

| 0.0050 0.0000 0.0000 0.0415 0.0000 0.3591 0.0000

LEV | 0.0885 0.1419 0.0908 0.0223 0.2513 0.0717 0.1142

| 0.0618 0.0300 0.0553 0.6412 0.0000 0.1303 0.0200

| EBITDA~h CEV LEV

-------------+---------------------------

EBITDAgrowth | 1.0000

CEV | 0.0180 1.0000

| 0.7361

LEV | 0.0927 0.2232 1.0000

| 0.0651 0.0000

. regress EPS Cash OCF SG NOPAT CEV, beta

Source | SS df MS Number of obs = 197

-------------+---------------------------------- F(5, 191) = 4.20

Model | 50228212.8 5 10045642.6 Prob > F = 0.0012

Residual | 457217160 191 2393807.12 R-squared = 0.0990

-------------+---------------------------------- Adj R-squared = 0.0754

Total | 507445373 196 2589007 Root MSE = 1547.2

------------------------------------------------------------------------------

EPS | Coef. Std. Err. t P>|t| Beta

-------------+----------------------------------------------------------------

Cash | -23.74791 72.89637 -0.33 0.745 -.0300498

OCF | .0000751 .0000458 1.64 0.103 .1363854

SG | 1.755624 33.95612 0.05 0.959 .003668


NOPAT | 245.2403 87.80341 2.79 0.006 .2922645

CEV | -72.32212 76.62635 -0.94 0.346 -.087445

_cons | -477.2234 887.9896 -0.54 0.592 .

------------------------------------------------------------------------------

estat vif

Variable | VIF 1/VIF

-------------+----------------------

NOPAT | 2.32 0.430833

CEV | 1.82 0.549561

Cash | 1.80 0.554441

OCF | 1.47 0.679719

SG | 1.07 0.937291

-------------+----------------------

Mean VIF | 1.70

xtreg EPS Cash OCF SG NOPAT CEV, fe

Fixed-effects (within) regression Number of obs = 197

Group variable: Firm1 Number of groups = 56

R-sq: Obs per group:

within = 0.5248 min = 1

between = 0.0103 avg = 3.5

overall = 0.0866 max = 6

F(5,136) = 30.03

corr(u_i, Xb) = -0.7162 Prob > F = 0.0000

------------------------------------------------------------------------------

EPS | Coef. Std. Err. t P>|t| [95% Conf. Interval]

-------------+----------------------------------------------------------------

Cash | -33.39033 64.06299 -0.52 0.603 -160.0788 93.29812

OCF | .0001699 .000038 4.47 0.000 .0000948 .000245

SG | 41.45019 23.46928 1.77 0.080 -4.961727 87.86212

NOPAT | 696.6171 83.6663 8.33 0.000 531.1619 862.0723

CEV | 174.883 83.99209 2.08 0.039 8.783583 340.9825

_cons | -8444.642 1247.622 -6.77 0.000 -10911.89 -5977.393

-------------+----------------------------------------------------------------

sigma_u | 1856.5303
sigma_e | 918.17852

rho | .80347328 (fraction of variance due to u_i)

------------------------------------------------------------------------------

F test that all u_i=0: F(55, 136) = 7.39 Prob > F = 0.0000

est store feEPS

xtreg EPS Cash OCF SG NOPAT CEV, re

Random-effects GLS regression Number of obs = 197

Group variable: Firm1 Number of groups = 56

R-sq: Obs per group:

within = 0.4954 min = 1

between = 0.0123 avg = 3.5

overall = 0.0957 max = 6

Wald chi2(5) = 87.39

corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000

------------------------------------------------------------------------------

EPS | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------

Cash | -74.86341 63.28092 -1.18 0.237 -198.8917 49.16492

OCF | .0001523 .0000393 3.88 0.000 .0000753 .0002293

SG | 25.94422 25.0855 1.03 0.301 -23.22245 75.11089

NOPAT | 494.6586 80.94364 6.11 0.000 336.012 653.3052

CEV | -21.35552 76.26787 -0.28 0.779 -170.8378 128.1268

_cons | -3514.027 1019.916 -3.45 0.001 -5513.025 -1515.029

-------------+----------------------------------------------------------------

sigma_u | 1072.3563

sigma_e | 918.17852

rho | .57699354 (fraction of variance due to u_i)

------------------------------------------------------------------------------

est store reEPS

hausman feEPS reEPS

Note: the rank of the differenced variance matrix (4) does not equal the number of
coefficients being tested
(5); be sure this is what you expect, or there may be problems computing the test.
Examine the output

of your estimators for anything unexpected and possibly consider scaling your
variables so that the

coefficients are on a similar scale.

---- Coefficients ----

| (b) (B) (b-B) sqrt(diag(V_b-V_B))

| feEPS reEPS Difference S.E.

-------------+----------------------------------------------------------------

Cash | -33.39033 -74.86341 41.47308 9.979567

OCF | .0001699 .0001523 .0000176 .

SG | 41.45019 25.94422 15.50598 .

NOPAT | 696.6171 494.6586 201.9585 21.1702

CEV | 174.883 -21.35552 196.2386 35.18357

------------------------------------------------------------------------------

b = consistent under Ho and Ha; obtained from xtreg

B = inconsistent under Ha, efficient under Ho; obtained from xtreg

Test: Ho: difference in coefficients not systematic

chi2(4) = (b-B)'[(V_b-V_B)^(-1)](b-B)

= 19.26

Prob>chi2 = 0.0007  Chọn rEM

(V_b-V_B is not positive definite)

xttest0

Breusch and Pagan Lagrangian multiplier test for random effects

EPS[Firm1,t] = Xb + u[Firm1] + e[Firm1,t]

Estimated results:

| Var sd = sqrt(Var)

---------+-----------------------------

EPS | 2589007 1609.039

e | 843051.8 918.1785

u | 1149948 1072.356

Test: Var(u) = 0

chibar2(01) = 64.40
Prob > chibar2 = 0.0000

xtreg EPS Cash OCF SG NOPAT CEV, robust re

Random-effects GLS regression Number of obs = 197

Group variable: Firm1 Number of groups = 56

R-sq: Obs per group:

within = 0.4954 min = 1

between = 0.0123 avg = 3.5

overall = 0.0957 max = 6

Wald chi2(5) = 49.06

corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000

(Std. Err. adjusted for 56 clusters in Firm1)

------------------------------------------------------------------------------

| Robust

EPS | Coef. Std. Err. z P>|z| [95% Conf. Interval]

-------------+----------------------------------------------------------------

Cash | -74.86341 82.34526 -0.91 0.363 -236.2571 86.53033

OCF | .0001523 .0000689 2.21 0.027 .0000172 .0002873

SG | 25.94422 13.39836 1.94 0.053 -.3160862 52.20452

NOPAT | 494.6586 97.60482 5.07 0.000 303.3566 685.9605

CEV | -21.35552 104.8528 -0.20 0.839 -226.8632 184.1522

_cons | -3514.027 1228.766 -2.86 0.004 -5922.363 -1105.69

-------------+----------------------------------------------------------------

sigma_u | 1072.3563

sigma_e | 918.17852

rho | .57699354 (fraction of variance due to u_i)

------------------------------------------------------------------------------

. xtserial EPS Cash OCF SG NOPAT CEV

Wooldridge test for autocorrelation in panel data

H0: no first-order autocorrelation

F( 1, 16) = 10.156

Prob > F = 0.0057

Khi có tự tương quan thì chạy thêm GMM


xtabond2 EPS l.EPS Cash OCF SG NOPAT CEV, gmm (l1.EPS L1.Cash L1.OCF , lag(1 1)) iv( SG NOPAT
CEV ) small noconst

Favoring speed over space. To switch, type or click on mata: mata set matafavor space, perm.

Dynamic panel-data estimation, one-step system GMM

------------------------------------------------------------------------------

Group variable: Firm1 Number of obs = 187

Time variable : Year Number of groups = 55

Number of instruments = 39 Obs per group: min = 1

F(0, 187) = . avg = 3.40

Prob > F = . max = 6

------------------------------------------------------------------------------

EPS | Coef. Std. Err. t P>|t| [95% Conf. Interval]

-------------+----------------------------------------------------------------

EPS |

L1. | .6251911 .1057407 5.91 0.000 .4165931 .8337891

Cash | 96.95157 109.536 0.89 0.377 -119.1335 313.0366

OCF | .0000683 .0000257 2.66 0.008 .0000177 .000119

SG | 64.93254 24.89209 2.61 0.010 15.82714 114.0379

NOPAT | 77.95308 85.87162 0.91 0.365 -91.44852 247.3547

CEV | -116.4283 54.66218 -2.13 0.034 -224.2621 -8.594533

------------------------------------------------------------------------------

Instruments for first differences equation

Standard

D.(SG NOPAT CEV)

GMM-type (missing=0, separate instruments for each period unless collapsed)

L.(L.EPS L.Cash L.OCF)

Instruments for levels equation

Standard

SG NOPAT CEV

GMM-type (missing=0, separate instruments for each period unless collapsed)

D.(L.EPS L.Cash L.OCF)

------------------------------------------------------------------------------

Arellano-Bond test for AR(1) in first differences: z = -2.01 Pr > z = 0.044

Arellano-Bond test for AR(2) in first differences: z = 0.79 Pr > z = 0.429

------------------------------------------------------------------------------

Sargan test of overid. restrictions: chi2(33) = 73.70 Prob > chi2 = 0.000

(Not robust, but not weakened by many instruments.)


Difference-in-Sargan tests of exogeneity of instrument subsets:

GMM instruments for levels

Sargan test excluding group: chi2(15) = 24.13 Prob > chi2 = 0.063

Difference (null H = exogenous): chi2(18) = 49.58 Prob > chi2 = 0.000

iv(SG NOPAT CEV)

Sargan test excluding group: chi2(30) = 69.62 Prob > chi2 = 0.000

Difference (null H = exogenous): chi2(3) = 4.08 Prob > chi2 = 0.253

Kiểm tra các giả định hồi qui

Phân phối chuẩn qua đồ thị

histogram MVA, normal

(bin=20, start=12.204411, width=.61760009)

. histogram EPS, normal

(bin=21, start=-5038, width=1116.619)

Kiểm tra vi phạm giả định liên hệ tuyến tính giữa biến phụ thuộc và biến độc lập

. qnorm MVA

. qnorm EPS

Kiểm tra phân bố chuẩn qua giá trị Skewness và Kurtosis

. sktest MVA

Skewness/Kurtosis tests for Normality

------ joint ------

Variable | Obs Pr(Skewness) Pr(Kurtosis) adj chi2(2) Prob>chi2

-------------+---------------------------------------------------------------

MVA | 422 0.0000 0.0005 25.83 0.0000

. sktest EPS

Skewness/Kurtosis tests for Normality

------ joint ------

Variable | Obs Pr(Skewness) Pr(Kurtosis) adj chi2(2) Prob>chi2

-------------+---------------------------------------------------------------

EPS | 446 0.0000 0.0000 . 0.0000

- Viết lại phương trình là done

You might also like