* ================================================================== * What the do-file does: * ================================================================== * * This do-file shows how the -xtscc- program can be applied in * practice. In this application, a dataset of 219 randomly selected * European stocks is analyzed. The dataset contains the following * main variables: * * - BA: This is a relative measure of the bid ask spread (in USD). * Definition: BA_Spread = 100 * (Ask-Bid)/(0.5*(Ask+Bid)) * - TRMS: This variable contains monthly total returns of the MSCI * Europe index (in USD); Definition: TR = 100*(TRInd/L.TRInd-1) * - TRMS2: This variable contains the squared MSCI Returns: TR2 = TR^2 * - nVol: This is a normalized measure for the trading volume. * Definition: norm_Vol = 100*[ln(Vol)-avg(ln(Vol))] * - Size: Variable "Size" contains the size decile of each stock. The size * deciles are based on the market value (in USD) and are monthly * recomputed. Definition: Smallest 10% of stocks are in decile 1, * the highest capitalized stocks are in decile 10. * * Based on economic reasoning, we expect that the Bid-Ask-Spread is high, if * * - the abnormal trading volume is low (negative sign expected) * - the stock belongs to a company with low market value (negative sign expected) * - TRMS2 is high (Proxy for high market volatility; positive sign expected) * * Concerning variable TRMS no a-priori hypothesis are evident. * * __________________________________________________________________ * * Daniel Hoechle, May 2007 (First version: May 2006) * __________________________________________________________________ * Header: version 9.2 set more off clear * Description of the data: sjlog using xtscc_app_des, replace use "BidAskSpread.dta", clear describe list ID TDate Obs BA-Size in 70/75, sep(0) noobs sjlog close, replace * Performing the analysis * 1) Pooled OLS: * Pooled OLS with Driscoll-Kraay standard errors: sjlog using xtscc_pooled_ols_1, replace xtscc BA aVol Size TRMS2 TRMS, lag(8) est store DK98 sjlog close, replace * Alternative standard errors for the pooled OLS model: reg BA aVol Size TRMS2 TRMS est store OLS reg BA aVol Size TRMS2 TRMS, robust est store W80 reg BA aVol Size TRMS2 TRMS, cluster(ID) est store R93 newey BA aVol Size TRMS2 TRMS, lag(8) force est store NW87 * Produce a table containing the results (by aid of estout): #delimit ; sjlog using xtscc_pooled_ols_2, replace ; estout OLS W80 R93 NW87 DK98, style(fixed) varlabels(_cons "Const.") stats(N r2, fmt(%7.0f %4.3f)) cells(b(fmt(%6.4f) star label(Coef)) t(fmt(%6.3f) par label(tval))) modelwidth(10) varwidth(8) starlevels(* 0.10 ** 0.05 *** 0.01) hlinechar("—") prehead(" " @hline) posthead(@hline) prefoot(@hline) postfoot(@hline "Significance: @starlegend" " ") ; sjlog close, replace ; #delimit cr * =========================================================================== * 2) Panel-robust Hausman test use BidAskSpread * Perform the auxiliary regression by OLS: sjlog using hausman_1, replace * a) standard Hausman test: * Estimation of the random effects model * Note that this estimator is not fully efficient in this context because * of likely correlation between the subjects: xtreg BA aVol Size TRMS2 TRMS, re estimates store REgls * Estimation of the fixed effects model which is consistent even if the true model is * the fixed effects: xtreg BA aVol Size TRMS2 TRMS, fe estimates store FE hausman FE REgls, sigmamore // see help on -hausman- and Wooldridge (2002, p. 290). sjlog close, replace * Generate the variables for the auxiliary regression proposed by Hausman (1978). * This regression provides an asymptotically equivalent version of the ordinary Hausman test. sjlog using hausman_2, replace estimates restore REgls scalar lambda_hat = 1 - sqrt(e(sigma_e)^2 / (e(g_avg)*e(sigma_u)^2+e(sigma_e)^2)) gen in_sample = e(sample) sort ID TDate qui foreach var of varlist BA aVol Size TRMS2 TRMS { by ID: egen `var'_bar = mean(`var') if in_sample gen `var'_re = `var' - lambda_hat*`var'_bar if in_sample // GLS-transform gen `var'_fe = `var' - `var'_bar if in_sample // within-transform } * b) Perform an asymptotically equivalent version of the test as proposed by Hausman (1978): qui reg BA_re aVol_re Size_re TRMS2_re TRMS_re aVol_fe Size_fe TRMS2_fe TRMS_fe if in_sample test aVol_fe Size_fe TRMS2_fe TRMS_fe * c) panel-robust Hausman test as suggested by Wooldridge (2002): qui reg BA_re aVol_re Size_re TRMS2_re TRMS_re aVol_fe Size_fe TRMS2_fe TRMS_fe if in_sample, cluster(ID) test aVol_fe Size_fe TRMS2_fe TRMS_fe sjlog close, replace * d) Considering spatial dependence in the Hausman test: sjlog using hausman_3, replace xtscc BA_re aVol_re Size_re TRMS2_re TRMS_re aVol_fe Size_fe TRMS2_fe TRMS_fe if in_sample, lag(8) test aVol_fe Size_fe TRMS2_fe TRMS_fe sjlog close, replace * =========================================================================== * 3) Fixed-effects regression * Pooled OLS with Driscoll-Kraay standard errors: sjlog using xtscc_fe_1, replace estimates clear qui xtreg BA aVol Size TRMS2 TRMS, fe est store FE, title(\T FE) qui xtreg BA aVol Size TRMS2 TRMS, fe robust qui est store W80 qui xtreg BA aVol Size TRMS2 TRMS, fe cluster(ID) est store R93 xtscc BA aVol Size TRMS2 TRMS, fe lag(8) est store DK98 sjlog close, replace * Produce a table containing the results (by aid of estout): #delimit ; sjlog using xtscc_fe_2, replace ; estout *, style(fixed) varlabels(_cons "Const.") stats(N r2, fmt(%7.0f %4.3f)) cells(b(fmt(%6.4f) star label(Coef)) t(fmt(%6.3f) par label(tval))) modelwidth(10) varwidth(8) starlevels(* 0.10 ** 0.05 *** 0.01) hlinechar("—") prehead(" " @hline) posthead(@hline) prefoot(@hline) postfoot(@hline "Significance: @starlegend" " ") ; sjlog close, replace ; #delimit cr set more off estouttex * using xtscc_fe_2.tex, replace tablabel("FE-comparison") /// title("Comparison of standard error estimates for fixed-effects regression") /// stats(N N_g r2) sfmt(%7.0f %7.0f %4.3f) slabel("obs." "N stocks" "\$ R^2 \$") /// bfmt(%6.4f) altparam(t) afmt(%6.4f) textsize(small) * =========================================================================== * 4) Testing for cross-sectional dependence sjlog using xtscc_crosstest, replace estimates restore FE xtcsd, pesaran abs sjlog close, replace