SET NOECHO PROC OLS * THIS PROC WILL PRODUCE THE SAME OUTPUT AS THE SHAZAM OLS COMMAND SET NODOECHO COPY [DEPVAR] Y_ * DEFINE THE VECTOR OF ONES AS BELOW TO GET THE DIMENSIONS RIGHT MATRIX ONE_=Y_-Y_+1 GEN1 N_=\$ROWS COPY [INDEPS] ONE_ X_ SAMPLE 1 N_ MATRIX B_=INV(X_'X_)*X_'Y_ GEN1 K_=\$ROWS MATRIX YHAT_=X_*B_ MATRIX E_=Y_-YHAT_ MATRIX SSE_=E_'E_ GEN1 DF_=N_-K_ MATRIX SIG2_=SSE_/DF_ * COMPUTE Y'Y IN DEVIATIONS FROM MEAN, THIS REQUIRES THE A MATRIX, THEIL 4.2 MATRIX A_=IDEN(N_)-(1/N_)*(ONE_*ONE_') * DO ANOVA STUFF FROM MEAN MATRIX SST_=Y_'A_*Y_ MATRIX SSR_=SST_-SSE_ MATRIX R2_=1-SSE_/SST_ MATRIX KM1_=K_-1 MATRIX NM1_=N_-1 MATRIX R2ADJ_=1-(NM1_/DF_)*(1-R2_) MAT SIGMA_=SQRT(SIG2_) MAT YMEAN_=Y_'ONE_/N_ MATRIX MST_=SST_/NM1_ MAT SIGML_=SSE_/N_ MAT LLF_=-(N_/2)*LOG(2*3.14159*SIGML_)-(N_/2) PRINT N_ R2_ R2ADJ_ SIG2_ SIGMA_ SSE_ YMEAN_ LLF_ * DO THE MODEL SELECTION TESTS GEN1 FPE_=SIG2_*(1+K_/N_) GEN1 LOGAIC_=LOG(SIGML_)+2*K_/N_ GEN1 LOGSC_=LOG(SIGML_)+K_*LOG(N_)/N_ GEN1 GCV_=SIGML_*(1-K_/N_)**(-2) GEN1 HQ_=SIGML_*LOG(N_)**(2*K_/N_) GEN1 RICE_=SIGML_/(1-2*K_/N_) GEN1 SHIBATA_=SIGML_*(N_+2*K_)/N_ GEN1 SC_=SIGML_*N_**(K_/N_) GEN1 AIC_=SIGML_*EXP(2*K_/N_) PRINT FPE_ LOGAIC_ LOGSC_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 STANDB_ ELAS_ VB_ * RESIDUALS *PRINT Y_ YHAT_ E_ * DURBIN-WATSON * NEED TO GENERATE THE DW A MATRIX AS SHOW IN THE SHAZAM MANUAL * PROGRAMMING EXAMPLE FOR THE EXACT DW TEST GENR D_=2 SAMPLE 1 1 GENR D_=1 SAMPLE N_ N_ GENR D_=1 SAMPLE 1 N_ MATRIX A_=IDEN(N_,2) MATRIX A_=-(A_+A_')+DIAG(D_) MATRIX DW_=(E_'A_*E_)/SSE_ MATRIX VN_=DW_*(N_/NM1_) * NOW WE NEED AN A MATRIX THAT WILL GENERATE RHO ?DELETE A_ MAT A_=IDEN(N_,2) MAT RHO_=(E_'A_*E_)/(SSE_ - ((E_(N_))**2) ) MAT ESUM_=E_'ONE_ MAT EABS_=ABS(E_)'ONE_ * NEED THE DEVIATION A MATRIX AGAIN FOR Y AND YHAT MATRIX A_=IDEN(N_)-(1/N_)*(ONE_*ONE_') MAT R2OP_=(YHAT_'A_*Y_)**2/((YHAT_'A_*Y_)*(Y_'A_*Y_)) PRINT DW_ VN_ RHO_ ESUM_ SIG2_ EABS_ R2OP_ * NOW FOR THE RUNS TEST MAT DUME_=DUM(E_) MAT N1_=DUME_'ONE_ MAT N2_=DUM(-E_)'ONE_ MAT EN_=(2*N1_*N2_)/(N1_+N2_) +1 *PRINT EN_ MAT SN_=SQRT((2*N1_*N2_*(2*N1_*N2_-N1_-N2_))/((N1_+N2_)**2*(N1_+N2_-1))) *PRINT SN_ * GET THE NUMBER OF RUNS SAMPLE 2 N_ GENR DIFF_=DUME_.NE.LAG(DUME_) SAMPLE 1 N_ MATRIX NRUNS_=DIFF_'ONE_ +1 MAT NORMSTA_=(NRUNS_-EN_)/SN_ PRINT NRUNS_ N1_ N2_ NORMSTA_ * NOW FOR THE SKEWNESS AND KURTOSIS MATRIX S1_=E_'ONE_/N_ MATRIX S2_=(E_**2)'ONE_/N_ MATRIX S3_=(E_**3)'ONE_/N_ MATRIX S4_=(E_**4)'ONE_/N_ GEN1 M2_=S2_-S1_**2 GEN1 M3_=S3_-3*S1_*S2_+2*S1_**3 GEN1 M4_=S4_-4*S1_*S3_+6*S1_**2*S2_-3*S1_**4 GEN1 K2_=N_*M2_/(N_-1) GEN1 K3_=N_**2*M3_/((N_-1)*(N_-2)) GEN1 K4_=N_**2*((N_+1)*M4_-3*(N_-1)*M2_**2)/((N_-1)*(N_-2)*(N_-3)) GEN1 G1_=K3_/(K2_**1.5) GEN1 G2_=K4_/(K2_**2) GEN1 SG1_=SQRT(6*N_*(N_-1)/((N_-2)*(N_+1)*(N_+3))) GEN1 SG2_=SQRT(24*N_*(N_-1)**2/((N_-3)*(N_-2)*(N_+3)*(N_+5))) PRINT G1_ SG1_ G2_ SG2_ * THE ONLY THING MISSING IS THE CHI-SQUARE GOODNESS OF FIT TEST * NOT DONE HERE BECAUSE IT IS DIFFICULT TO GET RESIDUALS IN GROUPS DELETE / ALL_ SET DOECHO PROCEND SET ECHO