# Code

**Accounting for Unobservable Heterogeneity in Cross Section Using Spatial First Differences. **Working Paper. Replication Code. R package (please cite Druckenmiller & Hsiang 2018 when using).

**Adjust least-squares standard errors for spatial correlation and serial correlation in panel data. **(Stata and Matlab code here)** **(The technique is GMM, as outlined by Conley 2008). Code is described here (please cite Hsiang 2010 when using).

**Move data back and forth between Stata and Matlab. **Code here. Usage is described here.

**Partial-out two variables from a model and plot them with a single command.** (Stata) Code here.

**Non-parametric regression for one or two independent variables** (Matlab) Code here. described here.

**Generate and analyze random networks** (Matlab) Poisson, Watts-Strogatz, generate overlapping stars, plotting, computing empirical connection density, clustering coeff.** **Code here.

**Data visualization tools**

**Watercolor Regression **(MATLAB)** **Display a smooth nonparametric distribution of the probability density for a nonparametric regression estimate. Code is here. Watercolor regression (described here) is a type of visually-weighted regression (described here). Citation: *Hsiang (2012) "Visually-Weighted Regression" *(here).

**Visually-Weighted Regression **(STATA & MATLAB) Use the color-saturation of a regression line to denote the statistical confidence in the regression line at each point. Code is here. Described here with several options demonstrated here and the "watercolor regression" option described here. Citation: *Hsiang (2012) "Visually-Weighted Regression" *(here).

**Three-Dimensional Nonparametric Regression** (MATLAB) Flexibly estimate means conditional on two variables with bootstrapped confidence intervals. Code is here.

**Boxplot Regression** (MATLAB) Discretize an independent variable and use boxplots as a nonparametric regression. Code is here.