Search This Blog

Thursday 30 January 2020

Free online resources to learn statistics and basic R coding


In my book I don't go a great length in covering statistical concepts or in teaching the reader the required (very) basic knowledge of R. That is because there already is plenty of self-learning material available on the internet, and also because knowledge of math and statistics is not strictly necessary to apply what I show in the book. Still, it doesn't hurt to learn some statistics to get a deeper understanding of portfolio optimization, and you might want some directions regarding introductory R manuals.

R for Beginners, written by Emmanuel Paradis, is the first R manual I read when I started learning R. I think it does a good job in quickly teaching the reader the most basic concepts. It is quite short, and it's not a bad idea to read all of it. However, if you really only want to learn what is strictly necessary to implement the strategies I describe in the book, it is probably enough to skim through chapters 2, 3 and 6.
If you want to get serious about R programming, it is then a must to visit the R-bloggers website. It collects thousands of useful posts from a very large number of bloggers, and it also has a Learn R section with links to all sort of R guides and manuals.

You also need to get familiar with RStudio if you want to use it (and I think you should). Luckily, this is very straighforward. These slides provided by Princeton University take only a few minutes to read, and are enough to jump start a first time user.

Now, let's get at statistics. This online textbook by Hossein Pishro-Nik covers a good amount of material and is a good read for a beginner. Statlect is also nice, although because of the way it's structured I would use it more as reference to look up to single concepts rather than as a textbook to read one chapter after another.
Finally, if you want to learn something about forecasting, which is not directly related to the material in the book, but is definitely useful to know, you can check this book from Rob J. Hyndman and George Athanasapoulos.

You can always find the links to the resources presented here in the "Useful links" list in this blog.

Monday 27 January 2020

Websites with calculators, formulas and definitions that make life easier



Sometimes you just need to have right at hand the right formula, or the exact definition, or to have a calculator that spares you from wasting time on boring computations. I'm going to present you the three websites that have been most useful for me.

The Financial terms dictionary provided by Investopedia.com is a great resource that provides precise definitions for hundreds of financial terms, together with many useful formulas. When you are confused about or unfamiliar with some concept, there's a good chance this dictionary can really help you solve your doubts.

financeformulas.net is incredibly useful when you quickly need to find out the right formula to compute some popular financial ratio or indicator. Formulas are divided into categories: general finance, banking, stocks/bonds, corporate finance, financial markets. It's definitely good to have this website in you browser's bookmarks.

Finally, buyupside.com features a lot of calculators and analyzers, provided by retired college professor and investor Richar A. Howard. The tools include calculators to compute compound interest rates, inflation rate, investment fees, and many more.

You can now find these three websites in the "Useful links" list on the right side of the blog.

Saturday 25 January 2020

Will the stock market crash?

 
Now, the million dollar question: is the stock market going to crash? People have been asking this question for the past few years, but so far the market continues its bull run. Some really believe the euphoria is going to end very soon. Granted, sooner or later bearish market will kick in, so if there constantly is someone claiming a correction is going to happen, sooner or later we will see someone "predicting" the crash. Markets go up and down, it's in their nature. Telling when they go up or down is another story. So I really don't want to participate in this pointless game. I do want, however, make a broader discussion about stock markets behaviour.

Let's focus for a moment on the American stock market, which is the one everybody's eyes are on. The S&P and NASDAQ are breaking records, and some say companies are overevaluated by euphoric investors. Still, the american economiy is doing good, maybe not so good to enterely justify such a bull run, but it's certainly not completely irrational. There is real growth behind it. Point is, even stock markets of European economies that are not doing good at all are breaking records. Just to provide a couple of examples, the french GDP growth rate is not exactly breathtaking, and Italy is barely growing at all. However, stock markets in those countries seem to not care; the italian FTSE MIB earned almost 30% last year, despite economic and political instability. So why are the investors so optimist? If I had a fully satisfactory answer to this question, I would already be a millionaire. But I do know one thing: the markets are distorted. Think about it: what do investors base their decisions on? Their outlook on the state of the economy? Yes, also. But what else? Interest rates. Investors are betting that central banks will keep their low interest rates policy indefinitely. They feel safe, because they assume the central bank is there to keep them afloat no matter what. If this is not a distortion, I don't know what it is.

Now another question from finance 101: what is it that goes down when interest rates are low, while the stock market thrives? Bonds yields, of course. Including those of sovereign bonds. This is why there are countries like Italy showing increasingly unsustainable debt to GDP ratios while still managing to get away with sovereign bond yields that are ridicolously low* compared to the seriousness of the economic situation. Too bad, there are no free lunches in this world, so someone must be paying the price, and in fact someone is. But this is only an appetizer. As I mentioned, these policies are distorting expectations, and distorted expectations can create bubbles, that sooner or later have to burst. But I don't want to sound too austrian, so let's assume no bubbles are being inflated. We still have to face the fact that sooner or later central banks will have to raise interest rates. How will the market react? And what about the highly indebted countries? The combination of a recession and increasing bond yields could be fatal for them. Sooner or later the bill for the lunch will have to be paid. Try not to be seated at the wrong table when the time comes.

*Source: investing.com

Wednesday 22 January 2020

The "secret" behind Trump's economic "miracle"



