prog def ramsey version 2.1 mac def _varlist "req ex min(2)" mac def _if "opt" mac def _in "opt" parse "%_*" parse "%_varlist", parse(" ") mac def _lhs "%_1" mac shift mac def _rhs "%_*" reg %_lhs %_rhs %_if %_in predict double yhat %_if %_in predict double _res %_if %_in, res gen yh2=yhat^2 gen yh3=yhat^3 gen yh4=yhat^4 while "%_1" != "" { mac def _vtype : type %_1 if "%_vtype" != "byte" { mac def _i=%_i + 1 gen zsq%_i=%_1 * %_1 gen zcu%_i=%_1 * %_1 * %_1 gen zqu%_i=%_1 * %_1 * %_1 * %_1 } mac shift } di "" di "Two versions of Ramsey's RESET test:" di "" di "First, as a test of heteroskedasticity:" reg _res yh2 yh3 yh4 %_if %_in testparm yh* di "" di "Second, as a test of whether there are any omitted variables," di "or the functional form is misspecified:" reg %_lhs %_rhs yh2 yh3 yh4 %_if %_in testparm yh* reg %_lhs %_rhs z* %_if %_in testparm z* cap drop yh* _res z* end