#' @title quantile_optim #' #' @description This function plots the quantiles #' @param Lfor List of the data needed to plot #' @export #' @examples #' plotprob() quantile_optim <- function(model, data){ # Take the parameters bounds from the parameter bounds set in the model init <- model$get_prmbounds("init") lower <- model$get_prmbounds("lower") upper <- model$get_prmbounds("upper") # If bounds are NA, then set if(any(is.na(lower))){ lower[is.na(lower)] <- -Inf} if(any(is.na(upper))){ lower[is.na(upper)] <- Inf} resList <- list() for(i in (1:length(model$tau))){ cat("Quantile, tau: ", model$tau[i], "\n") resList[[i]] <- optim(par = init, fn = quantile_fit, # Parameters to pass to quantile_fit model = model, q = model$tau[i], data = data, returnanalysis = FALSE, # Parameters to pass to optim lower = lower, upper = upper, method = "L-BFGS-B") } #model$optPar <- sapply(1:length(model$tau), function(q) return(resList[[i]]$par)) return(resList) }