全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
7847 7
2009-08-17

I need to run the following fama-macbeth approach regression

Ri = C+B1LogMe+B2LogBTM+B3IdioStdi,1+B4Coskewi,1

+B5RETi,1+B6RETi,7:2+B7RETi,13:8+B8RETi,60:14

+B9IndMeanj,1+B10IndMeanj,2+B11IndMeanj,12:3+B12IndStdj,1

+B13IndSkewj,1+ei,

I am doing my dissertation, I should test the relation btw skewness and stock returns,
I have all data...my tutor helped me to transfer raw data to the useable data with each variable

But I do not know how to run it...shame.....

I googled, and find one ado file, I run it, nothing happens.....so  still do not know how to deal with it

I just know some basic stata command...and some basic test....


ANYONE,
HELP ........ thousands THANKS...............



二维码

扫码加我 拉你入群

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

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

全部回复
2009-8-17 22:46:15
I do not know how to attach file....shame....so I paste it......

PLEASE, EN REN, HELP ME!!
二维码

扫码加我 拉你入群

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

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

2009-8-17 23:21:08
program fmregress, eclass
    version 8
    syntax varlist(ts min=2)            ///
        [                               ///
            ,   NOCONStant              ///
                LAG(integer 0)          ///
                DROPFirst(integer 0)    ///
        ]
    *macro list
    *disp("I'm in")
    quietly capture xt_tis `t'
    if _rc {
        disp as err "Use tsset before fmreg"
        exit 111
    }
    *disp("Tsset checked")
   
    quietly summarize `s(timevar)'
    *disp("I've analyzed `s(timevar)'")
    local tmin = r(min) + `dropfirst'
    local tmax = r(max)
    local T = `tmax' - `tmin' + 1
    local tminplus1 = `tmin' + 1
    *disp("Time limits obtained tmin: `tmin' tmax: `tmax' T: `T'")
    * Regressions
    quietly regress `varlist' if `s(timevar)' == `tmin' ///
        , `noconstant'
    *disp("First regression done")
    matrix betas   = e(b) /// these are saved from the regression
    *disp("We have the betas of the first regression")
    matrix NumObs   = `e(N)'
    *disp("We have n of the firt regression")
    quietly forval i = `tminplus1'/`tmax' { /// Loop begins
        regress `varlist' if `s(timevar)' == `i', `noconstant'
        matrix betas     = betas\e(b)
        matrix NumObsAux = `e(N)'
        matrix NumObs    = NumObs\NumObsAux
    }
    *disp("Regressions done")
    matrix U = J(rowsof(betas),1,1)
    *disp("Matrix U constructed")
    matrix beta = U'*betas/rowsof(betas)
    *disp("Coefficients estimated")
    matrix TotObsAux = U'*NumObs
    *disp("Total number of observations computed")
    matrix betasMinusBeta = betas - ///
        J(rowsof(betas),colsof(betas),1)*diag(beta)
    matrix V = betasMinusBeta'*betasMinusBeta / ///
            (rowsof(betasMinusBeta)*(rowsof(betasMinusBeta) - 1))
    *scalar d = det(V)
    *display d
    *disp("VCV matrix of coefficients estimated")
    forval j = 1/`lag' {
        *disp("I'm in the loop for Newey-West correction")
        scalar weight   = 1 - `j'/(1 + `lag')
        scalar lIni = 1 + `j'
        scalar lFin = rowsof(betasMinusBeta) - `j'
        matrix Vaux = ///
            betasMinusBeta[lIni...,1...]'*betasMinusBeta[1..lFin,1...] / ///
            ((rowsof(betasMinusBeta) - `j')*(rowsof(betasMinusBeta) - `j' - 1))
        matrix V = V + weight*(Vaux + Vaux')
    }
    *disp("I'm going to create ereturn")
    *scalar d = det(V)
    *display d
    ereturn post beta V
    *disp("Ereturn created")
    ereturn scalar N = TotObsAux[1,1]
    if "`noconstant'" != "" {
        ereturn scalar df_m = colsof(betas)
    }
    else {
        ereturn scalar df_m = colsof(betas) - 1
    }
    ereturn scalar df_r = e(N) - colsof(betas)
    ereturn scalar lag  = `lag'
    ereturn local cmd "fmregress"
    ereturn local depvar "`1'"
    *disp("ereturn filled")
   
    disp _n in gr ///
        `"Fama MacBeth regression with Newey-West standard errors"'
    disp in gr `"Number of obs  ="' in yel %10.0f e(N)
    disp in gr `"Maximum lag    ="' in ye %10.0f e(lag)   
    ereturn display
   
    matrix drop _all
    scalar drop _all
    *disp("I'm out")
end
*-----------------------------------------------------------------------
二维码

扫码加我 拉你入群

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

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

2009-8-18 08:14:19
ssc install xtfmb, replace

*------------------
xtfmb is an implementation of the Fama and MacBeth (J. Polit.  Econ. 1973) two step procedure.
二维码

扫码加我 拉你入群

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

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

2009-8-18 19:37:21
4# arlionn Thanks for your help, arlionn. but still doesnot work It says . ssc install xtfmb, replace connection timed out -- see help r(2) for troubleshooting http://fmwww.bc.edu/repec/bocode/x/ either 1) is not a valid URL, or 2) could not be contacted, or 3) is not a Stata download site (has no stata.toc file). r(2); I load the ado file I can use, but I donot know how to do my regression.

Thanks for your help, arlionn. but still doesnot work
It says
. ssc install xtfmb, replace
connection timed out -- see help r(2) for troubleshooting
http://fmwww.bc.edu/repec/bocode/x/ either
  1)  is not a valid URL, or
  2)  could not be contacted, or
  3)  is not a Stata download site (has no stata.toc file).
r(2);

I load the ado file I can use, but I donot know how to do my regression.
二维码

扫码加我 拉你入群

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

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

2011-7-27 22:15:46
poor girl, bless
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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