Eric Zivot Econ 424 Fall 2014
Transcription
Eric Zivot Econ 424 Fall 2014
Eric Zivot Econ 424 Fall 2014 Problem Set #3 Bivariate distributions, Time Series Concepts, and Matrix Algebra Due: Friday 10/17/14 at 8 PM (PST) via Canvas Readings My lecture notes on review of probability, time series concepts, and matrix algebra Ruppert, chapter 7 (sections 1 – 5), chapter 9 (sections 1-2, 4 and 7) ZLM, chapters 5 and 7 R Cookbook, chapter 5 (data structures) and 8 (probability) 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 probReview.r matrixReview.r timeSeriesConcepts.r (R commands/hints for lab3) (R script used for in class examples) (R script used for in class examples) (R script used for in class examples) Instructions In this lab you will Use R to evaluate bivariate distributions, simulate some simple time series models and do simple matrix algebra computations Exercises The following questions require R. On the class web page are the R script files 424lab3.r, probReview.r, timeSeriesConcepts.r, and matrixReview.r. The file 424lab3.r contains hints for completing the assignment and the latter files contains R code for replicating the in-class examples illustrated in the powerpoint files timeSeriesConceptsPowerPoint.pdf, matrixReviewPowerPoint.pdf. 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. Start MS Word and open a blank document. You will save all of your work in this document. I. Bivariate distributions Let X and Y be distributed bivariate normal with X 0.05, Y 0.025, X 0.10, Y 0.05 (a) Using R package mvtnorm function rmvnorm(), simulate 100 observations from the bivariate distribution with XY 0.9 . Using the plot() function create a scatterplot of the observations and comment on the direction and strength of the linear association. Using the function pmvnorm(), compute the joint probability Pr X 0, Y 0 . (b) Using R package mvtnorm function rmvnorm(), simulate 100 observations from the bivariate distribution with XY 0.9 . Using the plot() function create a scatterplot of the observations and comment on the direction and strength of the linear association. Using the function pmvnorm(), compute the joint probability Pr X 0, Y 0 . (c ) Using R package mvtnorm function rmvnorm(), simulate 100 observations from the bivariate distribution with XY 0 . Using the plot() function create a scatterplot of the observations and comment on the direction and strength of the linear association. Using the function pmvnorm(), compute the joint probability Pr X 0, Y 0 . II. Simulating Time Series Data Consider the MA(1) model Yt 0.05 t t 1 , | |<1 t ~ iid N 0, 0.10 2 a) Using the R function arima.sim(), simulate and plot 250 observations of the MA(1) with 0.5, 0.9 . Briefly comment on the behavior of the simulated data series. 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. III. Matrix Algebra (a) Create the matrices and vectors 1 4 7 4 4 0 1 5 A 2 4 8, B 5 9 1, x 2, y 2 6 1 3 2 2 5 3 7 (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 4 y 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.10 0.30 0.10 0.01 0.04, 0.30 0.15 0.20 0.02 0.10 0.20 0.08 Compute the expected return and variance for an equally weighted portfolio portfolio (i.e., xA = xB = xC = 1/3). IV. Ruppert Exercises: Chapter 7, (section 15), exercises 1 and 2. Chapter 9 (section 17), exercise 3.