R PACKAGES

Please check out my GitHub: https://github.com/tkhdyanagi


STATA PACKAGES

"panelhetero"  SSC

Stata module to implement the methods developed by Okui and Yanagi (2019) "Panel data analysis with heterogeneous dynamics" and Okui and Yanagi (2020) "Kernel estimation for panel data with heterogeneous dynamics".

You can install the package by running the following code within Stata.

ssc install panelhetero 

Suppose that we have panel data "panel.dta". In this file, the column "y" collects panel data of a univariate variable, and the columns "id" and "period" indicate individuals and time, respectively. You can implement the empirical CDF estimation ("phecdf"), the moments estimation ("phmoment"), and the kernel density estimation ("phkd") in the following way.

/// 0. Initialization


use "panel.dta"

xtset id period


/// 1. Empiricl CDF Estimaton


phecdf y, method("hpj") acov_order(0) acor_order(1)


/// 2. Moment Estimation


phmoment y, method("hpj") boot(200) acov_order(0) acor_order(1)


ereturn list

matrix list e(ci)

matrix list e(se)

matrix list e(est)


/// 3. Kernel Density Estimation


phkd y, method("hpj") acov_order(0) acor_order(1)

You can select the method from "naive", "hpj", and "toj". Each of these indicates the naive estimation without bias correction, the HPJ bias-corrected estimation, or the TOJ bias-corrected estimation, respectively. As discussed in our paper, we recommend the bias-corrected estimation rather than the naive estimation.  Each of "acov_order" and "acor_order" indicates the order of the autocovariance or that of the autocorrelation, respectively, for which the quantities of interest are estimated. Note that acov_order(0) corresponds to the (time series) variance. "boot" is the number of bootstrap replications. 

For example, "phkd" provides the following densities of the heterogeneous (time series) mean, (time series) variance, and autocorrelation. The solid line indicates the density estimates. The filled area indicates 95% (point-wise) confidence bands.