*! version 1.0.1 08may1996 program define svytest version 4.0 if "`*'"=="" { error 198 } if substr("$S_E_cmd",1,3)!="svy" { error 301 } capture di matrix(S_E_b[1,1]) if _rc==0 { di in red "must run svy command with " _quote "complete" /* */ _quote " option before using this command" exit 301 } parse "`*'", parse(",") if "`1'"=="," { local options "Accumulate noTest noADJust BONferroni" parse "`*'" if "`accumul'`test'`adjust'"!="" { di in red "coefficient list or equation required" exit 100 } } else { local tlist "`1'" if "`2'"=="," { local options "Accumulate noTest noADJust BONferroni" parse ",`3'" } capture unabbrev `tlist' if _rc==0 { local tlist "$S_1" } } if "`bonferr'"!="" { if "`accumul'"!="" { di in red "accumulate option not allowed with " /* */ "bonferroni option" exit 101 } if "`test'"!="" { di in red "notest option not allowed with " /* */ "bonferroni option" exit 101 } if "`adjust'"!="" { di in red "noadjust option not allowed with " /* */ "bonferroni option" exit 101 } if "$S_E_cmd"!="svyreg" & "$S_E_cmd"!="svylogit" /* */ & "$S_E_cmd"!="svyprobt" { di in red "bonferroni option only allowed after " /* */ "svyreg, svylogit, or svyprobt" exit 101 } Bonferr `tlist' exit } if "`test'"=="notest" { test `tlist', `accumul' notest exit } if "`adjust'"!="" { di _n in gr "Unadjusted Wald test" test `tlist', `accumul' global S_1 = _result(3) global S_2 = _result(5) global S_3 = _result(6) exit } di _n in gr "Adjusted Wald test" test `tlist', `accumul' notest capture test `tlist', `accumul' local mdf = _result(3) if _rc | `mdf'==. { test `tlist', `accumul' exit } local df = $S_E_npsu - $S_E_nstr - `mdf' + 1 tempname f scalar `f' = `df'*_result(6)/($S_E_npsu - $S_E_nstr) di _n in gr _col(8) "F(" in ye %3.0f `mdf' in gr "," in ye %6.0f /* */ `df' in gr ") = " in ye %7.2f `f' _n in gr _col(13) "Prob > F = " /* */ in ye %9.4f fprob(`mdf',`df',`f') global S_1 "`mdf'" global S_2 "`df'" global S_3 = `f' end program define Bonferr version 4.0 tempname b V max matrix `b' = get(_b) matrix `V' = get(VCE) if "`*'"!="" { local nterm : word count `*' } else { local colname : colnames(`b') local nterm = colsof(`b') parse "`colname'", parse(" ") if "``nterm''"=="_cons" { local nterm = `nterm' - 1 } } scalar `max' = 0 local j 1 while `j' <= `nterm' { local i = colnumb(`b',"``j''") if `i'==. { di in red "``j'' not found" exit 111 } if `V'[`i',`i'] == 0 { di in red "covariance is singular; cannot perform test" exit 504 } if abs(`b'[1,`i']/sqrt(`V'[`i',`i'])) > `max' { scalar `max' = abs(`b'[1,`i']/sqrt(`V'[`i',`i'])) local imax "`i'" } local `j' "`i'" local j = `j' + 1 } global S_1 "`nterm'" global S_2 = $S_E_npsu - $S_E_nstr global S_3 = `max' di _n in gr "Bonferroni adjustment for " in ye "`nterm'" /* */ in gr " comparisons"_n DashLine Colhead DashLine 10 local j 1 while `j' <= `nterm' { Body ``j'' `b' `V' `imax' `nterm' local j = `j' + 1 } DashLine end program define DashLine version 4.0 if "`1'"=="" { di in gr _dup(78) "-" exit } local dash1 = `1' - 1 local dash2 = 78 - `1' di in gr _dup(`dash1') "-" "+" _dup(`dash2') "-" end program define Colhead version 4.0 local head " Coef. Std. Err." local head "`head' t Adj. P" local col = 9 - length("$S_E_depv") di in gr _col(`col') "$S_E_depv |" "`head'" end program define Body version 4.0 local i "`1'" local b "`2'" local V "`3'" local imax "`4'" local nterm "`5'" if `i'==`imax' { local star "*" } local colname : colnames(`b') local coli : word `i' of `colname' local col = 9 - length("`coli'") di in gr _col(`col') "`coli' |" /* */ in ye _s(2) %9.0g `b'[1,`i'] _s(3) %9.0g sqrt(`V'[`i',`i']) /* */ _s(3) %8.3f `b'[1,`i']/sqrt(`V'[`i',`i']) %10.4f /* */ min(1,`nterm'*tprob($S_E_npsu-$S_E_nstr, /* */ `b'[1,`i']/sqrt(`V'[`i',`i']))) in gr " `star'" end