#
代写ECON 424作业、R编程作业调试、R语言作业代做、代写Return calculations作业
代写Web开发|代做留学生Processing

ECON 424 Lab 1

Summer 2019

Due: Monday, July 29th at 8pm via Canvas

Part I: Return calculations

Consider the following (actual) monthly adjusted closing price data for

Starbucks stock over the period December 2017 through December 2018

Monthly Price Data for Starbucks Stock

December, 2017 $57.43

January, 2018 $56.81

February, 2018 $57.10

March, 2018 $57.89

April, 2018 $57.57

May, 2018 $56.67

June, 2018 $48.85

July, 2018 $52.39

August, 2018 $53.45

September, 2018 $56.84

October, 2018 $58.27

November, 2018 $66.72

December, 2018 $64.40

1. Using the data in the table, what is the simple monthly return between

December, 2017 and January, 2018? If you invested $10,000 in

Starbucks on Dec, 2017, how much would the investment be worth on

January, 2018?

2. Using the data in the table, what is the continuously compounded

monthly return between December, 2017 and January, 2018? Convert

1this continuously compounded return to a simple return (you should

get the same answer as in part a).

3. Assuming that the simple monthly return you computed in part (1)

is the same for 12 months, what is the annual return with monthly

compounding?

4. Assuming that the continuously compounded monthly return you computed

in part (2) is the same for 12 months, what is the continuously

compounded annual return?

5. Using the data in the table, compute the actual simple annual return

between December 2017 and December 2018. If you invested $10,000

in Starbucks at the end of December 2017, how much would the investment

be worth at the end of December 2018? Compare with your

result in part (3).

6. Using the data in the table, compute the actual annual continuously

compounded return between December 2017 and December 2018. Compare

with your result in part (4). Convert this continuously compounded

return to a simple return (you should get the same answer

as in part 5).

Part II. Excel exercises

Go to http://finance.yahoo.com and download monthly data on Starbucks

(ticker symbol SBUX) over the 15 year period Janurary, 2004 to January,

2019. See the Homework page on the class website for detailed instructions

on how to download data from Yahoo!. (Note, you may need to start

a month earlier in order to obtain the full range; you may also note that

Yahoo designates monthly data with date ”mm/1/yy”, but you may treat

the downloaded data as ”end-of-month”. ) Read the data into Excel and

make sure to re-order the data so that time runs forward. Do your analysis

on the monthly closing price data (which should be adjusted for dividends

and stock splits). Name the spreadsheet tab with the data “data”.

1. Make a time plot (line plot in Excel) of the monthly price data over

the period (end of Jan 2004 through Jan 2019. Please put informative

titles and labels on the graph. Place this graph in a separate tab

(spreadsheet) from the data. Name this tab “graphs”. Briefly comment

2on what you see (e.g. price trends, etc.); you can comment within the

spreadsheet.

(a) If you invested $1,000 in Jan 2004, what would your investment

be worth in Jan 2018?

(b) What is the compound annual rate of return over this period assuming

annual compounding? (Hint: what is the geometric average

annual rate for the 15 year investment?)

2. Make a time plot of the natural logarithm of monthly price data over

the entire and place it in the “graph” tab. Comment on what you see

and compare with the plot of the raw price data.

(a) Why is a plot of the log of prices informative? (Hint: what is the

slope between two time periods?)

3. Using the monthly price data over the period in the “data” tab, compute

simple monthly returns (assume Starbucks did not pay a dividend

over this period). When computing returns, use the convention that

Pt

is the end of month closing price. Make a time plot of the monthly

returns, place it in the “graphs” tab and comment. Keep in mind that

the returns are percent per month and that the annual return on a US

T-bill is about 0.5% right now.

4. Compute simple annual returns for the years 2004 through 2019 (note:

there are easy and hard ways to do this). Make a time plot of the

annual returns, put them in the “graphs” tab and comment. Note: You

may compute annual returns using overlapping data or non-overlapping

data. With overlapping data you get a series of annual returns for every

month. That is, the first month annual return is from Jan, 2004 to Jan,

2005. The second month annual return is from the Feb 2004 to Feb

2015 etc. With non-overlapping data you get a series of 15 annual

returns for the 15 year period 2004:Jan - 2019:Jan. That is, the annual

return for 2004:Jan - 2005:Jan is computed from the data of Jan 2004

through Jan 2005. The second annual return is computed from the Jan

2005 through Jan 2006 etc.

5. Use the monthly data over the full period to compute continuously

compounded (cc) monthly returns and place them in the “data” tab.

3Make a time plot of the monthly cc returns, put them in the ”graphs”

tab and comment.

(a) Briefly compare the continuously compounded returns to the simple

returns. Which ones are bigger?

6. Compute continuously compounded annual returns for the years 2004

through 2019 (Again, there are easy and hard ways to do this). Make

a time plot of the annual returns and comment. Briefly compare the

continuously compounded returns to the simple returns.

Part III. R Exercises - OPTIONAL

[PLEASE TRY THIS PART OF THE HOMEWORK AS MUCH AS YOU

CAN; you do not have to turn it in.]

Go to http://finance.yahoo.com and download monthly data on Starbucks

(ticker symbol SBUX) over the period March, 2003 to March, 2018.

Read the data into Excel and make sure to reorder the data so that time

runs forward. Delete all columns except those containing the dates and the

adjusted closing prices. Save the file as a .csv (comma separated value) file

and call it sbuxPrices.csv. This is important because base R does not have

functions for importing data from an Excel spreadsheet (see the RODBC and

xlsReadWrite packages for functions to read and write directly to Excel files).

Start R and open the file econ424lab1.r. Execute the commands in this

file line by line. Copy and paste your output into a Word (or whatever word

processor you use) document to show that you have done this assignment.

1. Import the data in the file sbuxPrices.csv using the R function read.csv()

into the data.frame object sbux.df. Follow the commands in econ424lab1.r

to manipulate the data.

2. Plot the closing price data using the plot() function. Notice that the

dates do not show up on the x-axis in the line plot. We will learn how

to fix this in future labs.

3. Compute monthly simple and continuously compounded returns. Plot

these returns separately and on the same graph.

44. Finally, the R package dygraphs (rstudio.github.io/dygraphs/) has

functions for creating interactive time series graphs similar to those

on finance.yahoo.com. If you are using R studio then you can view

the graph in the R studio web viewer. Follow the short example at

the end of the code in econ424lab1.r to see how easy it is to create

an interactive web graph using dygraphs within R studio (Besides

installing the package dygraphs, you should also install xts and zoo

for handling time-series data.)

5