- Details
- Parent Category: Programming Assignments' Solutions

# We Helped With This R Studio Programming Assignment: Have A Similar One?

Category | Programming |
---|---|

Subject | R | R Studio |

Difficulty | Graduate |

Status | Solved |

More Info | Help With Statistics Assignment |

## Short Assignment Requirements

## Assignment Description

Economics 217

Homework #4

Due Thursday, March 14th, 11AM

Problem 1

For this question you will study the properties of the ARMA(p,q) model.

a. Program a function in R to simulate an ARMA(p,q) process of
length N. Please make the code modular to accept any integer values of *p *or *q*. Use your function to generate and plot an
ARMA(3,2) process for N=100, 1000, and 10000. Assume that *φ *=
(0*.*3*,*0*.*2*,*0*.*1) and *θ *=
(0*.*3*,*0*.*1) (10 points)

b. For each of the values of *N *from part ’a’, calculate the sample average and variance of the
outcome variable. What happens to these values as sample size increases? (10
points)

c. For each of these series, plot an autocorrelation function of lag-length 10. Do we find any differences in the autocorrelation function by sample size? (10 points)

d. For *N *= 100, simulate the ARMA process
1000 times and calculate a 90% confidence

interval for the estimate of variance. (10 points)

Problem 2

For this question you will study vector autoregressions.

a. Using the library "quantmod", download stock price (open) data for GOOG (Google) and AMZN (Amazon) for the period 2014-04-01 to 2016-01-01. Plot both price series in a panel plot using R. Further, suppose that these two price series follow a one-lag vector autoregression of the following form:

*G**t *= *β*0 + *β*1*A**t *+ *β*2*G**t*−1 + *β*3*A**t*−1 + *u**t*

*A**t *= *γ*0 + *γ*1*G**t *+ *γ*2*A**t*−1 + *γ*3*G**t*−1 + *e**t*

where *u _{t }*and

*e*are unobservables for the two equations. Please

_{t }__derive__the reduced form vector autoregression for this system of equations. Then, using the function lm, please estimate the one-lag reduced form vector autoregression for the two price series. Please interpret your results.

(20 points)

b. Using R, please conduct a one-lag Granger causality test between the two price series. In what way are these results consistent with the reduced form VAR from part A? (10 points)

c. For the next question, we will construct impulse response functions. Simply put, to construct an impulse response function, we shock one of the noise parameters in the reduced form VAR, and then follow the effects through the system of equations over time.

Starting from the most recent prices for amazon and google from parts ’a’ and ’b’, assume that there is a $60 increase in the noise term for the reduced form VAR that predicts the price for amazon. Please write code (without using existing impulse response libraries) to trace out the effects of this unobserved shock on the prices of both google and amazon for 10 future periods. Please plot these impulse response functions (20 points. Hint: Use matrices and iterate forward. Also, set all unobservables to zero except the initial shock.)

Problem 3

For this question you will study stationary processes and cointegration.

a. Using the same price series from problem 1, please determine the order of integration for each price series.

b. Are the two price series cointegrated? Please code this procedure in R to test for cointegration. Plot the residuals and discuss how the residual plot supports your answer.