'Program for OLS reduction 'by Freddy Rojas 'Universidad de Chile 'e-mail: frojasca@gmail.com 'last up date 09/25/2011 subroutine ols_reduction MODE VER4 '--------------------------------------------------------------------------------- 'dependent serie '%0="d(ltcr_m)" '%0="serie1" 'Series in the right side '%x1="resids_hat" '%x2="serie1" 'lags '!nr=10 'number of lags of variables in the right side '!nc=2 'number of variables in the right side '!ndum=0 'number of dummies, it must be less than !nr '!nt=0 'put 1 if you want to include contemporaneous serie 'dummies '%xd1="dum0101" '%xd2="dum0190" '%xd3="dum0499" '%xd4="dum8903" '%xd5="dum9301" '%xd6="dum9901" '%xd7="resid_arch1" 'significance level '!nsig=0.045 '------------------------------------------------------------------------------------ matrix(!nr+!nt,!nc+1) bv=NA for !c=1 to @columns(bv)-1 for !b=1 to @rows(bv) bv(!b,!c)=!b-!nt next next matrix(!nr+!nt,!nc+1) bv for !b=1 to !ndum bv(!b,!nc+1)=!b next !pc=0 !pr=0 !j=0 !q=0 for !rep=1 to (!nr+!nt)*!nc+!ndum %xreg=" " matrix df=bv for !x=1 to !nc for !s=1-!nt to !nr !bv_aux=df(!s+!nt,!x) if !bv_aux <> NA and !x<=9 then %xreg=%xreg+" %x"+@str(!x)+"(-"+@str(!s)+")" endif if !bv_aux <> NA and !x>9 then %xreg=%xreg+" %xx"+@str(!x)+"(-"+@str(!s)+")" endif next next for !b=1 to !nr+!nt if bv(!b,!nc+1) <> NA then %xreg=%xreg+" %xd"+@str(!b) endif next equation ols_aux.ls(n) %0 c {%xreg} show ols_aux !i=2 matrix(!nr+!nt,!nc+1) pvalue_ols for !x=1 to !nc+1 for !s=1 to !nr+!nt if df(!s,!x) <> NA then pvalue_ols(!s,!x)=2*(1-@ctdist(@abs(ols_aux.@coefs(!i)/ols_aux.@stderrs(!i)),@regobs-((!nr+!nt)*!nc+1+!ndum-!j))) !i=!i+1 else df(!s,!x)=NA pvalue_ols(!s,!x)=NA endif next next !max_p=@max(pvalue_ols) for !x=1 to !nc+1 for !s=1 to !nr+!nt if pvalue_ols(!s,!x)=!max_p and !max_p>!nsig then bv(!s,!x)=NA if !x=!nc+!ndum then !ndum=!ndum endif !pr=!s !pc=!x endif next next !j=!j+1 if !max_p