Use your computer to generate a sequence of T = 100 i.i.d. standard normal random variables. Call these variables e1, e2, c, e100. Set Y1 = e1 and Yt = Yt - 1 + et for t = 2, 3, c, 100.

rand_data <- sample(0:100,100,rep=TRUE)
rand_data
  [1] 13 30 86 78 44 64 31 38 39  7 53 75 79 18 75 69 57 90 36 99 63 54 49 76 24 32 18  5 20 22 40
 [32] 17 46 85 81 24 62 75 51 98 11  1 50 14 94 33 32 85 54 96 54 26 19  4 67 57  1  2 95 12 61 31
 [63] 77 52 30 66 97 36 50 30 46 34 16 97  1 48 51 65 98 95 91 14  9 10 10 99 49 82 31 80 38 90 64
 [94] 75 57  3 12 96 18 27
  1. Use your computer to generate a new sequence, a1, a2, c, a100, of T = 100 i.i.d. standard normal random variables. Set X1 = a1 and Xt = Xt - 1 + at for t = 2, 3, c, 100.
rand_data_2 <- sample(0:100,100,rep=TRUE)
rand_data_2
  [1] 40 58 46 18 69 56 72 10 88 11  3 79 23  2  2 11 39 30 42 80 82 98 72 23 72 45 55 90  7 33 20
 [32]  1 36 82  1 88 74 21 91 74  6 19 97 25  6 11 56 54 44 87 60 18 64 53 76 39 47 71 31 87 29 27
 [63] 50 13 92 41 17 92 83 81 63 11 99 73 34  4 14 38 99 97 17 57 47 28 88 35 17 24 24 88 12 51 42
 [94] 45 95 98 71 18 53 56
  1. Regress Yt onto a constant and Xt. Compute the OLS estimator, the regression R2, and the (homoskedastic-only) t-statistic testing the null hypothesis that b1 (the coefficient on Xt) is zero.

Use this algorithm to answer the following questions: a. Run the algorithm (i) through (iii) once. Use the t-statistic from (iii) to test the null hypothesis that b1 = 0, using the usual 5% critical value of 1.96. What is the R2 of your regression?

Repeat (a) 1000 times, saving each value of R2 and the t-statistic. Construct a histogram of the R2 and t-statistic. What are the 5%, 50%, and 95% percentiles of the distributions of the R2 and the t-statistic?

In what fraction of your 1000 simulated data sets does the t-statistic exceed 1.96 in absolute value?

  1. Repeat (b) for different numbers of observations, such as T = 50 and T = 200. As the sample size increases, does the fraction of times that you reject the null hypothesis approach 5%, as it should because you have generated Y and X to be independently distributed? Does this fraction seem to approach some other limit as T gets large? What is that limit?
LS0tCnRpdGxlOiAiU1MxNTQgLSAxMC4yIgpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgpVc2UgeW91ciBjb21wdXRlciB0byBnZW5lcmF0ZSBhIHNlcXVlbmNlIG9mIFQgPSAxMDAgaS5pLmQuIHN0YW5kYXJkIG5vcm1hbCByYW5kb20gdmFyaWFibGVzLiBDYWxsIHRoZXNlIHZhcmlhYmxlcyBlMSwgZTIsIGMsIGUxMDAuIFNldCBZMSA9IGUxIGFuZCBZdCA9IFl0IC0gMSArIGV0IGZvciB0ID0gMiwgMywgYywgMTAwLiAKYGBge3J9CnJhbmRfZGF0YSA8LSBzYW1wbGUoMDoxMDAsMTAwLHJlcD1UUlVFKQpyYW5kX2RhdGEKYGBgCmlpLiBVc2UgeW91ciBjb21wdXRlciB0byBnZW5lcmF0ZSBhIG5ldyBzZXF1ZW5jZSwgYTEsIGEyLCBjLCBhMTAwLCBvZiBUID0gMTAwIGkuaS5kLiBzdGFuZGFyZCBub3JtYWwgcmFuZG9tIHZhcmlhYmxlcy4gU2V0IFgxID0gYTEgYW5kIFh0ID0gWHQgLSAxICsgYXQgZm9yIHQgPSAyLCAzLCBjLCAxMDAuIApgYGB7cn0KcmFuZF9kYXRhXzIgPC0gc2FtcGxlKDA6MTAwLDEwMCxyZXA9VFJVRSkKcmFuZF9kYXRhXzIKYGBgCmlpaS4gUmVncmVzcyBZdCBvbnRvIGEgY29uc3RhbnQgYW5kIFh0LiBDb21wdXRlIHRoZSBPTFMgZXN0aW1hdG9yLCB0aGUgcmVncmVzc2lvbiBSMiwgYW5kIHRoZSAoaG9tb3NrZWRhc3RpYy1vbmx5KSB0LXN0YXRpc3RpYyB0ZXN0aW5nIHRoZSBudWxsIGh5cG90aGVzaXMgdGhhdCBiMSAodGhlIGNvZWZmaWNpZW50IG9uIFh0KSBpcyB6ZXJvLiAKCl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