Summarize an "opm" object.

# S3 method for class 'opm'
coef(object, ...) 
  # S3 method for class 'opm'
coef(x) <- value

Arguments

object

Object returned by opm.

...

Further arguments to be passed to the function. Currently not used.

x

An opm object.

value

Set parameters equal to this value.

Value

coef.opm returns the best parameters found by each method that returned such parameters. The returned coefficients are in the form of a matrix with the rows named by the relevant methods and the columns named according to parameter names provided by the user in the vector of starting values, or else by "p1", "p2", ..., if names are not provided.

Examples

ans <- opm(fn = function(x) sum(x*x), par = 1:2, method="ALL", control=list(trace=0))
#> Warning: 'snewtonm' removed from 'method' -- no hess()
#> Warning: 'snewtm' removed from 'method' -- no hess()
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
#> Warning: optimr: par is NOT a vector of type double -- coercing
print(coef(ans))
#>                         p1            p2
#> BFGS          2.228468e-13 -1.109715e-13
#> CG           -4.103643e-07 -8.207287e-07
#> Nelder-Mead   1.274686e-04  1.447624e-04
#> L-BFGS-B      7.623310e-21 -3.515189e-20
#> nlm          -3.557703e-17  1.766256e-17
#> nlminb        2.953466e-31  9.870427e-31
#> lbfgsb3c     -1.120823e-21  7.669515e-23
#> Rcgmin                  NA            NA
#> Rtnmin                  NA            NA
#> Rvmmin                  NA            NA
#> spg          -5.240253e-08 -5.595524e-08
#> ucminf       -4.356895e-09 -5.256497e-09
#> newuoa        7.801992e-10 -5.695938e-10
#> bobyqa        7.363567e-09 -1.783518e-08
#> nmkb          6.289555e-04  3.953361e-04
#> hjkb          0.000000e+00  0.000000e+00
#> hjn           0.000000e+00  0.000000e+00
#> lbfgs                   NA            NA
#> subplex       2.818926e-17 -1.084202e-18
#> ncg                     NA            NA
#> nvm                     NA            NA
#> mla           2.881892e-09  5.763706e-09
#> slsqp         4.079614e-22  8.487978e-23
#> tnewt         1.177625e-11 -1.311573e-11
#> anms         -1.817331e-11 -7.873408e-11
#> pracmanm      4.526869e-14  1.940071e-15
#> nlnm        -4.940656e-324  0.000000e+00

ansx <- optimx(fn = function(x) sum(x*x), par = 1:2, control=list(all.methods=TRUE, trace=0))
print(coef(ansx))
#>                        p1            p2
#> BFGS         2.228468e-13 -1.109715e-13
#> CG          -4.103643e-07 -8.207287e-07
#> Nelder-Mead  1.274686e-04  1.447624e-04
#> L-BFGS-B     7.623310e-21 -3.515189e-20
#> nlm         -3.557703e-17  1.766256e-17
#> nlminb       2.953466e-31  9.870427e-31
#> spg         -5.240253e-08 -5.595524e-08
#> ucminf      -4.356895e-09 -5.256497e-09
#> Rcgmin       2.799706e-13  1.059251e-12
#> Rvmmin      -5.000027e-13 -5.000062e-13
#> newuoa      -6.046324e-10 -3.113271e-10
#> bobyqa       7.363567e-09 -1.783518e-08
#> nmkb         6.289555e-04  3.953361e-04
#> hjkb         0.000000e+00  0.000000e+00


if (FALSE) { # \dontrun{
proj <- function(x) x/sum(x)
f <- function(x) -prod(proj(x))
ans <- opm(1:2, f)
print(ans)
coef(ans) <- apply(coef(ans), 1, proj)
print(ans)
} # }