# Investing Blueprints

## Sunday, 28 June 2020

### Rejuvenation industry: will it dwarf the dot-com bubble?

About twenty years passed since Dr Aubrey De Grey started talking about his plan to put ageing under medical control. The idea of this computer scientist turned biologist is relatively simple. Ageing is the result of an accumulation of damage that the body does to itself as a result of the normal metabolism operations. We can't realistically expect to manipulate the metabolism in order to make it produce less damage (the traditional approach of biogerontology) without doing more harm than good, because metabolism is extremely complicated and we don't know nearly enough about it. And we also can't expect to attack the consequences of this damage accumulation (the traditional approach of geriatrics) with any significant success, because far too things go wrong all at the same time as we get old. So, he proposes a sort of "preventative geriatrics" approach that aims at repairing the damage in order to prevent it from reaching a pathological level. While the processes that produce the damage are extremely complicated, the damage itself is relatively simple: all of it can be classified in just seven broad categories. These categories are:

- cell loss/atrophy

- division-obsessed cells (basically cancer)

- death-resistant cells

- mitochondrial mutations

- intracellular waste products

- extracellular waste products

- extracellular matrix stiffening

In principle, all of these types of damage are potentially treatable. De Grey thinks we can find a way to do it, and in this way we would cure ageing and stay young indefinitely.

Most people called him mad. Admittedly, his bizarre look didn't help:

However, he didn't give up, and he founded a non-profit organization called SENS with a handful of other scientists in order to conduct scientific research inspired by his idea. Slowly, things started to change, and year after year his approch became more and more mainstream. Here is one of the many talks De Grey gave about his plan and the progress that have been done.

A few years ago, the magic happened: private investors became interested, and many startups were created. Some of them grew enough to go public. So now there is a growing industry in which you can easily invest. Should you? Let's give a better look at this.

Biotechnology startups have a huge high risk - high reward factor: the value of a stock can skyrocket if things go well, or go to zero if they don't, often very suddenly. The success or failure of a clinical trial can write the fate of a company almost overnight. If this is true in general, you can imagine how much this applies to an avveniristic and early stage market like the one focusing on rejuvenation. If this idea works, people who bet on it will be rich, no doubt. Of course, it could also fail, or at least take more time than expected. De Grey is very optimistic: he thinks we could be less than 20 years away from achieving robust human rejuvenation, and less than 5 years away to achieve robust mouse rejuvenation (which would serve as proof of concept for human rejuvenation, and therefore attract huge interest from investors, which would make the market skyrocket). However, even he admits that we might not have robust human rejuvenation for another hundred years.

Lots of speculative thinking so far. Let's get more down to earth and see how this market has performed so far. Here is a list of American public companies that, to the best of my knowledge, make up the bulk of this market:

- AgeX Therapeutics

- Alector

- Athersys

- Cohbar

- Denali Therapeutics

- resTORbio

- Scholar Rock

- Unity Biotechnology

Starting from November 29, 2018 (the day AgeX Therapeutics, which is the last of these companies to go public, was listed on the NYSE), the following graph shows what would have happened to one unit of wealth invested in each of these companies:

We can notice two things. The first one is that only two of these stocks now trade at a value higher than at the end of November 2018. The second is the very high volatility. Look for example at the vertical fall that the blue line experienced. That is what happened to the value of the resTORbio stocks after the company announced the failure of the Phase 3 trial for their main drug candidate.

So what if you had a portfolio with your wealth equally split among these eight stocks? Here is what would have happened to your money:

So, at a certain point in time, the losses would have amounted to half the value of the investment. This is a reminder of how risky this stuff is. However, in the last few months there have been some big gains, although there still is a 20% loss on the initial investment. It is also interesting to notice the low correlation with the main market indices, with the value of the portfolio going down while the S&P 500 and NASDAQ were breaking record after record. This is because the fate of these companies has little to do with the general state of the economy, and everything to do with the results of their clinical trials (and until results are announced, with how much investors trust these clinical trials will be completed successfully).

To sum it up, here is what I think. This is very high risk - high reward stuff. You don't want to invest a very big fraction of your savings into this because the risk of huge losses is just too big. However, it is also undeniably fascinating stuff. If this works, the world will never be the same again, and if you invested in it, you would be rich. So, if you have some money that you are willing to risk, you might give this a try. I would simply place an equal amount of money on each of the stocks in the rejuvenation industry, and then wait. It is especially important to not be emotional: you have to be ready to look at a -50% return without panic selling. Just buy and wait a few years. If things go as hoped, you'll celebrate on your yacht.

## Monday, 22 June 2020

### How to recreate the matrix of prices from the matrix of returns in R

It is very easy, in R, to obtain a matrix of returns starting from a matrix of prices. The opposite procedure, however, is slightly more complicated. Let's say you have a matrix of returns that starts at time

Let us start by generating some prices (5 periods for 3 assets), in order to put together a working example. We also store in a separate object the prices in the first period.

prices <- abs(matrix(rnorm(15,mean=0,sd=1),5,3))

