I want to optimally solve for ARIMA coeffs. Following the logic in this post:ARIMA estimation by hand
Except I want to use an external BFGS solver (not R's optim function). So I am using libLBFGS which has a very helpful sample program optimizing a Rosenbach 'Banana Function'.
However the key part of the sample code defines a objective function and gradients (following on this post:How to use liblbfgs for fitting?)
The 'key' piece from sample.c:
for (i = 0;i < n;i += 2) {
lbfgsfloatval_t t1 = 1.0 - x[i];
lbfgsfloatval_t t2 = 10.0 * (x[i+1] - x[i] * x[i]);
g[i+1] = 20.0 * t2;
g[i] = -2.0 * (x[i] * g[i+1] + t1);
fx += t1 * t1 + t2 * t2;
}
This defined a objective function defined by all your x parameters. As well as a vector of gradients the same size as the number of variables. I am confused on how to connect these two posts. I can define my objective function easily enough in the case of solving MLE for ARIMA coeffs. But I do not understand what I am suppose to do for figuring out the gradients at each iteration. My lin alg is rusty so I am having trouble figuring out where to start.
Any help would be much appreciated.