## Posts Tagged ‘**2016-17**’

## [WP] Shiny for Finance

For those familiar with R, Shiny offers a great alternative to spreadsheets. Targeted at instructors, we have a new paper introducing Shiny for finance applications in the classroom. Here is a longish abstract:

Despite the popularity of open-source languages like R and Python in modern empirical research and the data-science industry, spreadsheet programs like Microsoft Excel remain the data analysis software of choice in much of the business-school curriculum, including at IIMA. Even if instructors are comfortable with modern programming languages, they have to pitch their courses at the level of computer literacy prevalent among students. Excel then appears to be a natural choice given its popularity, but this choice constrains the depth of analysis that is possible and requires a certain amount of dumbing-down of the subject by the instructor. Recent software advances however make the ubiquitous web browser a worthy challenger to the spreadsheet. This article introduces one such browser-based tool called Shiny for bringing finance applications to the classroom and smart phones. Fueled by the availability of high-quality R packages in finance and statistics, Shiny brings together the power of HTML with the R programming language. It naturally creates an environment for the instructor to focus on the role of parameters and assumptions in analysis without the clutter of data, and allows the instructor to go beyond the toy problems that are necessitated by the nature of spreadsheets. The learning curve is short for an interested instructor with even a rudimentary exposure to programming in any language. The article ends with the discussion of a fully-worked out example of Shiny for teaching the mean variance efficient frontier in a basic investments course.

The working paper is here. It needs a bit of fine tuning yet, but comments welcome.

## [PGP-I FM] Time Value of Money

Chapter 2 of your book has a decent enough description of the mechanics of time value of money, so I won’t spend too much time on this post motivating and explaining it. If you understand the Present Value Rule, then finding the time value of money of future certain cash flow boils down to just simply summing simple geometric progressions (GP). That brings us to the first tip of the day:

*Tip 1: *When finding time value of money, more often than not you should be able to reduce it to a mathematical problem of valuing finite GPs. *Use it!*

For this post then I’ll just summarize the math and the main results.

…

**Discount Factors**

I include Discount Factors here only to set the notation for this post. There is nothing new here. Given an annual discount rate the Discount Factor (with annual compounding) is given as:

(For much of this post, annual compounding is assumed.)

…

**Perpetuities**

A perpetuity () is an endless stream of cash flows () starting at the end of the year (e.g. Consols). Assuming constant interest rates, mathematically it means summing up the following infinite GP:

If the problem at hand warrants assuming constant cash flows, i.e. if this simplifies to:

Perpetuities are not so important as financial instruments, but the formula/derivation for as above is immensely useful in simplifying calculation of PVs of annuities, as we’ll see below.

…

**Annuities**

An annuity () for a term is a finite stream of cash flows () starting at the end of the year . Annuities can be interpreted both as payments to be made (EMIs, regular savings from your salary, recurring deposits) as well as payments to be received (coupon payments from a bond). Mathematically, of course, it’s just summing up the following finite GP:

First of all notice that we can write an annuity as a function of the discount factors as:

So, if we consider all cash flows , then we have the Annuity Factor for term as:

*Tip 2:* If you have manageable number of terms (say, less than 4-5) in a situation, and you’ve already calculated some of the already as part of the problem, then use the discount factor way to find the PV of the annuity. It’ll not only be easier (i.e. you’ll perhaps make less mistakes) but also save time. Otherwise, use the formula in the textbook/as we derive below.

Just like for perpetuities, if the problem at hand warrants assuming constant cash flows, i.e. if this simplifies to:

*Tip 3: *Now one way to sum it up is to use the formula for summing finite GPs, but that’s messy – and it will only get worse when you have an annuity which is growing/falling. We exploit our derivation for perpetuity here. Write:

where we have just added and subtracted a term going to perpetuity. Write:

Clearly is:

That is, we can simplify as:

Notice how we have used the the’perpetuity to our advantage to convert our original annuity into perpetuity and then subtracted back .

We have now the final result for :

…

**Growing Annuities**

If we have a growing annuities (either upwards or downwards), then our expression changes to:

If we take out the factor from the above equation we end up with a finite GP again, but with a different common ratio – in this case .

Repeat the same steps as earlier (write again as a difference of two perpetuities – only the common ratio is different) and we end up with a similar result for growing annuities. Let’s outline the proof:

