1. Learn
  2. /
  3. Courses
  4. /
  5. Intro to Computational Finance with R

Exercise

Simulate data from a MA(1) model

Consider the MA(1) model $$Y_t = 0.05 + \epsilon_t + \theta \epsilon_{t-1},$$ with \(|\theta| < 0\) and \(\epsilon_t ~\) \(iid\) \(N(0,(0.1)^2)\).

In this exercise, you will simulate 250 observations from the above model. You can use the arima.sim() function in R to simulate a moving average or autoregressive process (see documentation). Furthermore, you should specify the following arguments for arima.sim:

  • The model argument should contain a list that indicates the type of model that you would like to simulate from. For a MA(1) model with \(\theta = 0.3\), for example, you should set the model argument to list(ma = 0.3).

  • n specifies the number of observations to simulate.

If you take a close look at the documentation of arima, you will notice that there is no constant included in the model. This means that you will need to add the constant \(0.05\) yourself.

Instructions

100 XP
  • Simulate 250 observations from the above MA(1) model with \(\theta = 0.5\) and the constant \(0.05\). Assign the result to ma1_sim.