Statistical programming, matrix languages, and more

Execution Matrices has not been set a value

Reply
Occasional Contributor
Posts: 10

Execution Matrices has not been set a value

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;

Grand Advisor
Posts: 16,367

Re: Execution Matrices has not been set a value

Can you narrow it down to which part of your code is generating the error? And including the log is helpful as well. 

 

 


Mike7 wrote:

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;




Occasional Contributor
Posts: 10

Re: Execution Matrices has not been set a value

its generating errors in the three parts, when trying to create T10, T100, and T1000

 

Its telling me that the matric has not been set a value; however I tried setting a value in the beginning but did not work

Grand Advisor
Posts: 16,367

Re: Execution Matrices has not been set a value

That's not what it's saying. Read the error thoroughly and fix what it indicates is the error. 

FYI it's a typo.

Occasional Contributor
Posts: 10

Re: Execution Matrices has not been set a value

I fixed the Typo, but still getting errors for T10 T100 T1000

Grand Advisor
Posts: 16,367

Re: Execution Matrices has not been set a value

Out of curiosity how am I supposed to have any idea of either what the error or your code looks like now? 

 

Post your modified code AND log with errors. 

Occasional Contributor
Posts: 10

Re: Execution Matrices has not been set a value

i fixed the typo but i am having problems with another error

(execution) Invalid subscript or subscript out of range

Grand Advisor
Posts: 9,332

Re: Execution Matrices has not been set a value

 

83         varb2 = s2 * b2;
 84         seb2 = sqrt(varb2);
 85         t2 = (b2 - B2) * (1/seb2);
 86         T10[i,] = t2;
 87         end;
 ERROR: (execution) Matrix has not been set to a value.
 
  operation : * at line 83 column 12
  operands  : s2, b2
 
 s2      0 row       0 col     (type ?, size 0)

According to LOG, it said you did not define s2 before . I think s2 should be se2 ?

 

 

Grand Advisor
Posts: 9,332

Re: Execution Matrices has not been set a value

Also you do not define B_pop  ,are supposed to be Btot

t_2 is supposed to be t2?

 

 


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 = se2 * 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*Btot) + 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,] = t2;
end;
quit;

 

 

 

Grand Advisor
Posts: 16,367

Re: Execution Matrices has not been set a value

@Ksharp and here I was trying to let 'Mike' do his own homework Smiley Wink

Post a Question
Discussion Stats
  • 9 replies
  • 87 views
  • 2 likes
  • 3 in conversation