Together with Vasilis Sarafidis, I have released a new Stata package called xtivdfreg. The command implements a general instrumental variables approach for estimating large panel data models (large N and large T) with unobserved common factors or interactive effects, as developed by Norkute et al. (2020). The underlying idea of this approach is to project out the common factors from exogenous covariates using principal components analysis, and run IV regression using defactored covariates as instruments. The resulting "IVDF" method is valid for models with homogeneous or heterogeneous slope coefficients, and has several advantages relative to existing popular approaches (e.g. common correlated effects estimation). The algorithm accommodates unbalanced panel data and permits highly flexible instrumentation strategies.

You can install the command from my personal website:
Code:
net install xtivdfreg, from(http://www.kripfganz.de/stata/)
The syntax and options are explained in the Stata help file:
Code:
help xtivdfreg
The help file also contains a few examples.

For full details, see our accompanying article: Further reference: