Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#' @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 = Dnew,
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)
}