Curve fitting via stats::optim
L-BFGS-B with fall-back grid/pattern search
if convergence is not achieved.
dot-fitCurve2.Rd
Function to fit curve via stats::optim
Arguments
- par
numeric
Vector of intial guesses for the parameters. For each indexi
ofpar
, par[i] must be within the range (lower\[i\]
,upper\[i\]
). If only a singleupper
orlower
value is present, that range is used for all parameters inpar
.- x
numeric
Values to evaluatefn
for.- y
numeric
Target output values to optimzefn
against.- fn
function
A function to optimize. Anyfn
arguments passed via...
will be treated as constant and removed from the optimization. It is assumed that the first argument is the x value to optimize over and any subsequent arguments are free parameters to be optimized. Transformed to be optim compatible viamake_optim_function
is the first arguement isn't alreadypar
.- loss
character(1)
orfunction
Either the name of one of the bundled loss functions (see details) or a custom loss function to compute for the output offn
overx
.- lower
numeric(1)
Lower bound for parameters. Parallel topar
.- upper
numeric(1)
Upper bound for paramteres. Parallel topar
.- precision
numeric
smallest step size used in pattern search, once step size drops below this value, the search terminates.- density
numeric
how many points in the dimension of each parameter should be evaluated (density of the grid)- step
initial step size for pattern search.
- ...
pairlist
Fall through arguments tofn
.- loss_args
list
Additional argument to theloss
function. These get passed to losss viado.call
analagously to using...
.- span
numeric
Can be safely kept at 1, multiplicative ratio for initial step size in pattern search. Must be larger than precision.- optim_only
logical(1)
Should the fall back methods when optim fails be skipped? Default isFALSE
.- control
list
List of control parameters to pass tooptim
. See?optim
for details.