program define bound version 2.1 mac def _varlist "req ex min(1)" mac def _if "opt" mac def _in "opt" parse "%_*" parse "%_varlist", parse(" ") mac def _lhs "%_1" mac shift mac def _rhs "%_*" qui reg %_lhs %_rhs %_if %_in predict double _hat, hat predict double rstu, rstudent predict cook, cook mac def _NUMw=_result(1) mac def _DFNc=_result(3) mac def _DFNw=(_result(3)+1) gen double _dffits=sqrt(_hat/(1-_hat))*rstu mac def _subt=%_NUMw-%_DFNc-1 #del ; gen _ld=%_NUMw*log((%_NUMw/(%_NUMw-1))*((%_NUMw-%_DFNw-1)/ (rstu*rstu+%_NUMw-%_DFNw-1)))+ ((rstu*rstu*(%_NUMw-1))/((1-_hat)*(%_NUMw-%_DFNw-1)))-1 ; #del cr gen covratio=1/((((%_subt-1)/%_subt)+((rstu^2)/%_subt))^(%_DFNc+1)*(1-_hat)) di "" di "Some Regression Diagnostics" dbeta %_lhs %_rhs %_if %_in, gen(_dfbeta) mac def _dfc=2/sqrt(%_NUMw) mac def _hac=(3*%_DFNc)/%_NUMw mac def _wc=2*sqrt((%_DFNc+1)/%_NUMw) mac def _covc=(3*(%_DFNc+1))/%_NUMw gen _cuts=0 #del ; replace _cuts=1 if (cook>1 & cook~=.) | (abs(rstu)>2 & rstu~=.) | (_hat>%_hac & _hat~=.) | (abs(_dfbeta)>%_dfc & _dfbeta~=.) | (abs(_dffits)>%_wc & _dffits~=.) | (abs(covratio-1)>%_covc & covratio~=.) | chiprob(%_DFNw,_ld)<.10 ; #del cr gen _ldp=1-chiprob(%_DFNw,_ld) if "%_if"~="" { mac def _if2="%_if & _cuts==1" } else { mac def _if2="if _cuts==1" } di "covratio is measure of influence of observation on covariance matrix" di "_ld is measure of influence of observation on the likelihood (b AND s^2)" di "_ld is distributed approx. as chi-square with df=# of IV's w/constant" di "_ldp is the 'probability value' indicating that the removal of the" di " case in question will displace the estimate the edge of an x%" di " confidence region, where 'x'=value in table; thus, HIGH %'s sig." di "" #del ; di "dfbeta cut=" %6.4f %_dfc _sk(2) "dffits cut=" %6.4f %_wc _sk(2) "hat cut=" %6.4f %_hac _sk(2) "covratio cut=1 +/- " %6.4f %_covc ; #del cr format _dfbeta _dffits cook _hat rstu %7.3f format covratio %8.4f format _ld _ldp %6.3f li _dfbeta _dffits cook _hat rstu covratio _ld _ldp %_if2 %_in, nodis gen double _wght=1 replace _wght=.34/abs(_dffits) if abs(_dffits)>.34 reg %_lhs %_rhs %_if %_in =_wght end