After some testing, I am comfortable with this implementation of IRR()
in R:
https://stat.ethz.ch/pipermail/r-help/2008-August/169619.html
Here it is in the form of a script runnable via the Rscript command:
args <- commandArgs(TRUE)
periods = as.numeric(args[1])
payment = as.numeric(args[2])
value = as.numeric(args[3])
monthsInYear = 12
timeline <- (0:periods)
payments <- payment + (0 * timeline)
payments[1] <- value
f <- function(r) sum(payments * exp(-r * timeline))
irr <- function(f) uniroot(f, c(0, 1))$root
irr(f) * monthsInYear