Starting from:

$30

ECON 424 Homework 3

ECON 424 Homework 3
Readings
• EZ chapters on matrix algebra review, time series concepts, and descriptive statistics for financial time series.
• Ruppert and Matteson, Chapter 4 (Exploratory Data Analysis) and Chapter 12
(Time Series Models: Basics)
• ZLM, chapters 5 and 7
• R Cookbook, chapter 5 (data structures)
• Introduction to R (pdf document on webpage), chapter 5 (Arrays and Matrices)
• Beginners Guide to R, chapter 3, section 5 (Manipulating objects)
Programs and Data
The following files are located on the class homework page:
• 424lab3.r (R commands/hints for lab3)
• matrixReview.Rmd (R markdown files used for in class examples)
1
• timeSeriesConcepts.Rmd
• descriptiveStatistics.Rmd
Programs and Data
In this lab you will use R to do
• simple matrix algebra computations
• simulate some simple time series models
• compute sample descriptive statistics for some example data
Exercises
The following questions require R. On the Canvas page are the R script files 424lab3.r,
descriptiveStatistics.Rmd, timeSeriesConcepts.Rmd, and matrixReview.Rmd. The file
424lab3.r contains hints for completing the assignment and the latter files contain R
code for replicating the in-class examples. Copy and paste all statistical results and
graphs into a MS Word document (or your favorite word processor) while you work,
and add any comments and answer all questions in this document. Alternatively, consider using Rmarkdown to integrate the R code and text. The Rmarkdown document
can be compiled and saved to either a Word or .pdf file. Start MS Word and open a
blank document. You will save all of your work in this document. Alternatively, create
a new Rmarkdown document and copy the R code from 424lab3.r into the appropriate
parts of your Rmarkdown document.
1. Matrix Algebra
(a) Create the matrices and vectors
A =





1 4 7
2 4 8
6 1 3





, B =





4 4 0
5 9 1
2 2 5





, x =





1
2
3





, y =





5
2
7





2
(b) Compute the transposes of the matrices and vectors
(c) Compute A+B, A-B, 2*A, Ax, y ’Ax
(d) Consider the system of equations:
x + y = 1
2x + 4y = 2
Plot the two lines and note the solution to the system of equations (hint: use the R
function abline()). Write the system using matrix notation as Az = b and solve for z.
(e) Consider creating a portfolio of three assets denoted A, B and C. Assume the
following information
µ =





0.01
0.04
0.02





, Σ =





0.10 0.30 0.10
0.30 0.15 −0.20
0.10 −0.20 0.08





,
Compute the expected return and variance for an equally weighted portfolio (i.e.,
xA = xB = xC = 1/3).
2. Simulating Time Series Data
Consider the MA(1) model:
Yt = 0.05 + t + θt−1, |θ| < 1
t ∼ iid N(0,(0.10)2
)
a) Simulate and plot 250 observations of the MA(1) with θ = 0.5, 0.9. Briefly comment
3
on the behavior of the simulated data series. (Hint: you can do this in a “for loop" or
use the R function arima.sim())
b) What is the mean value of Yt
for each process?
c) What is the variance of Yt
for each process?
d) Plot the theoretical ACF for each process.
Now consider the AR(1) model:
Yt − 0.05 = φ(Yt−1 − 0.05) + t
, |φ| < 1
t ∼ iid N(0,(0.10)2
)
a) Using the R function arima.sim(), simulate and plot 250 observations of the AR(1)
with φ = 0.5, 0.9. Briefly comment on the behavior of the simulated data series.
b) What is the mean value of Yt
for each process?
c) What is the variance of Yt
for each process?
d) Plot the theoretical ACF for each process.
3. Ruppert and Matteson Exercises
Chapter 4, R Lab, Section 4.10.2 McDonald’s Prices and Returns, Problems 9, 10
and 11. Chapter 12 Exercises (section 16). Exercises 3 and 4.
4. Descriptive Statistics
4
In this part of the lab, you will analyze continuously compounded monthly return
data on the Vanguard long term bond index fund (VBLTX), Fidelity Magellan stock
mutual fund (FMAGX), and Starbucks stock (SBUX). I encourage you to go to finance.yahoo.com and research these assets. The script file econ424lab3.r walks you
through all of the computations for the lab. You do not need to show the R commands
in your lab write up. You will use the get.hist.quote() function from the tseries package to automatically load this data into R. You will also use several functions from
the PerformanceAnalytics package. Remember to install packages before you load
them into R.
I. Univariate Graphical Analysis
(a) Make time plots of the return data using the R command plot() as illustrated
in the script file econ424lab3.r. Comment on any relationships between the returns
suggested by the plots. Pay particular attention to the behavior of returns toward the
end of 2008 at the beginning of the financial crisis.
(b) Make a cumulative return plot (future of $1 invested in each asset) and comment.
Which assets gave the best and worst future values over the investment horizon?
(c) For each return series, make a four panel plot containing a histogram, density
plot, boxplot and normal QQ-plot. Do the return series look normally distributed?
Briefly compare the return distributions
II. Univariate Numerical Summary Statistics
(a) Compute numerical descriptive statistics for all assets using the R functions summary(), mean(), var(), stdev(), skewness() (in package PerformanceAnalytics) and
kurtosis() (in package PerformanceAnalytics). Compare and contrast the descrip5
tive statistics for the three assets. Which asset appears to be the riskiest asset?
(b) Using the mean monthly return for each asset, compute an estimate of the annual
continuously compounded return (i.e., recall the relationship between the expected
monthly cc return and the expected annual cc return). Convert this annual continuously compounded return into a simple annual return. Are there any surprises?
(c) Using the estimate of the monthly return standard deviation for each asset, compute an estimate of the annual return standard deviation. Briefly comment on the
magnitude of the annual standard deviations.
6

More products