全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
3334 2
2015-10-10

大家好,
       最近在看一段QEPM(by Daehwan Kim & Ludwig Chincarini)的一个模型,用于分析股票的基本面因子,下面有段stata代码,我之前没有用过stata,其中有个符号不太了解,即代码中标红的 i.month,不知道这个i.month是什么意思?


程序代码如下。
*****************************************************************
*         Fundamental Factor Model
*****************************************************************;


cd "E:\QEPM\Classroom_Labs\Chapter6"
/* let stata recognize the end-of-command only when it encounters semi colon */
#delimit ;
/* remove data, if any, in the current memory */
clear;

/* allow long screen output */
set more on;

/* increase the size of memory available to stata */
set memory 200m;

/* open log file */
log using Output.txt, text replace;

/* load the data set */
use data_Ch6;


* ---------------------------------------------------------------
        Section 1. Preparing data for analysis
* ---------------------------------------------------------------;

/* create new variable - 6 month price momentum
        the sum of monthly returns for the past 6 months
        note - retLEAD is lead return,
        thus current retLEAD is not included in the current momentum */
gen momentum = retLEAD[_n-1] + retLEAD[_n-2] + retLEAD[_n-3]
        + retLEAD[_n-4] + retLEAD[_n-5] + retLEAD[_n-6]
        if ticker==ticker[_n-6] & month==month[_n-6]+6;

/* take logarithm of price2cashflow and price2earnings */
gen p2cflog = log(price2cashflow);
gen p2elog = log(price2earnings);

/* select observations that have no missing values */
keep if retLEAD~=. & marketcap~=. & p2cflog~=. & p2elog~=. & momentum~=.;



* ---------------------------------------------------------------
*        Section 2. Pooled OLS
* ---------------------------------------------------------------;

/* pooled OLS */
xi: reg retLEAD market momentum p2cflog p2elog i.month;

/* close the log file */
log close;

*****************************************************************


程序输出结果为



. * ---------------------------------------------------------------
> *
> *       Section 2. Pooled OLS
> *
> * ---------------------------------------------------------------;
. /* pooled OLS */
> xi: reg retLEAD market momentum p2cflog p2elog i.month;
i.month           _Imonth_575-598     (naturally coded; _Imonth_575 omitted)

      Source |       SS           df       MS      Number of obs   =    74,254
-------------+----------------------------------   F(27, 74226)    =    346.43
       Model |  5684334.17        27  210530.895   Prob > F        =    0.0000
    Residual |  45108076.3    74,226  607.712611   R-squared       =    0.1119
-------------+----------------------------------   Adj R-squared   =    0.1116
       Total |  50792410.5    74,253   684.04523   Root MSE        =    24.652

------------------------------------------------------------------------------
     retLEAD |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   marketcap |  -7.94e-06   4.92e-06    -1.62   0.106    -.0000176    1.70e-06
    momentum |  -.0153397   .0018082    -8.48   0.000    -.0188838   -.0117956
     p2cflog |  -.4573508   .1715685    -2.67   0.008    -.7936244   -.1210772
      p2elog |  -.9739865   .1685167    -5.78   0.000    -1.304278   -.6436945
_Imonth_576 |    3.15918   1.867638     1.69   0.091    -.5013819    6.819742
_Imonth_577 |  -.5085492   1.892008    -0.27   0.788    -4.216876    3.199778
_Imonth_578 |   9.007866    1.45706     6.18   0.000     6.152034     11.8637
_Imonth_579 |   9.132751   1.455428     6.27   0.000     6.280119    11.98538
_Imonth_580 |  -2.767544   1.452197    -1.91   0.057    -5.613844    .0787557
_Imonth_581 |   5.978743   1.450877     4.12   0.000     3.135029    8.822456
_Imonth_582 |   7.871138   1.450424     5.43   0.000     5.028313    10.71396
_Imonth_583 |  -3.915814   1.450586    -2.70   0.007    -6.758955   -1.072672
_Imonth_584 |  -14.94025   1.448624   -10.31   0.000    -17.77954   -12.10095
_Imonth_585 |  -7.411348   1.448887    -5.12   0.000    -10.25116   -4.571536
_Imonth_586 |   9.102145   1.449591     6.28   0.000     6.260953    11.94334
_Imonth_587 |  -.4793444   1.452459    -0.33   0.741    -3.326158    2.367469
_Imonth_588 |  -6.520058   1.452944    -4.49   0.000    -9.367824   -3.672293
_Imonth_589 |   14.06517   1.454562     9.67   0.000     11.21423     16.9161
_Imonth_590 |   21.79714   1.467225    14.86   0.000     18.92138    24.67289
_Imonth_591 |   13.03934   1.466635     8.89   0.000     10.16474    15.91394
_Imonth_592 |   7.955849   1.468227     5.42   0.000      5.07813    10.83357
_Imonth_593 |   14.07528   1.465864     9.60   0.000      11.2022    16.94837
_Imonth_594 |   10.05913     1.4669     6.86   0.000     7.184009    12.93425
_Imonth_595 |   12.46179   1.466838     8.50   0.000     9.586797    15.33679
_Imonth_596 |   3.070499   1.462477     2.10   0.036      .204049    5.936948
_Imonth_597 |   8.846312   1.460175     6.06   0.000     5.984375    11.70825
_Imonth_598 |    11.0687   1.458888     7.59   0.000     8.209286    13.92812
       _cons |   .0337961   1.422419     0.02   0.981     -2.75414    2.821732
------------------------------------------------------------------------------



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-10-12 14:11:13
i.month是按月份生成虚拟变量,如果months有12个月,就生成12个虚拟变量,不过stata会自动剔除一个,避免多重共线性
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-10-20 18:53:01
houyunhuang 发表于 2015-10-12 14:11
i.month是按月份生成虚拟变量,如果months有12个月,就生成12个虚拟变量,不过stata会自动剔除一个,避免多 ...
明白了,多谢。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群