optim_pheno: optim_pheno

View source: R/optim_pheno.R

optim_phenoR Documentation

optim_pheno

Description

Interface of optimization functions for double logistics and other parametric curve fitting functions.

Usage

optim_pheno(
  prior,
  sFUN,
  y,
  t,
  tout,
  method,
  w,
  nptperyear,
  ylu,
  iters = 2,
  wFUN = wTSM,
  lower = -Inf,
  upper = Inf,
  constrain = TRUE,
  verbose = FALSE,
  ...,
  use.cpp = 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.

sFUN

The name of fine curve fitting functions, can be one of 'FitAG', 'FitDL.Beck', 'FitDL.Elmore', 'FitDL.Gu' and 'FitDL.Klos', 'FitDL.Zhang'.

y

Numeric vector, vegetation index time-series

t

Numeric vector, Date variable

tout

Corresponding doy of prediction.

method

The name of optimization method to solve fine fitting, one of 'BFGS','CG','Nelder-Mead', 'L-BFGS-B', 'nlm', 'nlminb', 'ucminf' and 'spg','Rcgmin','Rvmmin', 'newuoa','bobyqa','nmkb','hjkb'.

w

(optional) Numeric vector, weights of y. If not specified, weights of all NA values will be wmin, the others will be 1.0.

nptperyear

Integer, number of images per year, passed to wFUN. Only wTSM() needs nptperyear. If not specified, nptperyear will be calculated based on t.

ylu

[ymin, ymax], which is used to force ypred in the range of ylu.

iters

How many times curve fitting is implemented.

wFUN

weights updating function, can be one of 'wTSM', 'wChen' and 'wBisquare'.

lower, upper

vectors of lower and upper bounds, replicated to be as long as start. If unspecified, all parameters are assumed to be unconstrained.

constrain

boolean, whether to use parameter constrain

verbose

Whether to display intermediate variables?

...

other parameters passed to I_optim() or I_optimx().

use.cpp

(unstable, not used) boolean, whether to use c++ defined fine fitting function? If FALSE, R version will be used.

Value

A fFIT() object, with the element of:

  • tout: The time of output curve fitting time-series.

  • zs : Smoothed vegetation time-series of every iteration.

  • ws : Weights of every iteration.

  • par : Final optimized parameter of fine fitting.

  • fun : The name of fine fitting.

See Also

fFIT(), stats::nlminb()

Examples

# library(magrittr)
# library(purrr)

# simulate vegetation time-series
t    <- seq(1, 365, 8)
tout <- seq(1, 365, 1)

FUN = doubleLog_Beck
par  = c( mn  = 0.1 , mx  = 0.7 , sos = 50 , rsp = 0.1 , eos = 250, rau = 0.1)
par0 = c( mn  = 0.15, mx  = 0.65, sos = 100, rsp = 0.12, eos = 200, rau = 0.12)

y <- FUN(par, t)

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

sFUN   = "doubleLog.Beck" # doubleLog.Beck
r <- optim_pheno(par0, sFUN, y, t, tout, method = methods[4],
                 nptperyear = 46, iters = 2, wFUN = wTSM, verbose = FALSE, use.julia = FALSE)

phenofit documentation built on Feb. 16, 2023, 6:21 p.m.