• We are pleased to announce that the winner of our Feedback Prize Draw for the Winter 2024-25 session and winning £150 of gift vouchers is Zhao Liang Tay. Congratulations to Zhao Liang. If you fancy winning £150 worth of gift vouchers (from a major UK store) for the Summer 2025 exam sitting for just a few minutes of your time throughout the session, please see our website at https://www.acted.co.uk/further-info.html?pat=feedback#feedback-prize for more information on how you can make sure your name is included in the draw at the end of the session.
  • Please be advised that the SP1, SP5 and SP7 X1 deadline is the 14th July and not the 17th June as first stated. Please accept out apologies for any confusion caused.

IAI CS2B Nov 2019 Q8

  • Thread starter Srijana Raghunath
  • Start date
i) Why the random number generated is multiplied by 2?

Code:
rbinom(n, 1, .5)
will generate numbers 0 or 1. However, as per the question we need the random numbers to be -1 or 1. Hence, multiplying the 0 or 1 observation generated by 2 and then subtracted by 1 gives us the required sample.

ii) Why n=11, 101 and 1001 used instead of 10, 100 and 1000 as given in the question?

y_t depends on x_t and x_(t-1). So to generate y_1 we need x_1 and x_0; y_2 we need x_2 and x_1 and so on...

Thus to generate 10 samples of y_t, we need x_0, x_1,..., x_10 and hence 11 observations. This logic should generalize to the case when n = 100 and n = 1000.

iii) Why subtract 1?

See response to (i) above.

iv) Why use filter function to create equation yt?

Personally, I have never used the filter function from the stats package. So, not entirely sure of how this works. Although, you can go over the help documentation here: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/filter.html

However, in the present case, I think using the lag function from dplyr should also solve you needs: https://dplyr.tidyverse.org/reference/lead-lag.html
 
Back
Top