Optimization Objective Function
objectiveFn.RdThis function returns the optimization objective function from a ‘maxim’ object.
Value
function, the function that was optimized. It can be directly called, given that all necessary variables are accessible from the current environment.
Examples
hatf <- function(theta) exp(- theta %*% theta)
res <- maxNR(hatf, start=c(0,0))
print(summary(res))
#> --------------------------------------------
#> Newton-Raphson maximisation
#> Number of iterations: 1
#> Return code: 1
#> gradient close to zero (gradtol)
#> Function value: 1
#> Estimates:
#> estimate gradient
#> [1,] 0 0
#> [2,] 0 0
#> --------------------------------------------
print(objectiveFn(res))
#> function (theta)
#> exp(-theta %*% theta)
#> <environment: 0x5ff9118a2140>
print(objectiveFn(res)(2)) # 0.01832
#> [,1]
#> [1,] 0.01831564