*! version 3.2.1 12/20/94 (STB-25: sts10) program define prais version 4.0 local options "Level(int $S_level)" if substr("`1'",1,1)=="," | "`1'"=="" { if "$S_E_cmd"!="prais" { error 301 } parse "`*'" } else { local varlist "req ex min(2)" local in "opt" local options /* */ "`options' noLog TOl(real .001) Iterate(integer 100)" parse "`*'" tempfile PRASITR tempvar X RES LRES tempvar lest /* estimates */ if "`log'"!="" { local log "*" } else local log "noisily di" preserve quietly { keep `varlist' noisily confirm new var _iter if "`in'"!="" { keep `in' } save `PRASITR' , replace `log' in gr "Iteration 0: rho = " in ye "0.0000" regress `varlist' predict `RES', resid gen `LRES' = `RES'[_n-1] regress `RES' `LRES', nocons local rho = _b[`LRES'] local i "1" local lrho "2" use `PRASITR', clear while (`i' < `iterate' & abs(`rho'-`lrho')>`tol') { `log' in gr /* */ "Iteration `i': rho = " in ye %6.4f `rho' gen _iter = 1 - `rho' parse "`varlist'", parse(" ") while "`1'"!="" { gen float `X'=`1'-(`rho')*`1'[_n-1] replace `X' = sqrt(1-`rho'^2)*`1' in 1 drop `1' rename `X' `1' mac shift } regress `varlist' _iter, hascons use `PRASITR', clear gen _iter=1 predict `RES', resid gen `LRES' = `RES'[_n-1] local lrho "`rho'" capture estimates drop `lest' estimates hold `lest' regress `RES' `LRES', nocons local rho = _b[`LRES'] drop _iter `RES' `LRES' local i = `i' + 1 } local rho = _b[`LRES'] local serho= _se[`LRES'] local dof=_result(5) estimate unhold `lest' global S_E_rho `rho' global S_E_srho `serho' global S_E_dof `dof' global S_E_cmd "prais" } } if `level'<10 | `level'>99 { local level 95 } local trho = $S_E_rho/$S_E_srho local prho = tprob($S_E_dof,`trho') local invt = invt($S_E_dof,`level'/100) global S_1 $S_E_rho global S_2 $S_E_srho noisily di _n in gr "(Prais-Winsten regression)" noisily regress, level(`level') noisily di in gr /* */ " rho |" in ye " " %9.4f $S_E_rho /* */ " " %9.4f $S_E_srho %11.3f `trho' /* */ %8.3f `prho' /* */ " " %9.4f $S_E_rho-`invt'*$S_E_srho /* */ " " %9.4f $S_E_rho+`invt'*$S_E_srho /* */ _n /* */ in gr _dup(78) "-" end