R for things other than Finance, Github, and Stackoverflow

In looking for data sets outside of finance I was able to find some books and get a quick preview of some of them on topics R can be used for besides finance and statistics. Still highly related to statistics as most of the modeling and analysis done in these books are statistical ones. The books I read were focused on clinical trial analysis. So this analysis is something internally a biotech company may be doing in pre-clinical trial phases to determine whether the drug they plan on developing will be successful or fail. Externally investors can do the same with the available data they can receive. Two books I really hope to get my hands on is an R programming for medicine and biology book and an R programming for chemistry. Today we discover far less drugs than we used to even with the large amounts of data and research that is available. The modern drug discovery process is looking at chemistry, chemoinformatics, bioinfromatics, clinical informatics, and then using statistical regressions to determine the chances of success. So I think getting my hands on these books could be extremely informative.

Github and Stackoverflow have been some of my frequently visited websites this week. Github has everything you need for coding, examples, howtos, books, literally most things you want to learn or know how to do in programming are there. Stackoverflow has all the answers, if there is something you can’t find on Github I use Stackoverflow to ask my programming questions there. One useful package I found through Github this week is the finreportr package in R. It’s pretty basic and I’d like to add some new things to it or create my own R package using it as an outline. The most useful function I’ve found on it is the GetIncome function. This function allows you to get any income statement from any publicly traded companies as well as some overseas companies. When I start doing my financial analysis of companies in R this will make things a lot easier. Instead of manually having to find and upload the data myself I can just use this simple function to get the data I need and run my analysis after a little bit of manipulation.

I’ve been trying to breakdown my analysis as best I can to make it as simple as possible to program. I think ideally my code will need the variables revenue, cost of goods sold, gross profit, operating expense, operating income, interest income, pretax income, taxes, net income,¬† net cash off the balance sheet, and gross margin. Some functions I may have to create myself are maturity and return on invested capital, I would include discount rate and net present value but I used those functions on other R packages before.

Last week I talked about a large demand for free detailed financial data. Which may not be entirely true or could’ve been better worded. If you asked 100 people if they wanted free detailed financial data I think only a couple people would say yes or care. If you were to ask someone if they know what a Bloomberg terminal is I don’t think many people would. However if you were to say do you want to make a lot of money buying and selling stocks I think 100/100 would say yes. Often times in the world of investing they say if everyone knows about something then the market will have it priced correctly and no one will profit off of whatever strategy everyone knows to use. When it comes to value and growth investing though I think some things have remained true which is why people like Warren Buffet are still highly profitable. The idea that a company is worth the net present value of all future cash flows from operations has remained quite true. I think the epistemology of investing and mathematics are to some degree relatable in that it is one of logic and reasoning. Once someone understands the formula and reasoning behind it they too can apply mathematics. I believe investing to a large degree has some philosophy, mathematics, specialization, and luck involved to it. I know friends who have invested money into stocks and even more friends that want to but are afraid to lose money. I also know that they are many people out there that have a specialized understanding of the area they are involved in. I think one of the main things that prevent someone from investing are the numbers behind it and the process that comes with it.

What I think there is a demand for is a product that is able to take away some of the complexities of investing and allow a creative, philosophical, specialized person make smart investment decisions. Some things I think this product would need

Historical Return Histogram – if Apple stock has an average yearly return of 5% and standard deviation of 10% then someone saying Apple is going to return 100% this year is extremely unlikely. Unless some large events are happening for Apple a 10 sigma move will not happen. This is kind of a way to check people at time to make sure they are acting logically in their thinking, but it is necessary.

Net Present Value of Cash Flows From Operations – this is one of the most important parts of the product, but extremely complicated to apply to a number of different companies.

Some Type of Chat or Sharing of Information –¬† this makes the NPV problem less complicated if a user base is able to share their own work and financial models with each other freely. Maybe even the NPV’s of all these models can be taken to get an average estimate form the user base. Someone with a degree in statistics can do a far better job running a regression than me. Someone with a degree in pharmacology can do a far better analysis of drug interaction than me.

Portfolio Creation – creating a portfolio that is least risky an be hard for someone who does not have a degree in finance. Offer factor analysis of individual stocks, fama french, capm, anything else important.

One company I have found that has taken some initiative¬† to do something like this is Quantopian which is free sharing of algorithms and trading strategies using computer programming. Which is useful if you know how to program, but I don’t know many people that really do know how to program.



  • Robin DeRosa

    I love the way you are integrating your coursework with your own reading to think about what kinds of gaps there are in current products– it seems like you are driving towards a vision for how you could bring together financial literacy with tools that are aimed to help the average investor make good decisions even when we don’t have the depth of understand that someone like you will have about the context. Very exciting stuff, and I continue to be impressed with the way you design your education to lead you towards something that will really make a difference in your career and in the lives of many investors.

  • Steve Greenlaw

    “Once someone understands the formula and reasoning behind it they too can apply mathematics. I believe investing to a large degree has some philosophy, mathematics, specialization, and luck involved to it.”

    If one understands how financial markets work, and has a large enough portfolio for diversification, one can play the probabilities and make a decent return. That’s what Buffett does, I think.

    • admin

      Yes! That is to a large degree what Buffet, Munger, and many other successful investors do. Buffet also stays very focused on some of the qualitative aspects of a company, “it’s far better to buy a wonderful company at a fair price than a fair company at a wonderful price”. Playing the probabilities has proven to be very effective. For example mean reversion has been a very successful way to play probabilities. Some of the original founders of D.E. Shaw popularized it with a strategy called pairs trading where you search for two cointegrating assets. The idea is to buy one of the assets when it is getting returns statistically lower than usual and short the other asset when it is getting returns statistically higher than usual, creating a market neutral hedge.

Leave a Reply

Your email address will not be published. Required fields are marked *