Question
2. Assume the usual linear regression model with normal errors, Y = X + . (a) Suppose that there are n subjects and two numerical
2. Assume the usual linear regression model with normal errors, Y = X + .
(a) Suppose that there are n subjects and two numerical explanatory variables. Write an R function called gen X mat that randomly generates a design matrix X with n rows and 3 columns. In the ith row of the matrix, set xi,1 = 1 for the first element, and let (xi,2, xi,3) be a realization of Xi,2 = + Ai + Zi,2 Xi,3 = + Ai + Zi,3, where is a constant, A1, . . . , An are i.i.d. N(0, 2 X), and all Zi,j are i.i.d. N(0,(1 ) 2 X). The function gen X mat should take 2 arguments n, mu, sigma x, and rho and return a design matrix generated as specified.
(b) Suppose that p = 3, = [1, 1/2, 1/2]T , and = 3. Use simulations to find the number of subjects n such that the power of the test of H0 : 3 = 0 against HA : 3 6= 0 is roughly 85 % when a 4 % significance level is used. Consider the following to cases:
i. The design matrix is generated from the procedure described in part 2 (a) with = 70, X = 2, and = 0.5.
ii. The design matrix is generated from the procedure described in part 2 (a) with = 70, X = 2, and = 0.98.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started