its like optim, but with fixed parameters.
1 2 3 |
specify a second argument 'fixed', a vector of numerical values. There are three options (a) To indicate that the parameter in fn() is optimised over, use 0 (b) To indicate that the parameter in fn() is fixed to its starting value, use its index. Thus, if the Nth parameter in fn() is fixed to the starting value, then fixed[N] <- N. (c) To indicate that the parameter in fn() is fixed to the value of another parameter, use the index of that parameter. Thus, if the Nth parameter in fn() should have the same value as the Mth parameter, then fixed[N] <- M.
The return thing is the return thing from optim() but with a couple of extra bits - a vector of all the parameters and a vector copy of the 'fixed' argument.
This function was adapted by Fabian Soto from code originally written by Barry Rowlingson <b.rowlingson@lancaster.ac.uk> in October 2011 and released under a CC By-SA license: http://creativecommons.org/licenses/by-sa/3.0/
Any use of this script must retain the text: "Originally written by Barry Rowlingson" in comments.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.