Useful codes

A collection of useful codes and Stata routines for panel data econometrics, macroeconomic filtering, and cross-country dataset merging.

1. Roy-Zellner Test by Hand (Stata)


Download RZ_test.do ↓

Routine to test coefficient poolability across panel units (unpooled vs. pooled Random Effects specification) using the classic Grunfeld dataset:

set more off

webuse grunfeld
xtset company year, yearly

*Create a set of individual dummy variables
xi, prefix(F) i.company

gen Fcompany_1=1 if company==1 
replace Fcompany_1=0 if company!=1

*Interact these dummies with the regressors of interest: mvalue kstock
foreach var of varlist mvalue kstock {
    foreach num of numlist 1(1)10 {
        gen `var'_`num'=`var'*Fcompany_`num'
    }
}

*RE regression for the unpooled data
quietly xtreg invest kstock_* mvalue_*, re

*Test for the equality of the coefficients of the unpooled vs pooled data:
test (mvalue_1 = mvalue_2 = mvalue_3 = mvalue_4 = mvalue_5 = mvalue_6 = mvalue_7 = mvalue_8 = mvalue_9 = mvalue_10) (kstock_1 = kstock_2 = kstock_3 = kstock_4 = kstock_5 = kstock_6 = kstock_7 = kstock_8 = kstock_9 = kstock_10)

2. Fiorito & Kollintzas (1994) Filtering Routine

Implementation of the business cycle methodology from Fiorito & Kollintzas, European Economic Review (1994) featuring winsorizing and multiple detrending filters. (Available upon request)

3. Fast-kountry.ado (Country Standardization)

Modified Stata command that standardizes and converts country names from heterogeneous international sources into numeric ISO-3N codes, streamlining the merging of cross-country datasets indexed by ISO country numbers. (Available upon request)