SET NOECHO proc dwpvalue * CALCULATION OF A P-VALUE FOR THE DURBIN-WATSON TEST STATISTIC * Revision date: March 23, 1996 set nodoecho ?gen1 T_=$n SAMPLE 1 T_ genr one_=1 copy [X] one_ x_ / TROW=1;T_ * compute m matrix m_=iden(t_)-x_*inv(x_'x_)*x_' * generate the a matrix genr d_=2 if(time(0).eq.1) d_=1 if(time(0).eq.t_) d_=1 matrix a_=iden(t_,2) matrix a_=-(a_+a_')+diag(d_) * compute the eigenvalues of ma matrix ma_=m_*a_ matrix e_=eigval(ma_) * run ols just to get the dw statistic, it is stored in $dw ?ols [y] [x] / rstat ?gen1 ne_=$df ?gen1 dw_=$dw * use the distrib command to compute the exact dw probability ?dist dw_ / eigenval=e_ type=imhof neigen=ne_ ?gen1 pvalue_=$cdf print dw_ pvalue_ DELETE / ALL_ SET DOECHO PROCEND SET ECHO