Fixed Effect Estimation with Singletons
The paper "Exploiting Information From Singleton in Panel Data Analysis" (joint with RL Bruno and M Stampini) has been published in Economics Letters: https://doi.org/10.1016/j.econlet.2019.07.004
We are working to build a STATA command for this estimator.
In this page we share the STATA codes used to perform the Monte Carlo simulations and the empirical analysis reported in the paper.
Monte Carlo simulations have been obtained using the following program.
We first simulate the observations for the full balanced panel of Ns+Np units, and then randomly assign the unique observation period for the singleton units. FE and GMM estimates are then obtained.
program define bsgmm, rclass
syntax [, nbal(integer 100) ns(integer 100) tbal(integer 2) delta1(real 1) delta2(real 1) delta3(real 1) sigma2alpha(real 1) sigma2e(real 1)]
drop _all
tempvar iii ttt y x alphai gammai xxi xdemeaned balobs xcs ycs xobs periodoobs
local nobs = (`nbal' + `ns')*`tbal'
set obs `nobs'
* set the unit and time variables
gen `iii' = (ceil(_n/`tbal'))
gen `ttt' = _n-`tbal'*(`iii'-1)
sort `iii' `ttt'
xtset `iii' `ttt'
* Data generating process
gen `alphai'=invnorm(uniform()) if `ttt'==1
by `iii': replace `alphai' = `alphai'[1]
gen `gammai'=invnorm(uniform()) if `ttt'==1
by `iii': replace `gammai' = `gammai'[1]
gen `x' = `delta1' * `alphai' + `delta2' * `gammai' + `delta3'*invnorm(uniform())
gen `y' = `x' + sqrt(`sigma2alpha')*`alphai' + invnorm(uniform())*sqrt(`sigma2e')
drop `alphai' `gammai'
* Randomly assign the period of observation for the singleton units
gen `periodoobs'=runiformint(1,`tbal') if `ttt'==1
by `iii': replace `periodoobs' = `periodoobs'[1]
replace `x'=. if `iii'>`nbal' & `ttt'!=`periodoobs'
replace `y'=. if `iii'>`nbal' & `ttt'!=`periodoobs'
gen `balobs'=0
replace `balobs'=1 if `iii'<=`nbal'
* Within-group estimator
xtreg `y' `x' , fe
return scalar coeffbfe = _b[`x']
* GMM estimator
sort `iii' `ttt'
* Generate demeaned indpendent variable (within-group transformation) to be used as instrument
by `iii': egen `xxi' = mean(`x')
gen `xdemeaned' = `x'-`xxi'
* Generate new variables that only contain values for the singleton units
gen `xcs' = `x' if `iii'>`nbal'
gen `ycs' = `y' if `iii'>`nbal'
* GMM estimtor that allows exploiting information from the singleton
gmm (consres: `y' - {b1}*`x' -{b0}) (biasres: `y' - ({b1} +{d1})*`x' -({b0}+{d0})) (biasrescs: `ycs' - ({b1} +{d1})*`xcs' -({b0}+{d0})) , ///
instruments(consres: `xdemeaned') instruments(biasres: `x') instruments(biasrescs: `xcs' ) twostep winitial(unadjusted, independent) ///
nocommonesample vce(cluster `iii') wmatrix(cluster `iii') quickderivatives
return scalar coeffb1gmm = _b[b1:_cons]
return scalar coeffb0gmm = _b[b0:_cons]
return scalar coeffd1gmm = _b[d1:_cons]
return scalar coeffd0gmm = _b[d0:_cons]
end