I have function of loss given for a k-elements vector by the following formula:
Where p is a positive parameter. I have to write a function in R which returns the value of u which minimizes this function. How can I do that?
first define the function you want to minimize:
my_function <- function(u) {
...
}
Then you can call the optim()
function:
result <- optim(starting_point_for_u, my_function, ...)
# parameter value minimizing the function
result$par
# minimal value of function
result$value