Question: R Code requested. 4. Power of a test In this exercise we are going to simulate the power of a test. Consider the standard model

R Code requested.
4. Power of a test In this exercise we are going to simulate the power of a test. Consider the standard model Y =a +BX+u where Cov(x, U) = 0 and E[U21X] = 02. We know that the OLS estimator will be consistent and asymptotically normal: Bols N(B, AVar (BoLs)) where AV art Bous) = Varis (X) Suppose you want test the null hypothesis Ho : B = Bo vs the alternative H: B Bo for a given Bo. A common choice if to pick Bo = 0: X has no effect on E[Y|X]. We use a t-test, whose test statistic is BOLS - Bo Aar (BoLs) t = (a) Generate 1,000 different values of t using samples sizes of n = 100. To generate the data use a = B = 0. Also, let XN(0,1) and UN(0,1). To construct t set Bo = 0. Plot the density of the t statistics and overlay the density of a standard normal. Are they close to each other? Why or why not? (b) The t statistic you constructed corresponds to the test Ho : B = 0 vs the alternative Hq : B +0. We reject the null hypothesis if |:| > 1.96. In this case, if |t| > 1.96 we commit the so-called type I error: rejecting a true null hypothesis. Using the 1,000 different statistic, estimate the probability of type I error. Does it make sense? (C) If the true $ 0, then we should reject the null hypothesis Ho : B = 0. The probability of rejecting Ho : B = Bo when * Bo is called the power of the test. Again, generate 1,000 different values of using samples sizes of n = 100. This time, set Bo = 0 but = 0.1 in the data generating process. Note that the null hypothesis Ho : B = 0 is not true now. Plot the density of the t statistics and overlay the density of a standard normal. Estimate the probability of rejecting He: the probability that t > 1.96. Comment of the findings. Do they make sense? (d) Repeat the part (C), but for a grid B = -0.5, -0.4.... -0.1,0,0.1,..,0.5. Plot the rejection proba- bilities against B. The resulting curve is called the power of the test. Comment on its shape. Is it reasonable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
