R: An R implementation of a bounded nonlinear conjugate gradient...

Rcgminb {Rcgmin} | R Documentation

## An R implementation of a bounded nonlinear conjugate gradient algorithm with the Dai / Yuan update and restart. Based on Nash (1979) Algorithm 22 for its main structure. CALL THIS VIA `Rcgmin` AND DO NOT USE DIRECTLY.

### Description

The purpose of `Rcgminb` is to minimize a bounds (box) and mask constrained function of many parameters by a nonlinear conjugate gradients method. This code is entirely in R to allow users to explore and understand the method. It allows bounds (or box) constraints and masks (equality constraints) to be imposed on parameters.

This code should be called through `Rcgmin` which selects `Rcgminb` or `Rcgminu` according to the presence of bounds and masks.

### Usage

       Rcgminb(par, fn, gr, lower, upper, bdmsk, control = list(), ...)

### Arguments

`par` | A numeric vector of starting estimates.
`fn` | A function that returns the value of the objective at the supplied set of parameters `par` using auxiliary data in .... The first argument of `fn` must be `par`.
`gr` | A function that returns the gradient of the objective at the supplied set of parameters `par` using auxiliary data in .... The first argument of `fn` must be `par`. This function returns the gradient as a numeric vector. The use of numerical gradients for Rcgminb is STRONGLY discouraged.
`lower` | A vector of lower bounds on the parameters.
`upper` | A vector of upper bounds on the parameters.
`bdmsk` | An indicator vector, having 1 for each parameter that is "free" or unconstrained, and 0 for any parameter that is fixed or MASKED for the duration of the optimization.
`control` | An optional list of control settings.
`...` | Further arguments to be passed to `fn`.

### Details

Functions `fn` must return a numeric value.

The `control` argument is a list.

maxit

  A limit on the number of iterations (default 500). Note that this is used to compute a quantity `maxfeval`<-round(sqrt(n+1)*maxit) where n is the number of parameters to be minimized.

trace

  Set 0 (default) for no output, >0 for trace output (larger values imply more output).

eps

  Tolerance used to calculate numerical gradients. Default is 1.0E-7. See source code for `Rcgminb` for details of application.

`dowarn`

  = TRUE if we want warnings generated by optimx. Default is TRUE.

  The source code `Rcgminb` for R is likely to remain a work in progress for some time, so users should watch the console output.

As of 2011-11-21 the following controls have been REMOVED

usenumDeriv

  There is now a choice of numerical gradient routines. See argument `gr`.

maximize

  To maximize user_function, supply a function that computes (-1)*user_function. An alternative is to call Rcgmin via the package optimx.

### Value

A list with components:

`par` | The best set of parameters found.
`value` | The value of the objective at the best set of parameters found.
`counts` | A two-element integer vector giving the number of calls to 'fn' and 'gr' respectively. This excludes those calls needed to compute the Hessian, if requested, and any calls to 'fn' to compute a finite-difference approximation to the gradient.
`convergence` | An integer code. '0' indicates successful convergence. '1' indicates that the function evaluation count 'maxfeval' was reached. '2' indicates initial point is infeasible.
`message` | A character string giving any additional information returned by the optimizer, or 'NULL'.
`bdmsk` | Returned index describing the status of bounds and masks at the proposed solution. Parameters for which bdmsk are 1 are unconstrained or "free", those with bdmsk 0 are masked i.e., fixed. For historical reasons, we indicate a parameter is at a lower bound using -3 or upper bound using -1.

### References

See `Rcgmin` documentation. Note that bounds and masks were adapted from the work by Nash and Walker-Smith(1987).

### See Also

`optim`

[Package Rcgmin version 2013-2.21 Index]