Wayne's Github Page

A place to learn about statistics

Homework2 - Simulating time series-like data

Goals

The purpose of this homework is to give you some experience in simulations and the problems that surface when dealing with time series.

Question 0 creating correlated errors through time

Please write a function that takes in an integer, n, equal or larger than 1, then produces “errors” that are generated in the following way:

Question 1, visualizing correlated errors

To understand correlated errors, it’s best to visualize and compare them to independent errors. To do this, please create 2 plots: one with correlated errors and one with independent errors.

Question 2, comment on the difference

According to the plots you’ve created, please answer the following:

Question 3, how correlated errors affect OLS

Please simulate data from the usual linear model \(Y_i = X_i\beta + \epsilon_i\), except that \(\epsilon\) are now generated from your correlated function. Let the non-constant column in \(X\) be evenly spaced values between 0 and 10 in increments of 0.02 (inclusive of bounds, this implies the n). Set \(\beta = \binom{1}{2}\). You should assume that at each value of \(X_i\), we only observe one \(Y_i\)

For each dataset generated, please fit the ordinary linear regression (OLS i.e. lm()) and store:

Please create 1000 simulated datasets and estimate real the mean and SE of the regression coefficients.

Do the mean and SE based on the simulated values “overall agree” with the values from summary.lm()? Please explain your answer with a graph.

Question 4

Repeat the steps above but replace the OLS with different versions of ARIMA:

Question 5

Which of our usual regression conditions are satisfied in our simulation above?