irr.solve {jrvFinance}R Documentation

Solve for IRR (internal rate of return) or YTM (yield to maturity)

Description

This function computes the internal rate of return at which the net present value equals zero. It requires as input a function that computes the net present value of a series of cash flows for a given interest rate as well as the derivative of the NPV with respect to the interest rate (10,000 times this derivative is the PVBP or DV01). In this package, irr.solve is primarily intended to be called by the irr and bond.yield functions. It is made available for those who want to find IRR of more complex instruments.

Usage

irr.solve(
  f,
  interval = NULL,
  r.guess = NULL,
  toler = 1e-06,
  convergence = 1e-08,
  max.iter = 100,
  method = c("default", "newton", "bisection")
)

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 the IRR applications, these two components will be the NPV and its derivative

interval

The interval c(lower, upper) within which to search for the IRR

r.guess

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

toler

The argument toler to newton.raphson.root. The IRR is regarded as correct if abs(NPV) is less than toler. Otherwise the irr.solve returns NA

convergence

The argument convergence to newton.raphson.root.

max.iter

The maximum number of iterations of the Newton-Raphson procedure

method

The root finding method to be used. The default is to try Newton-Raphson method (newton.raphson.root) and if that fails to try bisection (bisection.root). The other two choices (newton and bisection force only one of the methods to be tried.

Details

The function irr.solve is basically an interface to the general root finder newton.raphson.root. However, if newton.raphson.root fails, irr.solve makes an attempt to find the root using uniroot from the R stats package. Uniroot uses bisection and it requires the root to be bracketed (the function must be of opposite sign at the two end points - lower and upper).

Value

The function irr.solve returns NA if the IRR/YTM could not be found. Otherwise it returns the IRR/YTM. When NA is returned, a warning message is printed

Author(s)

Prof. Jayanth R. Varma jrvarma@iima.ac.in


[Package jrvFinance version 1.4.3 Index]