So, what is the magical recipe adopted by Trump to boost the US economy as mentioned in the last post? Don't hold your breath: there is no "secret". Trump did a pretty simple thing: he cut the taxes. If you cut taxes without cutting public expenditure, you can expect to give a boost to the economy, and that's what happened. Of course, I'm oversimplifying a lot, but this is it in a nutshell. It's not rocket science, even a child can get it, although IT IS smart compared to the approach of many European countries that keep raising taxes AND public expenditure, achieving only sluggish economic growth and unsustainable government debts. Maybe we should replace European politicians with children...

No doubt, even the American federal debt is piling up; it's another obvious thing that you get if you cut taxes without cutting the expenditure. Still, under Obama the federal debt was piling up at an even worse rate, so we can hardly accuse Trump of jeopardizing an otherwise idyllic situation. Even the threats of protectionist policies and trade wars, in the end, did little damage.

The question everybody is asking is: how much will it last? Will a brutal correction, at some point, wipe out three years of gains? The non-stop increase of the federal debt is only one possible source of problems, and probably not in the immediate future. Many people start to fear the stock market rally is actually a bubble ready to burst. And what will happen if the Fed raises the interest rates? These are questions hardly limited to the United States. Strong distortions are at work in the financial markets of many countries. I'll tell you more about this in another post.

Tuesday 21 January 2020

"This is why many people think economics is BS"



econjobrumors.com is a website on which economists (and academics in related disciplines) share and discuss job offers, conferences, academic journals and so on. Contrary to what you might think, it is often funny to read and politically incorrect, probably thanks to the fact that posts are anonymous. While browsing the website, I stumbled upon a post that shed light on an issue every economist is faced with: many people think economics is just bullshit. Even though I don't even call myself an economist, finance is a related discipline, and so I still feel the heat sometimes. This is why I want to share with you the post I mentioned. The discussion was about Krugman's prediction that the election of Trump would have wrecked the american economy to the point it would have never recovered:

If the question is when markets will recover, a first-pass answer is never. [...] So we are very probably looking at a global recession, with no end in sight.

Krugman's article didn't exactly age well: the markets have been breaking record after record, the unemployment rate is at a near-record low, and the american economy overall is just booming. And this came from a Nobel prize winner economist! So let's get at the post of our anonymous friend on the discussion I mentioned:

This is funny. But we should also be angry. All those people who think economics is BS voodoo science think that way because dbags like Krugman go on TV/in the press and make claims they can't possibly back-up with sound economics.
The only practical way your average layman has to evaluate the success of economics is that they saw idiots like Kruggles in the NYT saying "markets will never recover" (which any actual economist can immediately see is nonsense).
It's fine for Krugman who already has his phat Nobel money, his sweet speaking gigs, and his cushy NYT column. But for those of us who depend on public funding to do actual research, and on attracting students to the study of economics to maintain the viability of our departments, people like Krugman are public enemy number 1. 

This pretty much nails it. Economics is a social science, and as such it will never be as rigorous as natural sciences. But this is not the main problem. The main problem is that it is a discipline with political implications, and too many of the big guys in the field seem to abandon objectivity to push political positions. Krugman is probably an extreme case (I also think his Nobel prize was the most undeserved ever, but that's another story), but he's certainly not alone. While economics does not and probably never will have the rigorousness of natural sciences, it is also not BS as many people think. And while it's true that economists disagree, serious economists do not disagree as much as the general public thinks. There is a vast body of knowledge on which the discipline lies that is pretty much well established.

Finally, one thing that will never be pointed out often enough: the job of economists is not to make predictions. They do make predictions sometimes, but that's not what the discipline is about. Ideally, an economist is like a doctor, with the difference that the patient is not a person, but an economic system, or a part of it. Like a doctor, he tries to tell what's good and what's bad for the economy, he tries to find out what's wrong when something does not work properly, and how to fix it. Every doctor will tell you that smoking is bad for you, and that's true. However, there are people who smoke for decades and stay healthy until the age of 90, and people who never smoked that die of cancer at the age of 40. That does not invalidate the statement that smoking is bad for you. Other questions are more open and doctors disagree, like about the health consequences of eating red meat. While medicine is more rigorous than economics, they are similar in this regard. This is the correct way to look at economics as a discipline.

Wednesday 15 January 2020

My book "An Introduction to Stock Investing with R" is out now!


The first post on this blog is to announce the publication on Amazon Kindle Store of my book "An Introduction to Stock Investing with R". American readers can find it here. Readers from other countries can find it by searching for the title on the Amazon website they usually shop from.

This book is intended as a practical guide to teach the reader, in just 41 pages, how to optimally allocate money among different stocks using some of the most important results of modern finance. It also shows how to avoid losing money by exposing some very popular and aggressively advertised, yet ineffective, investing strategies (technical analysis above all). No prior knowledge of finance is necessary, and only very limited familiarity with statistics and with the R environment is required. Thanks to the codes contained in the book, and to the dataset downloadable for free here, you'll be able to replicate all the results and the examples in the book.

"An Introduction to Stock Investing with R" is particularly suited for investors who want a very friendly introduction to the basics of quant investing, but also for finance students looking for a handy guide to portfolio optimization with R.