function alphahat = hw9(alpha,T,J); % hw9.m % simulates J draws for alpha-hat, given alpha and T alphahat = NaN*ones(J,1); y=NaN*ones(T,1); for j=1:J, y(1,1) = 0; for t=2:T, y(t,1) = alpha*y(t-1,1) + randn; end; yt = y(2:T,1); ylag = y(1:T-1,1); alphahat(j,1) = (yt'*ylag)/(ylag'*ylag); end;