Hi,
Ok, I've progressed and I'm willing to share my code here for anyone else who is having difficulties. This is the main method of my class: int CGarch::GarchOnArray(const std::vector<double> &iPrices, std::vector<double> &oGarch) { if (iPrices.empty()) { QL_FAIL("ERROR: input array (ts) is empty"); return -1; } if(iPrices.size < 3) { QL_FAIL("ERROR: minimum (3) individual prices not present in ts array"); return -1; } oGarch.clear(); Date ds(7, July, 1962); TimeSeries<Volatility> ts(ds, iPrices.begin(), iPrices.end()); Garch11 g11(ts, Garch11::MomentMatchingGuess); LevenbergMarquardt lm; g11.calibrate(ts, lm, EndCriteria(3, 2, 0.0, 0.0, 0.0)); g11.calibrate(ts); TimeSeries<Volatility> tsOut = g11.calculate(ts); tsOut.find(ds+ts.size()+1); oGarch = tsOut.values(); return 0; } However, I still don't understand the EndCriteria part of the code and haven't been able to find any answers in the available documentation. I'd appreciate if someone could help me explain what each parameter does. maxIterations_ Maximum number of iterations. Are these iterations through the TimeSeries data or future iterations of how many results will be returned. maxStationaryStateIterations_ Maximun number of iterations in stationary state. What is the meaning of stationary state. rootEpsilon_ root, function and gradient epsilons I assume this is the value from which the process starts searching. functionEpsilon_ What's this? gradientNormEpsilon_ What's this? I appreciate this all probably related to Levenberg-Marquardt algorithm but I'm not a maths expert and haven't done stochastic calculus so struggling a little bit with this. Really appreciate any help. Thanks in advance. ------- Internet communications are not secure and therefore Andrew Leach does not accept legal responsibility for the contents of this message. The information contained in this email is private, personal and confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. This email and any attachments have been automatically scanned for viruses prior to dispatch, but we make no warranty that they are free from computer viruses. You are advised to check all emails and attachments using your own anti virus software before opening or executing them. On 11 July 2017 at 00:26, Andrew Leach <[hidden email]> wrote:
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
maxIterations is used to tell the optimization method, regardless of the method, the maximum number of times that it should iterate. If the method does not determine success (however that is defined by the method), then it should stop after this many iterations. In general, it should mean the maximum number of times that the objective function should be evaluated, although this is not necessarily true for some methods, e.g. swarm methods for which each iteration evaluates N times the objective.
Stationary state refers here to the best answer until now. Meaning that if the optimization method does not find a better answer in the next maxStationaryStateIterations, it should stop looking.
No, all three epsilons relate to the number accuracy that the method should concern itself with. rootEpsilon refers to the number accuracy in the parameter space, e.g. when comparing whether two points are the same, they would be so considered up to the given accuracy. For most applications, the full machine accuracy (e.g. ca. 10^-15 for doubles) is not needed, so giving a wider tolerance will allow the method to stop earlier.
This epsilon refers to the accuracy at the objective/target space. If the method compares whether a new solution is as good as the best current solution, then it only cares up to the accuracy given here.
Ditto, but for the gradient. It is the obligation of the optimization method to pay attention to these parameters, but some might not be relevant. If the method does not use a gradient, then gradientNormEpsilon_ will of course not be important. There might be other parameters that might be ignored by the method, e.g. like maxStationaryStateIterations_, which for a local optimization method is also not important. cheers, Andres On Sun, Jul 23, 2017 at 8:04 PM, Andrew Leach <[hidden email]> wrote:
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thank you Andres, this helps greatly. Cheers, Andrew ------- Internet communications are not secure and therefore Andrew Leach does not accept legal responsibility for the contents of this message. The information contained in this email is private, personal and confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. This email and any attachments have been automatically scanned for viruses prior to dispatch, but we make no warranty that they are free from computer viruses. You are advised to check all emails and attachments using your own anti virus software before opening or executing them. On 23 July 2017 at 22:02, Andres Hernandez <[hidden email]> wrote:
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Andres, thanks a lot. May you include your explanation into the docs for EndCriteria in the header file and send me a PR? Luigi On Sun, Jul 23, 2017 at 11:06 PM Andrew Leach <[hidden email]> wrote:
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |