DIFFER

Options     Examples

DIFFER differentiates a TSP equation analytically with respect to the list of arguments and stores each derivative in parsed form as another TSP equation (FRML). These equations may be evaluated using GENR, used in estimation, or printed just like any other TSP equation.

DIFFER (DEPVARPR=<new dependent variable name>, PRINT,

                 PREFIX=<new equation name>)

                <equation name> <list of arguments> ;

Usage

DIFFER requires the name of the equation to be differentiated, followed by one or more arguments for differentiation. If any of the arguments are not in the equation, a zero derivative will be stored (no error will be trapped). If the equation is unnormalized (no left hand side variable), the derivative equation will also be unnormalized.

Output

Ordinarily, DIFFER produces no printed output. It stores the derivatives as equations in data storage. If the PRINT option is specified, DIFFER prints each equation in symbolic form with a title specifying what the derivative is.

Options

DEPVARPR= prefix for new dependent variable. The default is Dlhsvar . If the original equation has no dependent variable (is unnormalized), then the default is to create unnormalized derivative equations.

PRINT/NOPRINT tells whether the resulting derivative equations are to be printed.

PREFIX= the name to be given to the derivative equations if the names Deqname1, etc. are not wanted. The equation names will consist of the prefix name followed by the argument number for that derivative.

Examples

  1. Using the default options:

FRML EQ Y = A + B*X + G*X**2;

DIFFER EQ A B X Q;

creates the following FRMLs:

FRML DEQ1 DY1 = 1;                               ? dY/dA

FRML DEQ2 DY2 = X;                              ? dY/dB

FRML DEQ3 DY3 = B + 2*G*X;               ? dY/dX

FRML DEQ4 DY4 = 0;                               ? dY/dQ

  1. Using some prefix options for naming the results:

FRML EQ Y = A + B*X + G*X**2;

DIFFER(PREFIX=GYX,DEPVAR=MPX) EQ X;

creates the following FRML:

FRML GYX1 MPX1 = B + 2*G*X;                       ? dY/dX

  1. Unnormalized equation (residual from AR(1) model):

FRML E Y - (A + B*X) - RHO*(Y(-1) - (A+B*X(-1));

DIFFER E B;

creates the following (unnormalized) FRML:

FRML DE1 -X + RHO*X(-1);

  1. Differentiate a Constant Elasticity of Substitution production function with respect to the two inputs K and L, compute the two marginal product series using the derivative equations, and print them.

FRML CES Y=A*EXP(GAM*T)* (ALPHA*L**RHO+BETA*K**RHO)**(1/RHO) ;

DIFFER CES L K ;

GENR DCES1 LMP ; GENR DCES2 KMP ;

PRINT LMP KMP ;

  1. Differentiate the log likelihood for a PROBIT model with respect to its parameters and store the generated equations.

FRML PROBIT LOGL = LOG(D*CNORM(A+B*X) + (1-D)*(1-CNORM(A+B*X)));

DIFFER (PRINT,PREFIX=LOGL) PROBIT A B ;

The results are:

FRML LOGL1 DLOGL1 = [D*(NORM(A+B*X)+(1-D)*(-NORM(A+B*X))] /

                         [D*CNORM(A+B*X)+(1-D)*(1-CNORM(A+B*X))] ;

FRML LOGL2 DLOGL2 = [D*(NORM(A+B*X)*X+(1-D)*(-NORM(A+B*X)*X)] /

                        [D*CNORM(A+B*X)+(1-D)*(1-CNORM(A+B*X))];

This example illustrates the convenience of DIFFER when you use it to generate analytic derivatives of an objective function for use in another program or language, such as Fortran.