_NumJac
Description
_NumJac computes the Jacobian of the model (the derivatives of the fitted values with respect to each parameter) by central differences, for NLS and _LMFit.
Used by: NLS
Source Code
_NumJac = LAMBDA(
fw, // LAMBDA(p): n x 1 column of (weighted) fitted values
p, // parameters as a column
[delta], // relative step (default 1E-5)
LET(
delta, IF(ISOMITTED(delta), 10 ^ -5, delta),
k, ROWS(p),
h, delta * IF(p = 0, 1, ABS(p)),
cols, REDUCE(
0,
SEQUENCE(k),
LAMBDA(acc, j,
LET(
e, h * (SEQUENCE(k) = j),
HSTACK(acc, (fw(p + e) - fw(p - e)) / (2 * INDEX(h, j)))
)
)
),
DROP(cols, , 1)
)
);