rgn {RGN} | R Documentation |
Robust Gauss Newton optimization
Description
rgn
performs optimization of weighted-sum-of-squares (WSS) objective function using the Robust Gauss Newton algorithm
Usage
rgn(
simFunc,
simTarget = 0,
weights = NULL,
par,
lower,
upper,
control = NULL,
...
)
Arguments
simFunc |
is a function that simulates a (vector) response, with first argument the vector of parameters over which optimization is performed |
simTarget |
is the target vector that |
weights |
is a vector of weights used in the WSS objective function. Defaults to equal weights. |
par |
is the vector of initial parameters |
lower |
is the lower bounds on parameters |
upper |
is the upper bounds on parameters |
control |
list of RGN settings
|
... |
other arguments to |
Details
rgn
minimizes the objective function sum((weights*(simFunc-simTarget)^2))
,
which is a sum of squared weighted residuals (residuals=weights*(simFunc-simTarget)
).
Note simFunc
corresponds to the vector of residuals when default
arguments for simTarget
and weights
are used.
Value
List with
par
, the optimal parametersvalue
, the optimal objective function valuesim
, the simulated vector using optimal parametersresiduals
, the vector of residuals using optimal parameterscounts
, the total number of function callsconvergence
, an integer code indicating reason for completion.1
maximum iterations reached,2
relative reduction in function value small.3
absolute reduction in function value small4
relative change in parameters small
Examples
# Example 1: Rosenbrock
simFunc_rosenbrock=function(x) c(1.0-x[1],10.0*(x[2]-x[1]**2))
rgnOut = rgn(simFunc=simFunc_rosenbrock,
par=c(-1.0, 0.0), lower=c(-1.5, -1.0), upper=c( 1.5, 3.0),
simTarget=c(0,0))
rgnOut$par #optimal parameters
rgnOut$value #optimal objective function value
# Example 2: Hymod
data("BassRiver") # load Bass River hydrological data
rgnOut = rgn(simFunc=simFunc_hymod,
par=c(400.,0.5,0.1,0.2,0.1),
lower=c(1.,0.1,0.05,0.000001,0.000001),
upper=c(1000.,2.,0.95,0.99999,0.99999),
simTarget=BassRiverData$Runoff.mm.day[365:length(BassRiverData$Date)],
stateVal=c(100.0,30.0,27.0,25.0,30.0,0.0,0.0,0.0), # initial states for hymod
nWarmUp=365, # warmup period
rain=BassRiverData$Rain.mm, # precip input
pet=BassRiverData$ET.mm) # PET input
rgnOut$par #optimal parameters
rgnOut$value #optimal objective function value