Readme file for data and MATLAB codes accompanying 
Estimation and Inference in Spatial Models with Dominant Units 
by M. Hashem Pesaran and Cynthia Fan Yang

This version: January 2020
Please report any issues to Cynthia Yang 
cynthia.yang@fsu.edu


## List of Files:
--------------------
Monte Carlo Simulations
--------------------
# Main programs:
main_MC.m			Main program to run simulations 
				under various DGPs with different estimation methods
outtab.m			Tabulates MC results (in the format of the tables in the supplement)
plot_power_main_paper.m         Plots empirical power functions for BMM and GMM estimators as displayed in the main paper
plot_power_supplement.m		Plots empirical power functions for BMM, GMM and ML estimators as displayed in the supplement

# Functions:
BMM_moment_SARX_iid.m		Forms moment conditions for the BMM estimator assuming homoskedastic errors
BMM_moment_SARX_het.m		Forms moment conditions for the BMM estimator assuming heteroskedastic errors
GMM_multiP_moment_SARX.m	Forms moment conditions for the GMM estimator
GMM_multiP_var_SARX_iid.m	Computes variance of the GMM estimator assuming homoskedastic errors 
GMM_multiP_var_SARX_het.m	Computes variance of the GMM estimator assuming heteroskedastic errors
invpd.m*			Computes generalized inverse (required for MLE)
matadd.m*			Performs matrix addition if only row or column is compatible (required for MLE)
nearestSPD.m***			Finds the nearest positive definite matrix
normw.m*			Normalizes row sums of a matrix such that each row sums to unity
qqWeight.m			Generates "q ahead and q behind" spatial weights matrix
sar2.m				Implements ML estimation
f_sar.m*			Evaluates concentrated log-likelihood (required for MLE)
f2_sar.m*			Evaluates log-likelihood (required for MLE)
lndetfull.m*			Computes log det(I-rho*W) using sparse matrices (required for MLE)

--------------------
Empirical Application
--------------------
# Data:
data_application.mat		Data used in the empirical application
				Contains price levels and W matrices
# Codes:
main_application.m		Main program for the empirical application
est_delta.m**			Estimates the degrees of dominance
BMM_SARX.m			Implements the BMM estimation
rbstw.m				Constructs robust spatial weights matrix with a given threshold
The rest of the .m files are the same as those in the MC_programs folder. 

Notes:
* Codes from the Econometrics Toolbox by James P. LeSage.
** This function was part of the replication package accompanying the study by Pesaran and Yang (2019). 
*** Retrieved from MATLAB Central File Exchange. Only used for BGMM estimation of pure SAR models
    when rho=0.95 and delta=1. 

References:
John D'Errico (2014). nearestSPD (https://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd),
	MATLAB Central File Exchange.
Lesage, J. P. Econometrics Toolbox Version 7. Available at https://www.spatial-econometrics.com/.
Pesaran, M. H. and C. F. Yang (2019). Econometric analysis of production networks with dominant units. 
	Journal of Econometrics (forthcoming).