Curve fitting via stats::optim L-BFGS-B with fall-back grid/pattern search if convergence is not achieved.
dot-fitCurve2.RdFunction to fit curve via stats::optim
Arguments
- par
numericVector of intial guesses for the parameters. For each indexiofpar, par[i] must be within the range (lower\[i\],upper\[i\]). If only a singleupperorlowervalue is present, that range is used for all parameters inpar.- x
numericValues to evaluatefnfor.- y
numericTarget output values to optimzefnagainst.- fn
functionA function to optimize. Anyfnarguments 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_functionis the first arguement isn't alreadypar.- loss
character(1)orfunctionEither the name of one of the bundled loss functions (see details) or a custom loss function to compute for the output offnoverx.- lower
numeric(1)Lower bound for parameters. Parallel topar.- upper
numeric(1)Upper bound for paramteres. Parallel topar.- precision
numericsmallest step size used in pattern search, once step size drops below this value, the search terminates.- density
numerichow many points in the dimension of each parameter should be evaluated (density of the grid)- step
initial step size for pattern search.
- ...
pairlistFall through arguments tofn.- loss_args
listAdditional argument to thelossfunction. These get passed to losss viado.callanalagously to using....- span
numericCan 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
listList of control parameters to pass tooptim. See?optimfor details.