Uploaded by Sarah Y

COMM1190 Week3 4pm annotated

advertisement
COMM1190 Business Decision Making
Week 3: Analysing Financial Time
Series using R
Rajesh Lucknauth, Associate Course Coordinator
School of Information Systems and Technology Management
UNSW Business School | UNSW Australia
Welcome to Week3
Workshop!
Questions?
Before we start,
do we have
questions on
Workshop 2
Daily Returns of Stocks
Your first task is to calculate the logreturns of S&P 500 index and Microsoft
stock.
The log-return on day d is computed as:
R_d = ln(Sd) - ln(Sd-1)
with Sd representing the price on day d
Sd-1 is the price on preceding day
Day
Open
High
Low
Close
Column 5 represents the Close
price for the day is Sd.
In the activity 1-3, we use the
adjusted close which is column 6.
There are not always significant
differences between adjusted
close and close for S&P500.
Adj Close Volume
Questions?
Workshop 3Activity 1
Workshop 3 –Question 1
1.Calculate the log-returns for S&P 500
index and Microsoft using R
2.Plot S&P 500 price and its log-returns,
and plot Microsoft price and its logreturns (x-axis should correspond to
calendar year).
3.Comment on the chosen time frame
and discuss some characteristics of the
data that you might find interesting.
Activity 1:
Run the R-script to generate the
• S&P 500 Price chart
• Microsoft Price chart
• S&P500 Daily Returns
• Microsoft Daily Returns
R Coding:
R Studio and/or Ed’s Jupyter platform
Explaining the R-coding for Activity 1
R Coding:
R Studio and/or Ed’s Jupyter platform
Explaining the R-coding for Activity 3
Price Charts
Comments & Insights:
• Before 2009, the S&P 500 and
Microsoft was not correlated
• Market crashes: 2009 and 2020
(march). MSFT was not as
adversely impacted by the market
crash as other listed companies
• S&P500 and MSFT follows an
upward trend in the post-GFC era
More insights by comparing charts
Students’ Group Brainstorming Activity 1
Comments and Insights
• When the stock market crashes in 2009 and 2020, S&P500 price declines, and the returns
show high a spike in the oscillations, thus indicating high bursts of volatility.
• VIX is another index used to measure volatility where investors speculate on the heightened
volatility by buying VIX futures.
• When there is an upward trend in stock prices of both MSFT and S&P500, the volatility is
lowest, as demonstrated by the graphs below, thus showing fewer investors’ uncertainty
during those good times.
• The overall volatility is higher for Microsoft than the SP500 due to diversification benefits of
S&P500 which Microsoft cannot achieve.
Questions?
Workshop 3Activity 2
Workshop 3 –Question 2
1. Present summary statistics for the
S&P 500 index and Microsoft stock
log-returns, such as the mean,
variance, skewness, kurtosis, and
other descriptive statistics.
2. Discuss the findings you might
find interesting and derive insights
Activity 2:
Generate descriptive Statistics on
R
R Coding:
R Studio and/or Ed’s Jupyter platform
Explaining the R-coding for Activity 2
Summary Stats: S&P500 v/s MSFT
mean(SP500_returns)
0.0002122353
mean(MSFT_returns)
0.0005519068
var(SP500_returns)
0.0001555403
var(MSFT_returns)
0.0003341242
sd(SP500_returns)
0.01247158
sd(MSFT_returns)
0.01827906
min(SP500_returns)
-0.1276522
min(MSFT_returns)
-0.1594534
max(SP500_returns)
0.109572
max(MSFT_returns)
0.1706253
0.0381354
skewness(SP500_returns)
-0.418067
skewness(MSFT_returns)
kurtosis(SP500_returns)
14.68138
kurtosis(MSFT_returns) 11.25427
Students’ Group Brainstorming Activity 2
Comments and Insights:
• MSFT has higher mean returns and variability (variance), which almost doubled
the S&P500, as the latter is most diversified and risk minimizing.
• With lower kurtosis and positive skewness compared to the market average
(S&P500), MSFT has fewer outliers than S&P500.
Questions?
Workshop 3Activity 3
Workshop 3 –Question 3
1. Use an appropriate plot and numerical
measure to quantify the
relationship/dependence between the
S&P500 index and the Microsoft stock
prices and derive insights.
2. Decisions: What would you recommend
to your manager based on your analysis of
the log returns of the S&P500 index and
the Microsoft stock?
Activity 3:
Compile the Correlation graph and
correlation factor in R
Comments on correlation:
A correlation factor close to 1.0,
implies that there is a high
association between S&P500
and MSFT price.
cor(SP500_price, MSFT_price)
## [1] 0.9023579
Correlation between returns
Corr = 0.72676
A correlation factor close to 1.0, implies
that there is a high association between
S&P500 returns and MSFT returns. MSFT
is highly exposed to market risk.
COMM1190_T2_2022 – Ed Discussion
(edstem.org)
Download