Sunday, May 7, 2017

Correlations among the Fraser family members using R

So I've been fiddling around with R over the weekends. R is both the name of a programming language and an open-source software which is used for statistical computing. I'm using R in the workplace and it comes equipped with a full suite of packages for various kinds of data manipulation/analysis/etc.

Not too long ago, I wondered whether could R be used for investing-related purposes. True enough, there was a package known as quantmod which would be a treasure trove for traders. After some fiddling around, what I liked about quantmod is its ease in importing data from various financial sources (e.g. yahoo finance, google finance, etc) into R itself.

As I'm currently vested in some of the Fraser family members, I thought to myself how fun it would be if I could create a function in R that will be able to tell me how correlated the Fraser family members are.

Before proceeding further, there are some assumptions I have made. First, I've set the time period from 1 January 2016 to 31 December 2016. Second, I did not include Frasers Logistics & Industrial Trust as it does not have a full-year worth of data from the above-mentioned time period. Third, I assumed that there is a monotonic relationship among the Fraser family members. Monotonic relationships are less restrictive than linear relationships as linear relationships are monotonic, but not all monotonic relationships are linear. Therefore, I will be using the Spearman's correlation, which is suited for this task.

Basically, the function which I have written takes in three arguments: (a) the list of stocks to be correlated with one another, (b) the start date, and (c) the end date.

The function consists of the following steps:
1). use quantmod to import a list of stock symbols/tickers to be downloaded from yahoo finance
2). retain only the closing price of all the stock counters from the period between the start date to the end date (inclusive of both the start date and the end date as well)
3). join the closing prices together in one dataset, with each column representing one counter
4). produce scatterplot matrices and the Spearman's correlation table.

So, here's the scatterplot matrices produced by R:




















At first glance, I thought that there was something wrong with the output. For example, if you look at the scatterplot in the first column from the left, second row from the top, it has F&N on its x-axis and FCL on its y-axis. A mirror-image of that scatterplot could be found on the second column from the left, first row from the top. The change is that now F&N is on the y-axis and FCL is on the x-axis. The scatterplots do really look different from one another if the counters swapped axis! I've checked the underlying raw data and everything seems to be correct. Guess it must be the compression of the y-axis (relative to the x-axis) that causes the distortion in presentation.

What about the Spearman's correlation table?











Over the last year, the performance of Frasers Centrepoint Trust is positively associated with the performance of Frasers Commercial Trust. Frasers Hospitality Trust is least associated with the other counters in the Frasers family (the correlation coefficients with the other counters are generally smaller).

That's all for now.

In the meantime, I shall touch up on my programming code. I realized that I have no error handling mechanism in my code (e.g. if only one symbol/ticker is used as an input, it should throw up a warning statement instead of an error). Also, the scatterplots could be made more visually appealing (most probably with the ggplot2 package).

Readers, if you want to know whether a counter correlate with another counter, do drop a comment. I'm keen to test my function out further. =P

Just specify the list of counters, start date, and end date!

Monday, May 1, 2017

A colleague's financial woes

Recently, a colleague of mine has been experiencing an increased amount of financial stress in his life. He is going to get married soon, have to pay the down payment for his flat, and commence paying the monthly installments like all budding home owners.

Besides the looming mountain of debt, he also has to service a whole life policy a "friend" sold him. Having read up a little on insurance after purchasing the whole life policy, he realized he got a sucker's deal. He is hesitant to terminate the policy as he would not get back the full value of premiums paid thus far. Hence, he is intending to continue paying the premiums for his whole life policy.

Add to that that both he and his wife-to-be only have contract jobs, the huge financial load that they would have to shoulder together as a couple seems all the more intimidating. From my conversations with him, I learn that he and his wife have bright dreams ahead of them. They both intend to further their studies. However, with their current situation, he has been thinking of shelving his dreams aside.

A female colleague was quick to point out that his wife-to-be would also be able to contribute financially. Shouldering the debt load was not his alone. He swiftly called her out on her bluff. After all, there is still the female expectation for males to support them financially even though ladies have surpassed men in earning power. Why touch your own savings and investments when there is a loving boyfriend/hubby that willingly and unconditionally provide for you? ;) Only touch your principal when there's no choice mah!

The female colleague then rubbed it in with the bride price and the 四点金 (si dian jin). For non-Chinese readers, the si dian jin is a 4-piece jewellery set presented to the bride. This meant additional savings on his part.

I realized that my colleague has been spending more time on his hobbies to unwind.....

On a separate (yet related) note, he is also concerned about job stability and career progression in our industry. As I have shared in my blog postings before, you need at least a Masters degree before you can get a permanent job in my field of social science research. With rampant paper qualifications-inflation these days, sooner or later you would need a PhD just to get a job. (In fact, this is what is happening in my previous work place. PhD holders are applying for Masters level positions).

Upon some reflection, social science graduates can also be broadly categorized by what they intend to do with their degree following graduation. There are those that get a degree to satisfy the basic requirements of jobs available in the marketplace today. Therefore, what jobs they take up after graduation may or may not be related to the field of their degree. Hence, you have people working in banking, human resource, finance, consulting, business services, etc.

Conversely, you have those that do want their jobs to be an extension of their degree programme, applying what they have learned in school to the workplace. Here you have the social science researcher or the social science practitioner.

When posed with "am I in the right place/career" questions from interns and colleagues who are newer to the workforce such as said male colleague above, I am always unable to answer their question adequately. It is a personal question that is best answered by the questioner himself/herself.

If you want to be a social science practitioner, you have to either save a lot or come from a rich family (spend $100000 or so for both Bachelor Degree and Masters). You must be willing to accept a low pay even after many years of studies as well as the exorbitant tuition fees you fork out. Those who seek this path do so out of helping others self-actualize. Cost of studying and low remuneration should be a non-issue to them; what brings satisfaction is seeing the joy on your client's face.

For those who gravitate towards the former, the requirements and expectations are indeed different. Paper qualifications are not the be-all and end-all. Your job experience is much more esteemed by your employer. You work in vastly different environments and have a higher base pay and pay progression to boot.

There is no right or wrong answer. And this is why the person is in the best position to answer the question themselves.