#' Parameter Estimator
#'
#' This function runs either find_first_value or find_later_value depending on whether a list of parameters is specified to find the value of a parameter for a function that gives a desired value.
#' @seealso \code{\link{find_later_value}} and \code{\link{find_first_value}}
#' @param f the function that is being used (note f should be a monotonic function for this function to work properly).
#' @param params a list of parameter values for all parameters that are specified in a function call prior to the desired parameter as well as any required parameters that do not have default values that occur after the desired parameter (if the desired parameter is the first parameter in the function call and all other required parameters have default values, this should not be defined).
#' @param val the desired value for the function.
#' @param maximum the maximum value for the search parameter (default = 100000).
#' @param minimum the minimum value for the search parameter (default = 0).
#' @param only_integers logical indicating whether the function only takes integers for the search parameter (default = F, allowing decimals).
#' @param decimals the number of decimal places to use for the search parameter.
#' @return A list will be returned containing the estimate for the desired parameter, the function value when the parameter estimate is used in f, and a warning if the parameter estimate results in a function value that is more than 1 away from val.
#' @export
#' @examples
#' find_value(log, val = 10, maximum = 1000000)
#' find_value(log, params = list(32), val = 2, decimals = 6)
find_value <- function(f, params, val = 0, maximum = 100000, minimum = 0, only_integers = F, decimals = 4){
if(missing(params)){
find_first_value(f = f, val = val, maximum = maximum, minimum = minimum, only_integers = only_integers, decimals = decimals)
} else{
find_later_value(f = f, params = params, val = val, maximum = maximum, minimum = minimum, only_integers = only_integers, decimals = decimals)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.