**BioStatMatt » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Dan Byrne of Vanderbilt University gave me a book back in October titled *The Automatic Millionaire* by David Bach. The book is an easy read and full of sound advice that I intend to take. Bach espouses a plan for retirement built on the principles of “paying yourself first” (*i.e.* before taxation, 401(k), 403(b)), making your plan automatic (*i.e.* automatic payroll deductions), and home ownership.

However, one of Bach’s arguments regarding home ownership has turned out to be incredibly bad. In chapter six: “Automatic Debt-free Home Ownership”, Bach argues

As U.S. housing prices climbed steadily throughout the late 1990s and early years of the twenty-first century, some people began to worry if we were experiencing a real estate “bubble,” similar to the unjustified run-up we saw with “dot-com” stocks. But homes are not stocks. … According to figures kept by the National Association of Realtors, there has never been a

nationalreal estate bubble.

Of course, Bach’s book was published in 2004, several years before the onset of the current U.S. real estate calamity. Even so, I don’t hold this against Bach or his book.

#### Amortization

Bach’s discussion of home ownership prompted me to delve into mortgage amortization, which is how lenders determine how large your payments will be, and how much will go towards interest versus principal (the loan balance). Wikipedia has a discussion on the mathematics of amortization.

I wrote a few `R` functions and a small S3 class to compute the minimum payments and amortization for a given loan amount, APR, and the loan length (in months). The amortization code may be found here: `amortize.R`

The minimum payment for a 30 year, $150k loan at 4.5% interest is computed as follows:

> source("http://biostatmatt.com/R/amortize.R") > loan <- 150000 > apr <- 4.5 > months <- 360 > pmt <- payment(loan, apr, months) > pmt [1] 760.028

The amortization class has a summary and plot method. Initialize the class and use its methods with something like:

> amrt <- amortize(loan, pmt, apr, months) > summary(amrt) loan amount: 150000 APR: 4.5 payment: 760.028 months: 360 interest paid: 123607.2 total paid: 273607.2 > plot(amrt)

The `plot` method produces something like:

where `balance` is the remaining balance of the loan, `interest` is the cumulative interest paid, `principal` is the cumulative principal paid, and `paid` is the total amount paid for the loan.

David Bach recommends making mortgage payments that are ten percent larger than the minimum. To see how this would affect the amortization:

> amrt <- amortize(loan, pmt * 1.1, apr, months) > plot(amrt)

Hence, by paying just ten percent more than the monthly minimum payment ($76), a borrower can pay this loan off five years earlier, and save more than $24k in interest payments.

**leave a comment**for the author, please follow the link and comment on their blog:

**BioStatMatt » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.