Restricted GMM estimation

To perform restricted GMM estimation, just click the Estimation drop-down menu and select the Unrestricted entry. What you should see is the following

Note that some new fields will show up, located at the bottom-left of the window, under the general title Restrictions. Apart from these fields, all the rest are identical with the ones used in the unrestricted GMM case and thus, we are not analyze them here; you can visit the unrestricted GMM help file to check their definitions.

Restrictions

The restrictions fields are:

Fields' explanation


LB

Lower bound constraints on the estimated parameters. You must input one of the following:
A Matlab' variable that consists of the lower bound of the estimates, or
A valid Matlab expression, for example [0.5 ; 0 ; -Inf].

The size of the lower bounds must be the same as the size of the estimated parameters. See example below.
UB

Upper bound constraints on the estimated parameters. You must input one of the following:
A Matlab' variable that consists of the lower bound of the estimates, or
A valid Matlab expression, for example [1 ; 10 ; Inf].

The size of the upper bounds must be the same as the size of the estimated parameters.
Example on LB and UB

Suppose you are estimating 5 parameters, denoted by θi, i=1,2,...,5 subject to the following constraints
-1< θ1 < 1
-1<θ2
θ3 unbounded
θ4 < 20
10<θ5 < 0

In this case set the lower and upper bounds as follows:
LB = [-1 ; -1 ; -Inf ; -Inf ; 10]
UB = [ 1 ; Inf ; Inf ; 20 ; 0 ]

Constraints' function

The input must be the name of a Matlab function that computes the constraints and their first derivatives.
In order for this function to be compatible with both gmmest (the main GMM estimation procedure) and fmincon (Matlab's constrained minimization function) it must be written in the following form (see also example below):

Syntax

function [a , constr, b, constr_derivative] = constrfun(theta, varargin)

Inputs

theta: A vector with the same size as the GMM estimates (i.e. Px1).
varargin : This input is only for compatibility purposes. You must include it as the second input argument of the function. YOU DON'T NEED TO REFER TO IT WITHIN YOUR CODE.

Output

a = An output argument required only for compatibility purposes.
constr = The value of the linear/nonlinear equalities evaluated at theta. Its size must be Cx1, where C is the number of constraints
b = An output argument required only for compatibility purposes.
GCeq = Gradients of the linear/nonlinear equalities. Its size must be CxP, where C is the # of constraints and P the # of parameters

IMPORTANT: Since a and b are useless, you can set both of them equal to an empty matrix (at the beginning of the constrfun code). See example below.
Example on constraints' function

LINEAR
Suppose that you want to estimate 6 parameters, , denoted by θi, i=1, 2,...,6 subject to the following two constraints
θ1 + 0.5 θ2 - θ3 = 0
3 + θ6 = - θ5
θ4 = 5 - θ1

The three linear constraints can be expressed in the form Rθ = r, where θ is a 6x1 vector of the parameters, R is a 3x6 matrix, and r is 3x1.
The constraints must be written in a form sush that, if they are satisfied, their value is zero. In this case, the constraints will simply be defined as Rθ - r.
With that in mind, we create the following Matlab function that calculates the value and the derivative of the above constraints.

% ------------------------------- Sample code starts here -------------------------------

function [useless1, constraint, useless2, deriv_constr] = constrdemo1(theta, varargin)

useless1 = [ ]; % Set the first output element equal to an empty matrix since it is useless
useless2 = [ ]; % Same as above
R = [ 1 0.5 -1 0 0 0; 0 0 -1 0 1 1; 1 0 0 1 0 0];
r = [0 ; 0 ; 5]
constraint = R*theta - r;
deriv_constr = R;
% ------------------------------- Sample code ends here -------------------------------

NONLINEAR
Now, suppose that you want to estimate the same six parameters as above subject to the following linear/nonlinear constraints
θ1 - θ3 = 0
sin(θ46) = θ2

In this case the function used is

% ------------------------------- Sample code starts here -------------------------------

function [eraseme1, cons, eraseme2, der] = constrdemo2(theta, varargin)

eraseme1 = [ ]; % Set the first output element equal to an empty matrix since it is useless
eraseme2 = [ ]; % Same as above
first_constr = theta(1,1) - theta(3,1);
second_constr = sin(theta(4,1) + theta(6,1)) - theta(2,1);

cons = [first_constr ; second_constr];

% Derivative of the first constraint w.r.t. θ.
der1 = [1 0 -1 0 0 0];


% Derivative of the second constraint w.r.t. θ.
der2 = [0 -1 0 cos(theta(4,1)+theta(6,1)) 0 cos(theta(4,1)+theta(6,1))];

der = [der1 ; der2]
% ------------------------------- Sample code ends here -------------------------------