Sorry to bother u again, and thanx a lot for ur help. I understood the above problem and I was able to fix it, now I did a little adjustment on the codes and the loop doesn't end, here are the new codes: proc iml; n=3; p=2; m=10; k=1; nruns=10000; yvec=0; avrlvec=0; sigma=1; T=n*(k+m); x1={1,4,3}; x2={2,3,5}; xp={1 2,4 3,3 5}; l=j(n,1,1); x=l||x1||x2; x11=repeat(x1,(m+k)); x22=repeat(x2,(m+k)); i=j(T,1,1); xx=i||x11||x22; z=T({ [30] 0 [3] 1}); z0=z#i; zx1=z#x11; zx2=z#x22; xxf=i||z0||x11||zx1||x22||zx2; beta0=1; beta1=2; beta2=3; alpha=0.05; alpha1=1-(1-alpha)**2/3; df1=p+1; df2=T-2*(p+1); fdis=finv((1-alpha),df1,df2); shiftvec={0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5}; nshf=nrow(shiftvec); do k=1 to nshf; shift=shiftvec[k,]; c=0; do i=1 to nruns; yvec=0; do i=1 to m; epslon1=sigma* normal(repeat(-1,n)); y=beta0+(beta1)*x1+(beta2)*x2+epslon1; yvec=yvec//y; xty=T(x)*y; beta=inv(T(x)*x)*xty; yhat=x*beta; msej=ssq(y-yhat)/(n-p); msec=msec//msej; end; yvec1=yvec; mse=sum(msec)/m; arl=0; ftest=0; do until (ftest>fdis); yvec1=yvec; epslon=sigma* normal(repeat(-1,n)); y1=beta0+(beta1+shift)*x1+(beta2)*x2+epslon; yvec1=yvec1//y1; bhatr=inv(T(xx)*xx)*T(xx)*yvec1[2:34,]; yhatr=xx*bhatr; err=yvec1[2:34,]-yhatr; sser=T(err)*err; bhatf=inv(T(xxf)*xxf)*T(xxf)*yvec1[2:34,]; yhatf=xxf*bhatf; erf=yvec1[2:34,]-yhatf; ssef=T(erf)*erf; msef=T(erf)*erf/(T-2*(p+1)); ftest=(sser-ssef)/((p+1)*msef); arl=arl+1; numb=nrow (yvec1); end; c=c+arl; end; avrl=c/nruns; avrlvec=avrlvec//avrl; end; print yvec1 avrlvec ftest fdis msef numb shift ; quit;
... View more