R tutorial: The Portfolio Weights

Portfolio weights show what fraction of your money goes into each stock. The basic formula is values divided by their sum. Equal weighting spreads risk evenly, while market-cap weighting matches firm size, but any split beats putting everything in one stock.
Chapters
In the previous example, I intentionally chose two companies selling a similar product. Still, the analysis showed that the value of the stocks can diverge over time. So how to decide between those two companies? Flip a coin? No. In most cases, the rational decision is not to invest in either one or the other, but to reduce our risk by holding a portfolio and that is invested in both of them. This is called diversifying your risks. So how good is your portfolio diversification? To answer this question, you need to investigate how the portfolio investments are spread across the different assets. This is done by computing the portfolio weight of each asset. This means that we compute the ratio between the value of one investment relatively to the total value value of all the investments in the portfolio. Suppose, for example, that there are n different investments, each with their own value vi. Then the weight of investment I equals VI divided by the sum of the value of all the investments in the portfolio. The corresponding R code is simple. Suppose that values is a vector holding the values invested in a different asset. Then the corresponding weight vector is simply that vector of values divided by its sum. Of course, this vector sums to unity. In chapter four, we will see how to optimize the choice of portfolio weights. In the meantime, it is important to know that several approaches exist to set the portfolio weights. A first approach is to concentrate the investment bet in one risky asset. This approach is speculative and very likely to be inefficient when all assets are similar in terms of risk and reward. A better approach is to aim for perfect diversification and to invest the same amount in each risky asset. This is the so called equal weighting approach. Another popular approach is to set weights proportional to the market value of of the asset. It implies overweighting stocks of big firms and underweighting stocks of small firms. These are only a few examples of the large number of possible approaches to define portfolio weights. For us, the important conclusion to remember is that to avoid extreme losses, it is definitely not a good idea to put all your eggs and in one basket.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







