Uploaded by Sarah Y

Week 3 Workshop

advertisement
Week 3 Workshop: Analysing Financial Time Series using R
Objective: Data Visualisation and Exploration II
Requirements:
In the pre-workshop activities, you are required to:
-
Generate synthetic data using a normal distribution
Calculate simple statistics (i.e., mean, median, standard deviation, variance, skewness,
kurtosis,range, quartiles, correlation)
Conduct data visualisation using histograms, QQ plots, and box plots.
Conduct data visualisation using box plots for categorical data.
Problem
Standard & Poor's 500, best known as the S&P 500, is a stock market index that tracks the performance
of the 500 largest US companies listed on the stock exchange. It's a key indicator because it's recognised
as a benchmark for the performance of the broader US stock market. Microsoft is a leading tech company
listed among the 500 companies on the S&P 500 index.
You are an investment analyst working for an investment bank. Your manager is thinking of either
investing in the S&P 500 index or the Microsoft Stock. You have been asked to provide recommendations
based on your analysis of the S&P 500 price and the Microsoft price over the past 20 years. You were
given two datasets from your manager:
-
Dataset 1 (SP500.csv): Daily open, high, low, close, adj. close prices and volume of the
S&P500 (from Jan 2001 to Dec 2020); and
Dataset 2 (MSFT.csv): Daily open, high, low close, adj. close prices, and volume of
Microsoft (from Jan 2001 to Dec 2020)
Activity 1
To measure the day-to-day performance of the S&P 500 index and Microsoft stock, you decide to
calculate their daily returns. The daily return is the log-normal difference between the price of a stock
at today's closure and the price of the same stock at yesterday's closure. A positive daily return indicates
an appreciation in stock price on the daily comparison, while a negative daily return indicates a
depreciation in stock price on the daily comparison.
Your first task is to calculate the daily returns of the S&P 500 index and Microsoft stock. The return on the day
d is computed as 𝑅𝑑 = ln(𝑆𝑑) − ln(𝑆𝑑−1) with 𝑆𝑡 representing the price on day d.
Comm 1190: Data, Insights, and Decisions. Module 2: Data Visualisation and Exploration.
In your groups:
1. Calculate the daily returns for S&P 500 index and Microsoft stock using R
2. Plot S&P 500 index price and its daily returns and plot the Microsoft stock price and its daily
returns(x-axis should correspond to the calendar year).
3. Comment on the chosen time frame and discuss some characteristics of the data that you might
find interesting.
Activity 2
In your groups:
1. Present summary statistics for the S&P 500 index and Microsoft stock returns, such as the
mean, variance, skewness, kurtosis, and other descriptive statistics.
2. Discuss the findings you might find interesting and derive insights.
Activity 3
In your groups,
1. Use an appropriate plot and numerical measure to quantify the relationship/dependence between
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
returns of the S&P500 index and the Microsoft stock?
Practice using R Studio
In this exercise, you will practice using R Studio, by re-creating the bar graphs from last week’s
workshop.
1. Create a folder for storing your R work.
2. Download the R script, flavours. R and save the file to the newly created folder.
3. Download the dataset, Weekly_Sales.csv, and save the file to the newly created folder
4. In R studio, go to sessions, set working directory, and choose the directory to be the new
folder.
5. Open the R script, flavours. R and run the script to create the graphs.
Page 2
Download