AAPL | MSFT | AMZN | NFLX | |
---|---|---|---|---|
AAPL | 1.00 | 0.73 | 0.05 | -0.14 |
MSFT | 0.73 | 1.00 | 0.47 | 0.38 |
AMZN | 0.05 | 0.47 | 1.00 | 0.83 |
NFLX | -0.14 | 0.38 | 0.83 | 1.00 |
2023-11-07
Today’s plan 📋
Comments and Questions from Engagement Questions or about R
Upcoming Dates
Review Questions
Comparing Portfolios of Stocks
Profitability of sne stock using geometric mean
Weighted Mean of two or more stocks
Volatility of One Stock using adjusted standard deviation
Volatility of weighted combination of two or more stocks
Review: You have two options to facilitate your introduction to R and RStudio:
If you are comfortable with coding: Start with Option 1, but still sign up for Posit Cloud account.
If you are nervous about coding: Choose Option 2.
For both options: I can help with download/install issues during office hours.
What I do: I maintain a Posit Cloud account for helping students but I do most of my work on my laptop.
NOTE: We will use R and RStudio in class during MOST lectures
HW 7 is due 11/8 (Grace period ends 11/10)
Test 2 is on November 14th and will include material up through Lecture 20
Some Practice Questions will be posted before class on 11/9
Updates to Practice Questions and some demo videos will be posted by this weekend.
Zoom Review on Monday 11/13 at 7:00 PM
Today:
Recall that in lecture 20 we discussed \(R_{xy}\), the correlation coefficient.
The matrix shown here shows a correlation matrix for four stocks based on their 2021 - 2022 daily adjusted closing values.
A correlation matrix shows the pairwise correlation between each pair of stocks in the dataset.
Which other stock is most strongly positively correlated with Apple (AAPL)?
AAPL | MSFT | AMZN | NFLX | |
---|---|---|---|---|
AAPL | 1.00 | 0.73 | 0.05 | -0.14 |
MSFT | 0.73 | 1.00 | 0.47 | 0.38 |
AMZN | 0.05 | 0.47 | 1.00 | 0.83 |
NFLX | -0.14 | 0.38 | 0.83 | 1.00 |
For each of these four companies we have two year of data.
We want to know the average rate of return.
We could calculate the arithmetic mean of the adjusted close, but the conventional wisdom is that this is not ideal.
Instead, we calculate the geometric mean
psych
package in R has the geomtric.mean
command to do this calculation.If the Stocks are relatively stable, these values will be similar.
The geometric mean is more reliable because of the compounded interest.
The table below shows the geometric means of three of the stocks:
Stock | Arithmetic_Mean | Geo_Mean |
---|---|---|
AAPL | 146.4521 | 145.6287 |
MSFT | 268.1429 | 266.3239 |
AMZN | 146.6869 | NA |
NFLX | 421.7004 | 388.1685 |
Question 2. What is the geometric mean for the Amazon (AMZN) 21-22 stock data?
geometric.mean
command from the psych
package.Question 3. Which of these four stocks shows the largest disparity between the geometric and arithmetic mean?
A primary concern when investing is “not putting all of your eggs in one basket”.
In other words, it is important to diversify your portfolio by investing in multiple stocks so that you have some protection if one stock crashes.
We can calculate the rate of return of a portfolio
To do this we calculate a weighted average of the individual stock geometric means:
In our simple examples, we will look at 2 stock portfolios, but the same principles apply to larger portfolios.
This weighted average the stock portfolio is referred to as it’s Expected Value.
Example: Calculate the 21-22 average rate of return of a portfolio where 80% is invested in Apple (AAPL) and 20% is invested in Netflix (NFLX).
Round answer to both questions below to two decimal places.
Question 4: What is the 21-22 average rate of return of a portfolio with 60% investment in Amazon (AMZN) and 40% investment in Microsoft (MSFT)?
Question 5: What is 21-22 average rate of return of a portfolio with 70% investment in Amazon (AMZN) and 30% investment in Apple (AAPL)?
Volatility is a measure of variability and risk associated with a stocks rate of return over time.
Volatlity for a single stock: \(Volatility = SD \times \sqrt{T} = \sqrt{VAR \times T}\)
where T = number of time periods. In 21-22, there were 503 trading days, T = 503.
Variances, standard deviations, and volatilities for each of these stocks:
Stock | Variance | Std_Dev | Volatility |
---|---|---|---|
AAPL | 242.2252 | 15.56358 | 349.0548 |
MSFT | 992.2833 | NA | NA |
AMZN | 739.6161 | 27.19588 | 609.9401 |
NFLX | 24767.8935 | 157.37819 | 3529.6247 |
Question 6: What is the volatility of the Microsoft (MSFT) stock?
Round answer to two decimal places.
Volatlity for a single stock:
\[ Volatility = SD \times \sqrt{T} = \sqrt{VAR \times T} \]
Stock | Variance | Std_Dev | Volatility |
---|---|---|---|
AAPL | 242.2252 | 15.56358 | 349.0548 |
MSFT | 992.2833 | NA | NA |
AMZN | 739.6161 | 27.19588 | 609.9401 |
NFLX | 24767.8935 | 157.37819 | 3529.6247 |
Recall our portfolio where 80% is invested in Apple and 20% is invested in Netflix
Calculating the volatility of a portfolio little more complex, but it is easier if we break it down into steps.
Step 1: Calculate variance of portfolio of stocks 1 and 2, which is the sum of three parts:
Part 1: \(W_{1}^2 \times Variance_{1}\)
Part 2: \(W_{2}^2 \times Variance_{2}\)
Part 3: \(2 \times W_{1} \times W_{2} \times COV_{1,2}\)
Portfolio Variance = Part 1 + Part 2 + Part 3
Step 1: Calculate variance of portfolio of stocks 1 and 2, which is the sum of three parts:
Part 1: \(W_{1}^2 \times Variance_{1}\)
Part 2: \(W_{2}^2 \times Variance_{2}\)
Part 3: \(2 \times W_{1} \times W_{2} \times COV_{1,2}\)
Portfolio Variance = Part 1 + Part 2 + Part 3
w1 <- .8
w2 <- .2
var1 <- var(adj_st$AAPL) # Var 1
var2 <- var(adj_st$NFLX) # Var 2
cov12 <- cov(adj_st$AAPL, adj_st$NFLX) # Cov 1 & 2
(portfolio_var <- w1^2*var1 + w2^2*var2 + 2*w1*w2*cov12) # Part 1 + Part 2 + Part 3
[1] 1032.6
Step 2: Calculate Volatility from Variance
\[ Volatlity = SD \times \sqrt{T} = \sqrt{VAR \times T}\]
Round answer to both questions below to two decimal places.
Question 7: What is the 21-22 volatility of a portfolio with 60% investment in Amazon and 40% investment in Microsoft?
Question 8: What is the 21-22 volatility of a portfolio with 70% investment in Amazon and 30% investment in Apple?
Stock portfolios are linear combinations of stocks
The geometric mean is average rate of return of a single stock
The average rate of return of a portfolio is the weighted average of the individual stock means.
Volatility of a stock or a portfolio is \(SD \times \sqrt{T}\)
To find volatility of a portfolio, first find the variance
We will review these concepts and calculations after Quiz 2
To submit an Engagement Question or Comment about material from Lecture 21: Submit by midnight today (day of lecture). Click on Link next to the ❓ under Lecture 21