
The numerical work in the paper was carried out using C++ code which
is not convenient for sharing with the rest of the world.

We therefore provide code in both Matlab and R to carry out the
two-step method for testing moment inequalities.


Matlab code:

The main function is called testTwoStep.m and its documentation should
be sufficiently clear. There is also a helper function called S.m.

Dependencies:
- Statistics Toolbox
- Optimization Toolbox (to compute the QLR test statistic)


R code:

The main function is called test.two.step and its documentation should
be sufficiently clear. There is also a helper function called S.
Both functions can be loaded in the work space by executing the command

> load("twoStep.R")

Needless to say, the file two.step.R needs to reside in your current
working directory (or the path name must be added when executing the
load command).

Dependencies:
- library package "quadprog"


Both codes, Matlab and R, proceed as follows: 
First compute the confidence region (4). If this region is a subset of the
third quadrant, the test decision is immediate: fail to reject; and to get
the full output, the test statistic and the critical value are set to `empty'.
Otherwise, the code continues and bases the test decision on a `proper' 
test statistic and critical value.


In case of doubt, we recommend to use the R code. First, R is free
of charge (including all library packages). Second, there appears to be
some (strange) numerical instabilities at times in Matlab when
carrying out the method based on the QLR test statistic. Third,
it also appears much slower to carry out the method based on the 
QLR test statistic in Matlab.


Both the Matlab and the R code are under the "2-clause BSD license",
also called "Simplified BSD License" or "FreeBSD License".


In case of any troubles, send me an email to michael.wolf@econ.uzh.ch.


Michael Wolf
Zurich, March 2021

PS: We thank Anastassios Kalandrakis for pointing out an issue with a previous version of the codes.




