**Tags**

**Situation:**

A borrower wishes to borrow a loan today of principal amount “**P**” at a monthly interest rate of “**i**“. The loan is to be paid back in “**n**” monthly installments of “**M**” each, which begins one month from the date of disbursement of loan. We need to calculate the monthly instalment “**M**“.

In this above problem, actually we need to calculate present value of the future **n** monthly payments of **M**, which is as follows:

or

This geometric equation can be simplified to the following form:

This formula above is used to calculate the present value of an annuity.

If we know “P”, “i” and “n” then we can calculate value of “M” easily from the rearrangement of the formula above:

To perform the calculations in package R, we first have to define the variables. Let us assume that the principal borrowed (loan amount, P) be $10,000, the interest, “i”, is 2% per annum and the repayment term, “n”, is 24 months. Then the variables will be defined in R as:

**> P.borrowed = 10000 #Defining variable for principal**

**> L.intt = 0.02 #Defining variable for loan interest**

**> N.period = 24 #Defining variable for loan period terms (24 months)**

We then define a formula (variable) in R for monthly instalment M

**> M.instalment = (P.borrowed * L.intt) / (1 – (1 + L.intt)^(-N.period))**

This should produce a result like this:

**> M.instalment**

**[1] 528.711**

So the borrower will have to pay $528.711 in monthly instalment for 24 months against her loan.