* ================================================================== * 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 normalized 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 TR_MS no a-priori hypothesis are evident. * * __________________________________________________________________ * * Daniel Hoechle, May 2007 * __________________________________________________________________ * Header: version 9.2 set more off clear * Load the dataset: use "BidAskSpread.dta", clear * ================================================================== * Pooled OLS estimation (Table 2 of the paper). * ================================================================== * 1) Linear regression with OLS standard errors: reg BA aVol Size TRMS2 TRMS est store OLS * 2) OLS regression with White standard errors: reg BA aVol Size TRMS2 TRMS, robust est store White * 3) OLS regression with Rogers standard errors: reg BA aVol Size TRMS2 TRMS, cluster(ID) est store Rogers * 4) OLS regression with Newey and West standard errors * (lag length is arbitrarily set to 8): sort ID TDate newey BA aVol Size TRMS2 TRMS, lag(8) force est store Newey * 5) OLS regression with Driscoll and Kraay standard errors * (lag length is arbitrarily set to 8): xtscc BA aVol Size TRMS2 TRMS, lag(8) est store Driscoll * Plot the results (Note: -estout- is a user written command by Ben Jann). * ==> This produces Table 2 in the paper. estout *, style(smcl) varlabels(_cons "Constant") /// stats(N N_clust N_g r2, fmt(%9.0f %9.0f %9.0f %4.3f)) /// cells(b(fmt(%7.4f) star label(Coef)) t(fmt(%7.4f) par label(tval))) * ================================================================== * Perform several variants of the Hausman test * ================================================================== estimates clear * a) Standard Hausman test: * Estimation of the random effects model. * Note that this estimator is not fully efficient under the * null hypothesis due to likely cross-sectional dependence. 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 model. xtreg BA aVol Size TRMS2 TRMS, fe estimates store FE * Hausman test (see help on -hausman- and Wooldridge (2002, p. 290)) hausman FE REgls, sigmamore * b) An asymptotically equivalent version of the ordinary Hausman test. * Generate the variables for the auxiliary regression proposed * by Hausman (1978). This regression facilitates an asymptotically * equivalent version of the ordinary Hausman test. 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 } * Alternative Hausman test. 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 proposed by Wooldridge (2002). 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 * d) Spatial dependence consistent Hausman test. 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 * ================================================================== * Fixed effects (within) regression (Table 3 of the paper). * ================================================================== estimates clear * 1) FE-Regression with OLS standard errors. xtreg BA aVol Size TRMS2 TRMS, fe est store FE_OLS * 2) FE-Regression with White standard errors. xtreg BA aVol Size TRMS2 TRMS, fe robust est store FE_White * 3) FE-Regression with Rogers standard errors. xtreg BA aVol Size TRMS2 TRMS, fe cluster(ID) est store FE_Rogers * 4) FE-Regression with Driscoll and Kraay standard errors. xtscc BA aVol Size TRMS2 TRMS, fe lag(8) est store FE_Driscoll * Plot the results with -estout-. * ==> This produces Table 3 of the paper. estout *, style(smcl) varlabels(_cons "Constant") /// stats(N N_clust r2, fmt(%9.0f %9.0f %4.3f)) /// cells(b(fmt(%7.4f) star label(Coef)) t(fmt(%7.4f) par label(t-value))) * ================================================================== * Testing for cross-sectional dependence * ================================================================== estimates restore FE_OLS // restore the fixed effects estimates * Perform Pesaran's (2004) CD test. * (Note: -xtcsd- is a user written command by Rafael De Hoyos and Vasilis Sarafidis) xtcsd, pesaran abs * end of do-file