sharing is a beauty
luyued 发布于 2011-01-24 08:32 浏览 N 次A lot of ASSISTANT professors share their codes on the web:
http://kelley.iu.edu/nstoffma/
http://www.stanford.edu/~djtaylor/research/
A lot of them are qutie useful, for example:
Notes on Clustering, Fixed Effects, and Fama-MacBeth in SAS
by Noah Stoffman, Kelley School of Business, Indiana University
The code on this page shows how to run regressions with fixed effect or clustered standard errors, or Fama-Macbeth regressions in SAS. It is meant to help people who have looked at Mitchell Petersen's Programming Advice page, but want to use SAS instead of Stata.
Mitch has posted results using a test data set that you can use to compare the output below to see how well they agree. You can generate the test data set in SAS format using this code.
SAS now reports heteroscedasticity-consistent standard errors and t-statistics with the hcc option:
proc reg data=ds; model y=x / hcc; run; quit;
You can use the option acov instead of hcc if you want to see the covariance matrix of the standard errors. Thanks to Guan Yang at NYU for pointing this out. Until version 9.2, you had to use ODS to capture these statistics, which always seemed silly to me. SAS finally caught up though.
A fixed effects regression using the absorption technique can be done as follows:
proc glm; absorb identifier; model depvar = indvars / solution noint; run; quit;
Absorption is computationally fast, but the individual fixed effects estimates will not be displayed. If you want to see the fixed effects estimates, use:
proc glm; class identifier; model depvar = indvars identifier / solution; run; quit;
This will automatically generate a set of dummy variables for each level of the variable "identifier".
Clustered standard errors may be estimated as follows:
proc genmod; class identifier; model depvar = indvars; repeated subject=identifier / type=ind; run; quit;
This method is quite general, and allows alternative regression specifications using different link functions. The online SAS documentation for the genmod procedure provides detail.
Alternatively, you may use surveyreg to do clustering:
proc surveyreg data=ds; cluster culster_variable; model depvar = indvars; run; quit;
Note that GENMOD does not report finite-sample adjusted statistics, so to make the results between these two methods consistent, you need to multiply the GENMOD results by (N-1)/(N-k)*M/(M-1) where N=number of observations, M=number of clusters, and k=number of regressors. More detail is provided here.
Running a Fama-Macbeth regression in SAS is quite easy, and doesn't require any special macros. The following code will run cross-sectional regressions by year for all firms and report the means.
ods listing close; ods output parameterestimates=pe; proc reg data=dset; by year; model depvar = indvars; run; quit; ods listing; proc means data=pe mean std t probt; var estimate; class variable; run;
Since the results from this approach give a time-series, it is common practice to use the Newey-West adjustment for standard errors. Unlike Stata, this is somewhat complicated in SAS, but can be done as follows:
proc sort data=pe; by variable; run; %let lags=3; ods output parameterestimates=nw; ods listing close; proc model data=pe; by variable; instruments / intonly; estimate=a; fit estimate / gmm kernel=(bart,%eval_r(&lags+1),0); run; quit; ods listing; proc print data=nw; id variable; var estimate--df; format estimate stderr 7.4; run;
Note that the lag length is set by defining a macro variable, lags. The approach here is to use GMM to regress the time-series estimates on a constant, which is equivalent to taking a mean. This works because the Newey-West adjustment gives the same variance as the GMM procedure. (See Cochrane's Asset Pricing book for details.)
MSN空间完美搬家到新浪博客!
- 07-01· 古珀行钻戒 钻石情缘
- 07-01· 庆祝古珀行珠宝乌审旗珠
- 07-01· 加盟戴梦得古珀行成就财
- 07-01· 戴梦得古珀行代表了传统
- 07-01· 527=我爱妻 爱妻就为她做点
- 07-01· 中国时尚街拍网时尚街拍
- 07-01· 财富中国名媛学堂
- 07-01· 哥特式名媛打广告:关于叛
- 07-01· 名媛最爱 2011春季新款高跟
- 07-01· 足浴店开业宣传单为你免
- 07-01· SEM深入探究-两岸职工小发
- 07-01· 柳坪中小学主要领导
- 07-01· 移植名古树和人生历炼成
- 07-01· 亿赛通苦练内功,现身“
- 07-01· 阿美,别哭
- 07-01· [有声小说 www.51ysxs.com]“把
- 07-01· 2009年 大学生就业创业论坛
- 07-01· 创意生活点亮“个性家居
- 07-01· 各界名流齐聚2010中国新丝
- 07-01· 2011世界财富小姐英才大赛