The weights of a market capitalization-weighted portfolio
In a market capitalization-weighted portfolio, the weights are given by the individual assets' market capitalization (or market value), divided by the sum of the market capitalizations of all assets. A typical example is the S&P 500 portfolio invested in the 500 largest companies listed on the US stock exchanges (NYSE, Nasdaq). Note that by dividing by the sum of asset values across all portfolio assets, the portfolio weights sum to unity (one).
As an exercise, inspect the distribution of market capitalization based weights when the portfolio is invested in 10 stocks. For this exercise, you can use market capitalizations of 5, 8, 9, 20, 25, 100, 100, 500, 700, and 2000 million USD.
This is a part of the course
“Introduction to Portfolio Analysis in R”
Exercise instructions
- Define the vector
marketcaps
holding the market capitalizations. - Calculate the weights of
marketcaps
and assign them toweights
. - Print a summary of
weights
. - Create a bar plot of
weights
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Define marketcaps
# Compute the weights
# Inspect summary statistics
# Create a bar plot of weights
This exercise is part of the course
Introduction to Portfolio Analysis in R
Apply your finance and R skills to backtest, analyze, and optimize financial portfolios.
Asset returns and portfolio weights; those are the building blocks of a portfolio return. This chapter is about computing those portfolio weights and returns in R.
Exercise 1: Welcome to the courseExercise 2: Getting a grasp of the basicsExercise 3: Get a feel for the dataExercise 4: The portfolio weightsExercise 5: Calculating portfolio weights when component values are givenExercise 6: The weights of an equally weighted portfolioExercise 7: The weights of a market capitalization-weighted portfolioExercise 8: The portfolio returnExercise 9: Calculation of portfolio returnsExercise 10: From simple to gross and multi-period returnsExercise 11: The asymmetric impact of gains and lossesExercise 12: PerformanceAnalyticsExercise 13: Buy-and-hold versus (daily) rebalancingExercise 14: The time series of asset returnsExercise 15: The time series of portfolio returnsExercise 16: The time series of weightsWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.