Two unrelated comments:
1. You can improve the efficiency of the WHITE function by using elementwise multiplication of vectors instead of DO loops when you form the quadratic interaction terms:
X1_carré = X[,1] # X[,1];
X2_carré = X[,2] # X[,2];
X3_carré = X[,3] # X[,3];
X4_carré = X[,4] # X[,4];
X1X2_carré = X[,1] # X[,2];
X1X3_carré = X[,1] # X[,3];
X1X4_carré = X[,1] # X[,4];
X2X3_carré = X[,2] # X[,3];
X2X4_carré = X[,2] # X[,4];
X3X4_carré = X[,3] # X[,4];
XW = X||X1_carré||X2_carré||X3_carré||X4_carré||X1X2_carré||X1X3_carré||X1X4_carré||X2X3_carré||X2X4_carré||X3X4_carré;
2. You can put the allocations and the call to RANDSEED outside of the loop:
call randseed(2);
N = 500;
A = j(N,4); y = j(N,1);
B = j(4,1);
e = j(nrow(X),1);
numSamples = 10;
stat = j(numSamples,1,.); /* allocate result vector */
do i = 1 to 10; /* Theoritically -------> Starting DO Loop here */
...
stat[i] = White(X,Y);
end;
... View more