Learn R Programming

phenofit (version 0.2.0)

I_optim: Interface of unified optimization functions.

Description

Caution that optimx speed is not so satisfied. So I_optim is present.

Usage

I_optim(prior, FUN, y, t, tout, method = "BFGS", ...)

I_optimx(prior, FUN, y, t, tout, method, verbose = FALSE, ...)

Arguments

prior

A vector of initial values for the parameters for which optimal values are to be found. prior is suggested giving a column name.

FUN

Fine curve fitting function for goal function f_goal.

y

Numeric vector, vegetation index time-series

t

Numeric vector, Date variable

tout

Corresponding doy of prediction.

method

method can be one of 'BFGS','CG','Nelder-Mead', 'L-BFGS-B', 'nlm', 'nlminb', 'ucminf'. For I_optimx, other methods are also supported, e.g. 'spg','Rcgmin','Rvmmin', 'newuoa','bobyqa','nmkb','hjkb'.

...

other parameters passed to I_optim or I_optimx.

verbose

If TRUE, all optimization methods in optimx are used, and print optimization information of all methods.

Value

convcode

An integer code. 0 indicates successful convergence. Various methods may or may not return sufficient information to allow all the codes to be specified. An incomplete list of codes includes

1

indicates that the iteration limit maxit had been reached.

20

indicates that the initial set of parameters is inadmissible, that is, that the function cannot be computed or returns an infinite, NULL, or NA value.

21

indicates that an intermediate set of parameters is inadmissible.

10

indicates degeneracy of the Nelder--Mead simplex.

51

indicates a warning from the "L-BFGS-B" method; see component message for further details.

52

indicates an error from the "L-BFGS-B" method; see component message for further details.

9999

error

value

The value of fn corresponding to par

par

The best parameter found

nitns

the number of iterations

fevals

The number of calls to objective.

See Also

optim, nlminb, nlm, optimx, ucminf

Examples

Run this code
# NOT RUN {
library(ggplot2)
library(magrittr)
library(purrr)

# simulate vegetation time-series
fFUN = doubleLog.Beck
par = c(
  mn  = 0.1,
  mx  = 0.7,
  sos = 50,
  rsp = 0.1,
  eos = 250,
  rau = 0.1)
t    <- seq(1, 365, 8)
tout <- seq(1, 365, 1)
y <- fFUN(par, t)

# initial parameter
par0 <- c(
  mn  = 0.15,
  mx  = 0.65,
  sos = 100,
  rsp = 0.12,
  eos = 200,
  rau = 0.12)

objective <- f_goal # goal function
optFUNs   <- c("opt_ucminf", "opt_nlminb", "opt_nlm", "opt_optim") %>% set_names(., .)
prior <- as.matrix(par0) %>% t() %>% rbind(., .)

opt1 <- I_optim(prior, fFUN, y, t, tout, c("BFGS", "ucminf", "nlm", "nlminb"))
opt2 <- I_optimx(prior, fFUN, y, t, tout, c("BFGS", "ucminf", "nlm", "nlminb"))

# microbenchmark::microbenchmark(
#     I_optim(prior, fFUN, y, t, tout, c("BFGS", "ucminf", "nlm", "nlminb")),
#     I_optimx(prior, fFUN, y, t, tout, c("BFGS", "ucminf", "nlm", "nlminb")),
#     times = 2
# )
# }

Run the code above in your browser using DataLab