Again, we can similarly define and , and go through exactly the same steps to show that:

And we end up with final result as:

Note that there is nothing in the above formula that prevents from being negative. can very well be less than 0 – that would be the case where our future cash-flows are going down in a systematic manner.

…

**Some other Things to Remember**

1. When there is only a single unit cash flow (i.e. ) in the future, the following relationships hold:

2. For an annuity with constant cash flow every year we can talk about an Annuity Factor () as:

3. In general, one may think of PV of a unit sum of cash flow years later with compounding times a year as the following general expression:

And accordingly, the general expression for an annuity with a unit sum received times a year becomes:

…

**The Inflation Problem**

This is with reference to a couple of problems around inflation in the textbook. The inflation problem is just an application of the idea of a growing annuity. In presence of inflation, for your consumption to remain the same in ‘real’/quantity terms, annual cash-flows must grow at a rate commensurate with the inflation rate – i.e. the cash-flows must grow that match the inflation rate.

The only difference is that, because our typical annuity starts at the end of the year, unlike the earlier case of a growing annuity, our first annuity payment in this case would also be higher by a rate equivalent to the inflation rate.

So, if the inflation rate is known (that is, we know it’s going to remain the same for the entire horizon), then the expression for this annuity will be:

So, in this case we can factor out and we are again left with a GP with a common ratio . Nothing else changes.

And if we now write

then we can rewrite as:

which is just a normal annuity, but with a different discount rate . And what is this discount rate ? Think of it as the ‘real’ interest rate that applies in the presence of inflation. That is, in presence of inflation our effective discount rate goes down (why?).

The inflation problem is just an application of the idea of a growing annuity. In presence of inflation, for your consumption to remain the same in ‘real’/quantity terms, annual cash-flows must grow at a rate commensurate with the inflation rate – i.e. the cash-flows must grow that match the inflation rate.

The only difference is that, because our typical annuity starts at the end of the year, unlike the earlier textbook case of a growing annuity, our first annuity payment in this case would also be higher by a rate equivalent to the inflation rate.

So, if the inflation rate is known (that is, we know it’s going to remain the same for the entire horizon), then the expression for this annuity will be:

So, in this case we can factor out and we are again left with a GP with a common ratio . Nothing else changes.

And if we now write

then we can rewrite as:

which is just a normal annuity, but with a different discount rate . And what is this discount rate ? Think of it as the ‘real’ interest rate that applies in the presence of inflation. That is, in presence of inflation our effective discount rate goes down (why?).

…

**One Last Tip**

When all else fails, use* ab initio*. For any cash flow that you are supposed to value list down the ‘time-axis’ on the first row (), and below that list down all cash flows (with their right sign) of a kind (cash flow from each activity/operation on a separate line/row. This would make sure you’re counting each cash flow at the ‘right’ time (and not more than once). Now just bring back all of them to separately time and sum them up. And you are done.

Variations on the time value of money problems are situations when one knows the PV (your car/home loan for example), and you have to do some algebra/arithmetic to find some regular cash flow (your EMI). At others times when you know the cash flows and you may have to find the PV. (*Always* try and do the algebra first and then plug in the numbers as a last step – more often than not algebra helps simiplify the final expression and reduce possibility of silly mistakes. Though, of course, this may all be moot, as these days you’ll be probably using some software like Excel to do the job for you. Doesn’t hurt to know the principles though.)

…

It is an urban legend that Albert Einstein said that compound interest is the most powerful force in the universe – the Indians perhaps didn’t think through it!

## [WP] Open access temptations

Information science isn’t exactly my area of research, but it has been fun exploring the shady side of open access. Here is the abstract:

Backlash against “megapublishers” which began in mathematics a decade ago has led to an exponential growth in open access journals. Their increasing numbers and popularity notwithstanding, there is evidence that not all open access journals are legitimate. The nature of the “gold open access” business model and increasing prevalence of “publish or perish” culture in academia has given rise to a dark under-belly in the world of scientific publishing which feeds off academics’ professional needs. Many such “predatory” publishers and journals not only seem to originate out of India but also seem to have been patronized by academics in the country. This article is a cautionary note to early-career academics and administrators in India to be wary of this “wild west” of the internet and exercise due discretion when considering/evaluating open-access journals for scholarly contributions.

The working paper is here.