function calculateAffordability() {
// 1. Get Inputs
var annualIncome = parseFloat(document.getElementById('macAnnualIncome').value) || 0;
var monthlyDebt = parseFloat(document.getElementById('macMonthlyDebt').value) || 0;
var downPayment = parseFloat(document.getElementById('macDownPayment').value) || 0;
var interestRate = parseFloat(document.getElementById('macInterestRate').value) || 0;
var loanTerm = parseFloat(document.getElementById('macLoanTerm').value) || 30;
var propertyTaxAnnual = parseFloat(document.getElementById('macPropertyTax').value) || 0;
var homeInsuranceAnnual = parseFloat(document.getElementById('macHomeInsurance').value) || 0;
var hoaMonthly = parseFloat(document.getElementById('macHoaFees').value) || 0;
// 2. Constants for DTI (Conventional 28/36 Rule)
var frontEndRatio = 0.28;
var backEndRatio = 0.36;
// 3. Calculate Monthly Income
var monthlyIncome = annualIncome / 12;
if (monthlyIncome <= 0) {
alert("Please enter a valid annual income.");
return;
}
// 4. Calculate Max Payment based on Ratios
// Limit 1: Housing costs shouldn't exceed 28% of gross income
var maxHousingPaymentFront = monthlyIncome * frontEndRatio;
// Limit 2: Total debt (housing + other debts) shouldn't exceed 36% of gross income
var maxTotalDebtPayment = monthlyIncome * backEndRatio;
var maxHousingPaymentBack = maxTotalDebtPayment – monthlyDebt;
// The affordability is constrained by the lower of the two limits
var maxTotalMonthlyPayment = Math.min(maxHousingPaymentFront, maxHousingPaymentBack);
// 5. Subtract Non-Mortgage Housing Costs (Taxes, Insurance, HOA) to find max P&I
var monthlyTax = propertyTaxAnnual / 12;
var monthlyInsurance = homeInsuranceAnnual / 12;
var nonMortgageCosts = monthlyTax + monthlyInsurance + hoaMonthly;
var maxPrincipalAndInterest = maxTotalMonthlyPayment – nonMortgageCosts;
// 6. Handle edge case where debts/expenses are too high
if (maxPrincipalAndInterest <= 0) {
document.getElementById('macResults').style.display = 'block';
document.getElementById('macResultPrice').innerText = "$" + downPayment.toLocaleString();
document.getElementById('macResultPayment').innerText = "$0";
document.getElementById('macResultLoan').innerText = "$0";
document.getElementById('macResultDti').innerText = "N/A (Debts too high)";
return;
}
// 7. Calculate Max Loan Amount using Amortization Formula
// P = (M * (1 – (1+r)^-n)) / r
var monthlyRate = (interestRate / 100) / 12;
var numPayments = loanTerm * 12;
var maxLoanAmount = 0;
if (interestRate === 0) {
maxLoanAmount = maxPrincipalAndInterest * numPayments;
} else {
// Formula: Loan = P&I * (1 – (1+r)^-n) / r
maxLoanAmount = maxPrincipalAndInterest * (1 – Math.pow(1 + monthlyRate, -numPayments)) / monthlyRate;
}
// 8. Calculate Max Home Price
var maxHomePrice = maxLoanAmount + downPayment;
// 9. Display Results
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
maximumFractionDigits: 0
});
document.getElementById('macResults').style.display = 'block';
document.getElementById('macResultPrice').innerText = formatter.format(maxHomePrice);
document.getElementById('macResultPayment').innerText = formatter.format(maxTotalMonthlyPayment);
document.getElementById('macResultLoan').innerText = formatter.format(maxLoanAmount);
// Determine which ratio was the limiting factor
var limitingRatioText = (maxHousingPaymentFront < maxHousingPaymentBack) ? "28% (Front-End)" : "36% (Back-End)";
document.getElementById('macResultDti').innerText = limitingRatioText;
}
How Much House Can I Afford?
Determining "how much house can I afford" is the first critical step in the home buying process. This Mortgage Affordability Calculator uses the industry-standard 28/36 rule to estimate a realistic budget based on your income, debts, and down payment. Unlike simple payment estimators, this tool works backward from your financial limits to find the maximum property price you can handle without financial stress.
Understanding the Calculation Logic
Lenders look at two specific Debt-to-Income (DTI) ratios to decide how much money to lend you:
Front-End Ratio (28%): This rule states that your total monthly housing costs (principal, interest, taxes, insurance, and HOA fees) should not exceed 28% of your gross monthly income.
Back-End Ratio (36%): This rule states that your total monthly debt payments (housing costs PLUS credit cards, student loans, car loans, etc.) should not exceed 36% of your gross monthly income.
Our calculator computes both limits and uses the lower of the two to ensure you remain within a safe financial zone.
Factors That Impact Your Affordability
Several variables can drastically change your buying power:
Interest Rates: Even a small increase in interest rates can reduce your purchasing power by tens of thousands of dollars, as more of your monthly payment goes toward interest rather than principal.
Monthly Debts: High monthly obligations (like an expensive car payment) directly reduce the amount available for a mortgage, impacting your "Back-End" ratio.
Down Payment: A larger down payment not only reduces the loan amount but may also remove the need for Private Mortgage Insurance (PMI), freeing up monthly cash flow for a more expensive home.
Property Taxes & HOA: Don't forget that high property taxes or Homeowners Association fees count against your monthly limit. A cheaper house with high HOA fees might be less affordable than a slightly more expensive house with no fees.
Example Scenario
If you earn $85,000 annually and have $500 in monthly debts, the bank calculates your monthly gross income as roughly $7,083.
28% Limit: $1,983 max for housing.
36% Limit: $2,550 total debt allowance. Minus your $500 debt, that leaves $2,050 for housing.
In this case, the calculator would cap your housing payment at $1,983 (the lower limit). After deducting estimates for taxes and insurance, the remaining amount determines how large of a loan you can support.