I have a syntax error message for this ado file and cant find where the problem is. It tests for dominance up to the third order using income data in the analysis of poverty. Sorry I can't provide a minimal working example as I'm not sure where the error is. It displays up to the line " display "Maximum test point is " `zmax' " . A previous error was spotted by a forum member and fixed.
#delimit ;
program define dom; * syntax is dom var1 wgt1 var2 wgt2 zmax #test-points;
version 6.0;
local x1 `1';
local wgt1 `2';
local x2 `3';
local wgt2 `4';
local zmax = `5';
local num = `6';
summarize `x1', meanonly;
local min1 = r(min);
summarize `x2', meanonly;
local min2 = r(min);
local min = max(`min1',`min2');
local inter = (`zmax'-`min')/(`num'-1);
local min = `min' + `inter'; * Don’t start at very end of tail;
local inter = (`zmax'-`min')/(`num'-1);
local done = 0;
local s = 1;
tempvar ind;
display " ";
display "Minimum test point is " `min';
display " ";
display "Maximum test point is " `zmax';
display " "; if `zmax' <= `min' {;
local done = 1;
display " ";
display in red "Error: " in yellow "Max test point is not larger than
min test point!";
display " ";
};
while `done' == 0 {;
display " ";
display "Order " `s';
display "Z D1 D2 t-statistic";
local alpha = `s' - 1;
local i = 1;
local z = `min';
quietly gen `ind' = .;
while `z' <= `zmax' {;
quietly fgt `x1' `wgt1' `z' `alpha';
local D1 = ${D`s'};
local VD1 = ${VD`s'};
quietly fgt `x2' `wgt2' `z' `alpha';
local D2 = ${D`s'};
local VD2 = ${VD`s'};
local t = (`D2'-`D1')/sqrt(`VD1'+`VD2');
display %5.4f `z' " " %5.4f `D1' " " %5.4f `D2' " "
%4.2f `t';
local ind0 = 1.5;
if `t' >= 1.96 {; local ind0 = 1; };
if `t' <= -1.96 {; local ind0 = 2; };
quietly replace `ind' = `ind0' if _n==`i';
local z = `z' + `inter';
local i = `i' + 1;
};
summarize `ind', meanonly;
if r(mean) == 1 {; local done = 1;
global Dorder = -`s';
display "";
display "Dominance achieved at order " `s';
local s = 1;};
if r(mean) == 2 {; local done = 1;
global Dorder = `s';
display "";
display "Dominance achieved at order " `s';
local s = 1;};
if `s' >= 3 {; local done = 1;
global Dorder = 0;
display "";
display "Dominance not achieved up to order
3";};
drop `ind';
local s = `s' + 1;
};
end;
#delimit ;
program define dom; * syntax is dom var1 wgt1 var2 wgt2 zmax #test-points;
version 6.0;
local x1 `1';
local wgt1 `2';
local x2 `3';
local wgt2 `4';
local zmax = `5';
local num = `6';
summarize `x1', meanonly;
local min1 = r(min);
summarize `x2', meanonly;
local min2 = r(min);
local min = max(`min1',`min2');
local inter = (`zmax'-`min')/(`num'-1);
local min = `min' + `inter'; * Don’t start at very end of tail;
local inter = (`zmax'-`min')/(`num'-1);
local done = 0;
local s = 1;
tempvar ind;
display " ";
display "Minimum test point is " `min';
display " ";
display "Maximum test point is " `zmax';
display " "; if `zmax' <= `min' {;
local done = 1;
display " ";
display in red "Error: " in yellow "Max test point is not larger than
min test point!";
display " ";
};
while `done' == 0 {;
display " ";
display "Order " `s';
display "Z D1 D2 t-statistic";
local alpha = `s' - 1;
local i = 1;
local z = `min';
quietly gen `ind' = .;
while `z' <= `zmax' {;
quietly fgt `x1' `wgt1' `z' `alpha';
local D1 = ${D`s'};
local VD1 = ${VD`s'};
quietly fgt `x2' `wgt2' `z' `alpha';
local D2 = ${D`s'};
local VD2 = ${VD`s'};
local t = (`D2'-`D1')/sqrt(`VD1'+`VD2');
display %5.4f `z' " " %5.4f `D1' " " %5.4f `D2' " "
%4.2f `t';
local ind0 = 1.5;
if `t' >= 1.96 {; local ind0 = 1; };
if `t' <= -1.96 {; local ind0 = 2; };
quietly replace `ind' = `ind0' if _n==`i';
local z = `z' + `inter';
local i = `i' + 1;
};
summarize `ind', meanonly;
if r(mean) == 1 {; local done = 1;
global Dorder = -`s';
display "";
display "Dominance achieved at order " `s';
local s = 1;};
if r(mean) == 2 {; local done = 1;
global Dorder = `s';
display "";
display "Dominance achieved at order " `s';
local s = 1;};
if `s' >= 3 {; local done = 1;
global Dorder = 0;
display "";
display "Dominance not achieved up to order
3";};
drop `ind';
local s = `s' + 1;
};
end;
Comment