Modified Internal Rate of Return (MIRR) Calculator
The Modified Internal Rate of Return (MIRR) is a financial metric used to evaluate the profitability of an investment or project. Unlike the traditional Internal Rate of Return (IRR), MIRR addresses some of IRR's limitations, particularly its assumption that intermediate cash flows are reinvested at the project's IRR. MIRR accounts for the cost of capital and the reinvestment rate of positive cash flows, providing a more realistic measure of a project's true return.
The formula for MIRR is:
MIRR = [ (FV of positive cash flows / PV of negative cash flows) ^ (1 / number of periods) ] – 1
Where:
- FV of positive cash flows: The future value of all positive cash inflows, compounded at the reinvestment rate.
- PV of negative cash flows: The present value of all negative cash outflows, discounted at the cost of capital.
- Number of periods: The total number of periods for the project.
var periodCount = 3; // Start with 3 periods
function addCashFlowInput() {
periodCount++;
var newEntry = document.createElement('div');
newEntry.className = 'cash-flow-entry';
newEntry.innerHTML = '
' +
";
document.getElementById('cashFlowEntries').appendChild(newEntry);
}
function calculateMIRR() {
var initialInvestment = parseFloat(document.getElementById('initialInvestment').value);
var reinvestmentRate = parseFloat(document.getElementById('reinvestmentRate').value) / 100;
var costOfCapital = parseFloat(document.getElementById('costOfCapital').value) / 100;
var cashFlowInputs = document.getElementsByClassName('cashFlow');
var totalPeriods = cashFlowInputs.length;
var positiveCashFlowsFV = 0;
var negativeCashFlowsPV = 0;
// Validate initial investment
if (isNaN(initialInvestment) || initialInvestment <= 0) {
document.getElementById('result').innerText = 'Error: Please enter a valid initial investment (greater than 0).';
return;
}
// Validate reinvestment and cost of capital rates
if (isNaN(reinvestmentRate) || reinvestmentRate < 0) {
document.getElementById('result').innerText = 'Error: Please enter a valid reinvestment rate (0% or greater).';
return;
}
if (isNaN(costOfCapital) || costOfCapital < 0) {
document.getElementById('result').innerText = 'Error: Please enter a valid cost of capital (0% or greater).';
return;
}
// Calculate FV of positive cash flows and PV of negative cash flows
for (var i = 0; i 0) {
// Future value of positive cash flows
positiveCashFlowsFV += cashFlow * Math.pow(1 + reinvestmentRate, totalPeriods – i);
} else if (cashFlow < 0) {
// Present value of negative cash flows
negativeCashFlowsPV += cashFlow / Math.pow(1 + costOfCapital, i + 1);
}
}
// Ensure there are actual negative cash flows to discount
if (negativeCashFlowsPV === 0) {
// If there are no explicit negative cash flows in the series (only initial investment),
// we need to consider the initial investment as a negative cash flow at period 0.
negativeCashFlowsPV = -initialInvestment;
} else {
// Add the initial investment as a negative cash flow at period 0, discounted by cost of capital
negativeCashFlowsPV -= initialInvestment;
}
// Ensure FV of positive cash flows and PV of negative cash flows are valid for calculation
if (positiveCashFlowsFV = 0) {
document.getElementById('result').innerText = 'Error: Insufficient or invalid cash flows for MIRR calculation. Ensure there are positive cash flows to compound and valid negative cash flows to discount.';
return;
}
var mirr = Math.pow(Math.abs(positiveCashFlowsFV / negativeCashFlowsPV), 1 / totalPeriods) – 1;
document.getElementById('result').innerText = 'MIRR: ' + (mirr * 100).toFixed(2) + '%';
}