prices_1 <- prices[1,]

We then compute the simple and log returns.

simple_returns <- diff(as.matrix(prices))/prices[-nrow(prices),]

log_returns <- diff(log(prices))

Now, imagine you were only given the vector of prices at the first period and the matrix of simple or log returns, and you want the matrix of prices. If you were given simple returns, you can do it with this code:

prices_new1 <- rbind(prices_1,simple_returns)

for(i in 2:(nrow(simple_returns)+1)){

prices_new1[i,] <- prices_new1[i-1,]+prices_new1[i-1,]*prices_new1[i,]

}

row.names(prices_new1) <- 1:nrow(prices_new1)

With log returns, the code is as follows:

prices_new2 <- rbind(prices_1,exp(log_returns))

for(i in 2:(nrow(log_returns)+1)){

prices_new2[i,] <- prices_new2[i-1,]*prices_new2[i,]

}

row.names(prices_new2) <- 1:nrow(prices_new2)

As you can easily check, the objects prices, prices_new1 and prices_new2 contain exactly the same values.

*t*, and a vector of the prices at time*t-1*. How can you obtain the full matrix of prices that has been used to generate the matrix of returns? I'm going to illustrate you how to do it.Let us start by generating some prices (5 periods for 3 assets), in order to put together a working example. We also store in a separate object the prices in the first period.

prices <- abs(matrix(rnorm(15,mean=0,sd=1),5,3))

prices_1 <- prices[1,]

We then compute the simple and log returns.

simple_returns <- diff(as.matrix(prices))/prices[-nrow(prices),]

log_returns <- diff(log(prices))

Now, imagine you were only given the vector of prices at the first period and the matrix of simple or log returns, and you want the matrix of prices. If you were given simple returns, you can do it with this code:

prices_new1 <- rbind(prices_1,simple_returns)

for(i in 2:(nrow(simple_returns)+1)){

prices_new1[i,] <- prices_new1[i-1,]+prices_new1[i-1,]*prices_new1[i,]

}

row.names(prices_new1) <- 1:nrow(prices_new1)

With log returns, the code is as follows:

prices_new2 <- rbind(prices_1,exp(log_returns))

for(i in 2:(nrow(log_returns)+1)){

prices_new2[i,] <- prices_new2[i-1,]*prices_new2[i,]

}

row.names(prices_new2) <- 1:nrow(prices_new2)

As you can easily check, the objects prices, prices_new1 and prices_new2 contain exactly the same values.

### An Introduction to Stock Investing with R: Second Edition

The second edition of my book is ready. It is available on the Kindle Store at the same price of the first edition. I thoroughly revised and expanded it, and it now features more in depth explanations where was needed, it provides more codes, and it uses an updated dataset. Don't miss this opportunity to learn how to invest on your own quickly, effectively and with minimum costs. And please, leave a review on Amazon if you liked the book!

## Tuesday, 19 May 2020

### The great coronavirus market crash

So it happened. The markets stopped their bull run. Sure, I didn't expect it to be suddenly replaced by one of the worst economic crisis ever, but here we are. So, what now? Well, let me put it straight: we are facing doomsday scenario here. Actually, things might even get worse, at least in some countries.

Let's go with order. The general consensus, with which I happen to agree, is that there will be no V-Shaped Recovery, but rather an L-Shaped Recovery. This is hardly surprising: the virus is still around, only a minority of the world population have been infected and are immune to it, and so we simply cannot go back to normal. We have to travel with the v-brake (pun intended) activated, which would be bad for the economy in normal times, let alone after months during which billions of dollars of wealth have not produced because of the lockdowns. Sure, central banks and governments are throwing in the usual monetary and fiscal stimulus, and more of it might arrive. However, this is not going to help much: in order for a stimulus to work, you need something to stimulate. If businesses cannot go back working at full speed because of the COVID-19 containement measures, not much can be done. Hopefully we will have a vaccine by next year, but it may also be that we won't have one anytime soon and we will have to wait for global herd immunity...

So, we are the middle of the desert, with a punctured tire which we can't repair or substitute, only blow air in it that will come out in a matter of minutes, and the nearest place where we can get some help is many km away. How could things be worse? Well, we might run out of water because we've drank all of it earlier, thinking we would arrive at our destination safely with no accidents. That's the situation highly indebted countries with a sluggish economy are in. Their economy may completely sink, which implies falling tax revenues, and at the same time their public expenditure will go up. Their public debt would become unsustainable. A particularly interesting situation can be found in the EU: countries that kept their expenditures in check during good times will suffer from the crisis, but have the means to survive. Those who didn't...well, they can only ask the former to help them stay afloat. And that's the kind of solution we're going to see. Is this going to end well? I don't think so.

## Thursday, 26 March 2020

### How to compute a semicovariance matrix with R

