Heckman selection model code + simulation

Indeed it is, thanks Jim! :-) What would be your take on the situation where the unobservables and the observables (X, and possibly Z) in the equations are also non-independent? This seems a likely scenario in real data. Could we potentially include a (Gaussian) copula in the model to capture/soak up the resulting regressor-error correlations? I have never seen that tried in the selection/treatment model context specifically, but in more general (endogenous) regression contexts it has been gaining some traction.

Park, S., & Gupta, S. (2012). Handling Endogenous Regressors by Joint Estimation Using Copulas. Marketing Science, 31(4), 567-586.

Tran, K.C., & Tsionas, E.G. (2015). Endogeneity in Stochastic Frontier Models: Copula Approach without External Instruments. Economics Letters, 133, 85-88.

Blauw, S.L, & Franses, Ph.H.B.F. (2016). Off the Hook: Measuring the Impact of Mobile Telephone Use on Economic Development of Households in Uganda using Copulas. Journal of Development Studies, 52(3), 315–330.

Christopoulos, D. McAdam, P., & Tzavalis, E. (March 1, 2018). Dealing with Endogeneity in Threshold Models Using Copulas: An Illustration to the Foreign Trade Multiplier. ECB Working Paper No. 2136, ISBN: 978-92-899-3241-7. Available at SSRN: https://ssrn.com/abstract=3141725.