recsCheck Checks analytical derivatives against numerical ones
When the model file is not generated automatically by dolo-recs, recsCheck is
useful to verify that the hand-coded Jacobians are good.
recsCheck(MODEL,S,X,Z) checks analytical derivatives on the point defined by
the 1-by-d vector of state variables, S, the 1-by-m vector of response
variables, X, and the 1-by-p vector of expectations variables, Z. In this
default case, recsCheck tests the derivatives for shocks at their mean level;
for next-period state variables equal to S; and for next-period response
variables equal to X.
recsCheck(MODEL,S,X,Z,E) checks derivatives for the value of the shocks
supplied in E.
recsCheck(MODEL,S,X,Z,E,SNEXT) checks derivatives for the value of next-period
state variables supplied in SNEXT.
recsCheck(MODEL,S,X,Z,E,SNEXT,XNEXT) checks derivatives for the value of
next-period response variables supplied in XNEXT.
recsCheck(MODEL,S,X,Z,E,SNEXT,XNEXT,PRECISION) uses the scalar PRECISION as a
limit (default: 1e-4).
ERR = recsCheck(MODEL,S,X,Z,...) returns ERR, a 1x9 vector containing the maximal
differences between analytical and numerical derivatives.
[ERR,DISCREPANCY] = recsCheck(MODEL,S,X,Z,...) returns DISCREPANCY, a
structure containing the detailed differences between analytical and numerical
derivatives. Each structure field contains a 3-column matrix indicating the
element showing a discrepancy higher than PRECISION. The first column
indicates the equations, the second column the variables and the third the
discrepancy.