CMLMT how to obtain a NxK matrix of first derivatives (gradient)

Hi,

I am estimating a nonlinear model which does not have an analytic gradient using the CMLMT package.

I need to obtain a Nx1 vector of log-likelihood value and a NxK numerical gradient for the final estimated value.  The manual says:

Output Argument: Model Results Instance

The members of this structure are

2. Vector of log-likelihood by observations

Function Nx1 vector of log likelihood

                      Gradient NxK matrix of first derivative (optional)

It seems  like this is feasible with the package. Can anyone give me an example code on extracting the vector likelihood and gradient matrix out ? Thank you very much.

Shuping

1 Answer



0



When your procedure returns a vector of log-probabilities, and you choose the BHHH descent method, CMLMT will estimate the matrix of second derivatives as the cross-product of the NxK matrix of first derivatives.  This is the recommended method for CMLMT because the estimates will be more accurate.

The NxK matrix of first derivatives is not returned by CMLMT, but producing it is straightforward:

struct cmlmtResults out;
out = CMLmt(&lpr,p0,d0,c0));

// F is the Nx1 vector of function values
// G is the NxK matrix of first derivatives

F = lpr(out.par,d0);
G = gradmt(&lpr,out.par,d0);

Your Answer

1 Answer

0

When your procedure returns a vector of log-probabilities, and you choose the BHHH descent method, CMLMT will estimate the matrix of second derivatives as the cross-product of the NxK matrix of first derivatives.  This is the recommended method for CMLMT because the estimates will be more accurate.

The NxK matrix of first derivatives is not returned by CMLMT, but producing it is straightforward:

struct cmlmtResults out;
out = CMLmt(&lpr,p0,d0,c0));

// F is the Nx1 vector of function values
// G is the NxK matrix of first derivatives

F = lpr(out.par,d0);
G = gradmt(&lpr,out.par,d0);

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.