Most of you are probably familiar with the covariance matrix. Its less known brother, the semicovariance matrix, might however be new to you. The semicovariance matrix is pretty much like a covariance matrix, with the difference that it is computed accounting only for the variability below a certain benchmark, which is set by the investor (e.g. negative returns, or returns lower than the risk-free rate or any other cut-off the investor sets).

Why would you want to use it? Well, if you think about it, it's the most natural thing to do: why consider all variability as risk, while in fact it is only the possibility of incurring into losses (or at least to earn less than expected) that worries you? Returns higher than the mean increase the volatility, but the possibility of achieving them can hardly be classified as risk. Therefore, it makes more sense to measure risk using not the standard deviation (which is the square root of the variace), but rather the downside deviation (the square root of the semivariance). If asset returns are symmetrically distributed, targeting either one or the other measure of risk makes no difference (well, technically, that's not always completely true, but let's make this almost innocuos assumption for the sake of simplicity). That's the logic behind the strategies that target the downside risk, and using the semicovariance matrix instead of the covariance matrix turns mean-variance optimization into mean-semivariance optimization, which is one way to target downside risk.

However, the semicovariance matrix suffers from one problem: endogeneity. Since it is computed by looking at the periods in which the portfolio underperforms the benchmark, but this set of periods is affected by the weights of the portfolio, any change in the portfolio weights changes the elements of the semicovariance matrix! This makes optimization problems that use the semicovariance matrix intractable. Luckily, there is a way around this problem. This paper describes a simple solution that consists into computing an approximated exogenous semicovariance matrix by looking at when the single assets, and not the portfolio as a whole, underperform the benchmark. The paper also describes in much greater detail what a semicovariance matrix is, so you should definitely give it a look.

The question now is: how can you compute this matrix in R? There are no built-in functions in R that perform this task, so let me show you how to write one. Let's call this function "scov"; the following code will give you what you need:

scov <- function(mydata,B){ #mydata = matrix of past returns; B = chosen benchmark

D <- mydata - B #subtract the benchmark from the returns

Z <- matrix(data=0, nrow=nrow(mydata), ncol=ncol(mydata)) #matrix of zeros

D <- pmin(D,Z) #pick the minimum value between D and 0

SM <- (nrow(mydata))^(-1)*t(D)%*%D #approximated semicovariance matrix

return(SM)

}

Done! It wasn't difficult, right? You can then use SM instead of the covariance matrix, in order to compute a mean-variance or minimum semivariance portfolio. Still, you might want to take it easy, as this approximation of the semicovariance matrix is not always a good approximation...

Why would you want to use it? Well, if you think about it, it's the most natural thing to do: why consider all variability as risk, while in fact it is only the possibility of incurring into losses (or at least to earn less than expected) that worries you? Returns higher than the mean increase the volatility, but the possibility of achieving them can hardly be classified as risk. Therefore, it makes more sense to measure risk using not the standard deviation (which is the square root of the variace), but rather the downside deviation (the square root of the semivariance). If asset returns are symmetrically distributed, targeting either one or the other measure of risk makes no difference (well, technically, that's not always completely true, but let's make this almost innocuos assumption for the sake of simplicity). That's the logic behind the strategies that target the downside risk, and using the semicovariance matrix instead of the covariance matrix turns mean-variance optimization into mean-semivariance optimization, which is one way to target downside risk.

However, the semicovariance matrix suffers from one problem: endogeneity. Since it is computed by looking at the periods in which the portfolio underperforms the benchmark, but this set of periods is affected by the weights of the portfolio, any change in the portfolio weights changes the elements of the semicovariance matrix! This makes optimization problems that use the semicovariance matrix intractable. Luckily, there is a way around this problem. This paper describes a simple solution that consists into computing an approximated exogenous semicovariance matrix by looking at when the single assets, and not the portfolio as a whole, underperform the benchmark. The paper also describes in much greater detail what a semicovariance matrix is, so you should definitely give it a look.

The question now is: how can you compute this matrix in R? There are no built-in functions in R that perform this task, so let me show you how to write one. Let's call this function "scov"; the following code will give you what you need:

scov <- function(mydata,B){ #mydata = matrix of past returns; B = chosen benchmark

D <- mydata - B #subtract the benchmark from the returns

Z <- matrix(data=0, nrow=nrow(mydata), ncol=ncol(mydata)) #matrix of zeros

D <- pmin(D,Z) #pick the minimum value between D and 0

SM <- (nrow(mydata))^(-1)*t(D)%*%D #approximated semicovariance matrix

return(SM)

}

Done! It wasn't difficult, right? You can then use SM instead of the covariance matrix, in order to compute a mean-variance or minimum semivariance portfolio. Still, you might want to take it easy, as this approximation of the semicovariance matrix is not always a good approximation...

#### Bibliography

- Estrada, J. (2008), Mean-Semivariance Optimization: A Heuristic Approach, Journal of Applied Finance, 18(1)
- Cheremushkin, S. V. (2009), Why D-CAPM is a Big Mistake? The Incorrectness of the Cosemivariance Statistics, SSRN Electronic Journal

## 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.

Subscribe to:
Posts (Atom)