*! Version 1.0.0 (09/23/02), G. R. Frechette program define superxt, eclass version 7.0 if replay() { if "`e(cmd)'" ~= "xt$cmd" { error 301 } else Replay `0' } else StandardSyntax `0' end program define StandardSyntax, eclass global cmd "`1'" macro shift 1 local therest "`*'" Estimate `therest' end program define Estimate, eclass syntax varlist [if] [in] [, I(varname) Quadrat(int 12) Rho(real 0.5) type(int 1) /* */ Level(passthru) *] quietly { tempname foo b lnsig2u b1 tempvar foo bar baz if `type' == 1 { /* start with default xt command */ noisily di in ye _n `"STEP 1"' noisily di in gr _n `"now estimating:"' noisily di in gr _n `"xt$cmd `varlist' `if' `in', i(`i')"' xt$cmd `varlist' `if' `in', i(`i') quad(12) nolog `options' mat `foo' = e(V)*e(b)' svmat `foo' egen `bar' = min(`foo'1^2) if `bar' == 0 { noisily di in ye _n `"STEP 2"' noisily di in re _n `"the command did not converge, bad Stata!"' noisily di in gr _n `"now attempting the same as the above except the starting value"' noisily di in gr _n `"is now set to the coefficient estimate of $cmd and rho = `rho'"' drop `foo'1 `bar' $cmd `varlist' `if' `in', `options' mat `b' = e(b) mat `lnsig2u' = ln(`rho'/(1-`rho')) mat `b1' = [`b', `lnsig2u'] xt$cmd `varlist' `if' `in', i(`i') quad(12) from(`b1', copy) `options' mat `foo' = e(V)*e(b)' svmat `foo' egen `bar' = min(`foo'1^2) if `bar' == 0 { noisily di in ye _n `"STEP 3"' noisily di in re _n `"the command did not converge, bad Stata!"' noisily di in gr _n `"now attempting"' noisily di in gr _n `"xt$cmd `varlist' `if' `in', i(`i') quad(23)"' drop `foo'1 `bar' xt$cmd `varlist' `if' `in', i(`i') quad(23) `options' mat `foo' = e(V)*e(b)' svmat `foo' egen `bar' = min(`foo'1^2) if `bar' == 0 { noisily di in ye _n `"STEP 4"' noisily di in re _n `"the command did not converge, bad Stata!"' noisily di in gr _n `"now attempting the same as the above except the starting value"' noisily di in gr _n `"is now set to the coefficient estimate of $cmd and rho = `rho'"' drop `foo'1 `bar' $cmd `varlist' `if' `in', `options' mat `b' = e(b) mat `lnsig2u' = ln(`rho'/(1-`rho')) mat `b1' = [`b', `lnsig2u'] xt$cmd `varlist' `if' `in', i(`i') quad(23) from(`b1', copy) `options' mat `foo' = e(V)*e(b)' svmat `foo' egen `bar' = min(`foo'1^2) if `bar' == 0 { noisily di in ye _n `"STEP 5"' noisily di in re _n `"the command did not converge, bad Stata!"' noisily di in gr _n `"now attempting"' noisily di in gr _n `"xt$cmd `varlist' `if' `in', i(`i') quad(30)"' drop `foo'1 `bar' xt$cmd `varlist' `if' `in', i(`i') quad(30) `options' mat `foo' = e(V)*e(b)' svmat `foo' egen `bar' = min(`foo'1^2) if `bar' == 0 { noisily di in ye _n `"STEP 6 (final)"' noisily di in re _n `"the command did not converge, bad Stata!"' noisily di in gr _n `"now attempting the same as the above except the starting value"' noisily di in gr _n `"is now set to the coefficient estimate of $cmd and rho = `rho'"' drop `foo'1 `bar' $cmd `varlist', `if' `in' `options' mat `b' = e(b) mat `lnsig2u' = ln(`rho'/(1-`rho')) mat `b1' = [`b', `lnsig2u'] xt$cmd `varlist' `if' `in', i(`i') quad(30) from(`b1', copy) `options' mat `foo' = e(V)*e(b)' svmat `foo' egen `bar' = min(`foo'1^2) if `bar' == 0 { noisily di in re _n `"failure to converge on all tries, quitting"' } else noisily Replay, `level' } else noisily Replay, `level' } else noisily Replay, `level' } else noisily Replay, `level' } else noisily Replay, `level' } else noisily Replay, `level' } else if `type' == 2 { noisily di in gr _n `"now estimating:"' noisily di in gr _n `"xt$cmd `varlist' `if' `in', i(`i') quad(`quadrat')"' noisily di in gr _n `"starting from the coefficient estimate of $cmd and rho = `rho'"' $cmd `varlist' `if' `in', `options' mat `b' = e(b) mat `lnsig2u' = ln(`rho'/(1-`rho')) mat `b1' = [`b', `lnsig2u'] xt$cmd `varlist' `if' `in', i(`i') quad(`quadrat') from(`b1', copy) `options' mat `foo' = e(V)*e(b)' svmat `foo' egen `bar' = min(`foo'1^2) if `bar' == 0 { noisily di in re _n `"failure to converge"' } else noisily Replay, `level' } else noisily di in re _n `"no such type, type should be set to 1 or 2"' } end program define Replay syntax [, Level(int $S_level)] `e(cmd)', level(`level') end