View source: R/combine_and_fit_function.R
combine.and.fit | R Documentation |
Combines fitted and non-fitted parameters and calls the fitting function. Serves as a wrapping function for the user-specified fitting function fit.fn
(see famos
).
combine.and.fit(par, par.names, fit.fn, binary = NULL, default.val = NULL, ...)
par |
A named vector containing all parameters that are supposed to be fitted. |
par.names |
The names of all parameters |
fit.fn |
The cost or optimisation function (see |
binary |
A vector containing zeroes and ones. Zero indicates that the corresponding parameter is not fitted. |
default.val |
A named list containing the values that the non-fitted parameters should take. If NULL, all non-fitted parameters will be set to zero. Default values can be either given by a numeric value or by the name of the corresponding parameter the value should be inherited from (NOTE: In this case the corresponding parameter entry has to contain a numeric value). Default to NULL. |
... |
Other arguments. |
Returns the value calculated by the user-supplied cost or optimisation function
#set parameters and cost function
fit.par <- c(p1 = 2, p2 = 4)
name.par <- c("p1", "p2", "p3")
defaults <- list(p1 = 0, p2 = 2, p3 = 4)
cost.function <- function(parms){
parms[1] + parms[2] + parms[3]
}
#call combine.and.fit
combine.and.fit(par = fit.par, par.names = name.par, fit.fn = cost.function)
combine.and.fit(par = fit.par, par.names = name.par, fit.fn = cost.function, default.val = defaults)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.