newton.raphson.root: A Newton Raphson root finder: finds x such that f(x) = 0

Description Usage Arguments Value References

View source: R/solve-irr.R

Description

The function newton.raphson.root is a general root finder which can find the zero of any function whose derivative is available. In this package, it is called by irr.solve and by GenBSImplied. It can be used in other situations as well - see the examples below.

Usage

1
2
3
4
5
6
7
8
9
newton.raphson.root(
  f,
  guess = 0,
  lower = -Inf,
  upper = Inf,
  max.iter = 100,
  toler = 1e-06,
  convergence = 1e-08
)

Arguments

f

The function whose zero is to be found. An R function object that takes one numeric argument and returns a list of two components (value and gradient). In an IRR application, these two components will be the NPV and the DV01/10000. In an implied volatility application, the components will be the option price and the vega. See also the examples below

guess

The starting value (guess) from which the solver starts searching for the IRR

lower

The lower end of the interval within which to search for the root

upper

The upper end of the interval within which to search for the root

max.iter

The maximum number of iterations of the Newton-Raphson procedure

toler

The criterion to determine whether a zero has been found. If the value of the function exceeds toler in absolute value, then NA is returned with a warning

convergence

The relative tolerance threshold used to determine whether the Newton-Raphson procedure has converged. The procedure terminates when the last step is less than convergence times the current estimate of the root. Convergence can take place to a non zero local minimum. This is checked using the toler criterion below

Value

The function returns NA under either of two conditions: (a) the procedure did not converge after max.iter iterations, or (b) the procedure converged but the function value is not zero within the limits of toler at this point. The second condition usually implies that the procedure has converged to a non zero local minimum from which there is no downhill gradient.

If the iterations converge to a genuine root (within the limits of toler), then it returns the root that was found.

References

The Newton Raphson solver was converted from C++ code in the Boost library


jrvFinance documentation built on Nov. 5, 2021, 5:07 p.m.