MATLAB Code

Nonparametric and semiparametric estimation

KleinSpady.m

Implements the Klein-Spady estimator for a semiparametric binary-choice model of the form D = 1(X*beta + epsilon >= 0). The distribution of the error is left unspecified and estimated using kernel or local linear regression. The program returns coefficient estimates, marginal effects, and the error density evaluated at the index mean.

Ichimura.m

Implements the Ichimura estimator for the semiparametric regression model Y = g(X*b) + e using kernel regression with the quartic kernel. The first coefficient is normalized to one. The program returns coefficient estimates, marginal effects, and the derivative of g evaluated at the index mean. A bandwidth may be supplied by the user or calculated using the program's default rule.

ks.m

Implements multidimensional nonparametric regression using either local-constant kernel regression or local linear regression. The program accepts a user-provided bandwidth or a bandwidth selected by cross-validation and returns the fitted value of the outcome at each observation.

opt_h.m

Uses cross-validation to select a bandwidth for multidimensional kernel regression or local linear regression.

Stata Code

GMM, binary-choice, and sample-selection routines

gmmAll.do

Performs linear or nonlinear GMM estimation after the user supplies the parameters and moment functions. The code includes examples for a binary-choice model, a sample-selection model, and the return-to-schooling application in Lewbel (2005).

These commands estimate a binary-choice model with potentially endogenous regressors, given a very exogenous regressor V, following Lewbel (2005).

  1. simpbin0 assumes that the density of V is known.
  2. simpbin1 assumes that V is conditionally normal.
  3. simpbin2 uses a nonparametric sorted-data density for the model error.

These commands estimate a selected-sample model with potentially endogenous regressors, given a very exogenous regressor V in the selection equation, following Lewbel (2005).

  1. simpsel1 assumes that the selection-model error is normal.
  2. simpsel2 uses a nonparametric sorted-data density for the selection-model error.
  1. sortedf1 calculates a nonparametric sorted-data density, following Lewbel and Schennach (2007). It is called by simpbin2 and simpsel2.
  2. sortuniq1 is called by sortedf1. It sorts the data and retains unique values in ascending order.
  3. zrnd rounds a number close to zero away from zero.