Dear All, I was trying to run this and I got this for the 3 matrices created "(Execution) Matrices has not been set a value"; proc iml; *part a; n = 10; x1 = j(10,1,1); x2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; x = x1 || x2; M = 1000; B10 = j(M,1,0); T10 = j(M,1,0); title "Answer to part a"; print x1 x2 x M B10 T10; *part b; u = j(n,1,0); Btot = {1, 2}; Var = {2}; *part c; do i = 1 to M; call randgen(u,"normal",0,Var); y = (x*BTot) + u; b = inv((x`) * x) * (x`) * y; e = y - (x*b); b2 = b[2,1]; B10[i,] = b2; B2 = Btot[2,1]; se2 = ((e`) * e) * (1/(n - 2)); varb2 = s2 * b2; seb2 = sqrt(varb2); t2 = (b2 - B2) * (1/seb2); T10[i,] = t2; end; *part d; n = 100; x_1 = j(100,1,1); x_2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 10); x = x_1 || x_2; M = 1000; B100 = j(M,1,0); T100 = j(M,1,0); u = j(n,1,0); Btot = {1, 2}; S = {2}; do i = 1 to M; call randgen(u,"normal",0,S); y = (x*B_pop) + u; b = inv((x`) * x) * (x`) * y; e = y - (x*b); b2 = b[2,1]; B100[i,] = b2; B2 = Btot[2,1]; se2 = ((e`) * e) * (1/(n - 2)); varb2 = se2 * b2; seb2 = sqrt(varb2); t2 = (b2 - B2) * (1/seb2); T100[i,] = t2; end; *part e; n = 1000; x1 = j(1000,1,1); x2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 100); x = x1 || x2; M = 1000; B1000 = j(M,1,0); T1000 = j(M,1,0); u = j(n,1,0); Btot = {1, 2}; Var = {2}; do i = 1 to M; call randgen(u,"normal",0,S); y = (x*Btot) + u; b = inv((x`) * x) * (x`) * y; e = y - (x*b); b2 = b[2,1]; B1000[i,] = b2; B2 = Btot[2,1]; se2 = ((e`) * e) * (1/(n - 2)); varb2 = se2 * b2; seb2 = sqrt(varb2); t2 = (b2 - B2) * (1/seb2); T1000[i,] = t_2; end;
... View more