*! version 1.0 (STB-54 dm73.1) /* Direct comments to: John Hendrickx Nijmegen Business School University of Nijmegen P.O. Box 9108 6500 HK Nijmegen The Netherlands Desmat is available at http://baserv.uci.kun.nl/~johnh/desmat/stata/ Version 1.0, October 27 1999 Program to be used in conjuction with desmat. Arguments are a list of model terms to be tested. If no arguments are specified, all terms are tested. An option "joint" can be specified to test for the joint siginficance of all model terms. An option "equal" can be specified to test for equality among the model terms. */ program define destest version 6.0 * get the arguments and the options, watch out in case no arguments are * specified tokenize "`0'", parse(",") if "`1'" == "," { local opts `2' } else { local args `1' local opts `3' } * option "equal" is passed on to testparms, tests for equality * option "joint" indicates that the joint significance of the terms is * to be tested * Only the first letter is significant in both cases tokenize "`opts'" while "`1'" ~= "" { if substr(lower("`1'"),1,1) == "e" { local eq="`1'" } if substr(lower("`1'"),1,1) == "j" { local joint="`1'" } macro shift } * change any asterisks in the argument list to periods local alltrms: subinstr local args "*" ".", all * if no arguments are specified, test all terms if "`alltrms'" == "" { local i 1 local termcnt="${term`i'}" if "`termcnt'" ~= "" { display "Testing all model terms ..." _newline } while "`termcnt'" ~= "" { tokenize "`termcnt'", parse("-") local varn="``1'[varn]'" if "`joint'" ~= "" { local jtest "`jtest' `termcnt'" } else { dotest `varn' `termcnt' `3' `eq' } local i=`i'+1 local termcnt="${term`i'}" } } else { tokenize "`alltrms'" local term `1' while "`term'" ~= "" { macro shift local alltrms `*' * find contents of term local i 1 local tryterm="${term`i'}" local termcnt="" while "`tryterm'" ~= "" & "`termcnt'" == "" { tokenize "`tryterm'", parse("-") local varn="``1'[varn]'" if "`term'" == "`varn'" { local lastvar="`3'" local termcnt="`tryterm'" } local i=`i'+1 local tryterm="${term`i'}" } if "`joint'" ~= "" { display "Including `term'" local jtest "`jtest' `termcnt'" } else { dotest `term' `termcnt' `lastvar' `eq' } tokenize `alltrms' local term `1' } } if "`joint'" ~= "" { display "Test of joint siginficance:" testparm `jtest', `eq' } end program define dotest args term termcnt lastvar eq if "`termcnt'" == "" { display "Can't find dummies for test of `term'" } else { if "`lastvar'" == "" { * don't test for equality of a single variable, even if requested capture testparm `termcnt' } else { capture testparm `termcnt', `eq' } * "capture" preceding testparm plows ahead even if the variables in * question have been dropped. If everything did go according to plan, * display the results now: if _rc == 0 { display "Testing `term':" test } else { display "An error occurred while testing `term', `termcnt'" display "One or more estimates do not exist." } } end