I'm estimating a model in which multiple variables are interacted many times. To more easily identify mistakes and avoid seeing repeated variables Stata is omitting, I would like to be able to write out "a b a#b" instead of "a##b". However, I am having trouble consistently being able to define base levels.
In the following example code (this isn't the actual regression I'm running), the second line of attempt 1 and attempt 2 omits race==3 instead of race==1. The only way I was able to get the ## and # regressions to match was to manually change my preferred base level to be larger than all other values of race (attempt 3).
I imagine I'm missing something obvious. Thank you!
In the following example code (this isn't the actual regression I'm running), the second line of attempt 1 and attempt 2 omits race==3 instead of race==1. The only way I was able to get the ## and # regressions to match was to manually change my preferred base level to be larger than all other values of race (attempt 3).
I imagine I'm missing something obvious. Thank you!
clear
input float(y educ race age prg gdr)
0 1 1 2 1 0
0 1 2 3.2 1 0
0 3 2 7 1 0
0 2 2 6 0 0
1 2 2 1 0 1
1 2 2 45 0 1
1 1 2 2 0 0
1 1 2 1 0 0
0 3 2 3 1 0
0 3 2 2 1 1
0 1 1 1 0 1
0 2 1 43 0 1
1 2 1 2 0 0
1 2 1 1 1 0
1 3 1 3 0 0
1 1 1 2 0 1
0 1 3 1 0 1
0 2 3 43 0 1
1 2 3 2 1 0
1 2 3 1 0 0
1 3 3 3 1 0
1 1 3 2 0 1
1 1 1 2 0 1
0 1 3 1 0 1
end
*attempt 1
fvset base 1 race
reg y race##i1.prg
reg y i.race prg race#i1.prg
*attempt 2
reg y ib1.race##i1.prg
reg y ib1.race prg ib1.race#i1.prg
*attempt 3
replace race = 6 if race==1
fvset base 6 race
reg y race##i1.prg
reg y i.race prg race#i1.prg
input float(y educ race age prg gdr)
0 1 1 2 1 0
0 1 2 3.2 1 0
0 3 2 7 1 0
0 2 2 6 0 0
1 2 2 1 0 1
1 2 2 45 0 1
1 1 2 2 0 0
1 1 2 1 0 0
0 3 2 3 1 0
0 3 2 2 1 1
0 1 1 1 0 1
0 2 1 43 0 1
1 2 1 2 0 0
1 2 1 1 1 0
1 3 1 3 0 0
1 1 1 2 0 1
0 1 3 1 0 1
0 2 3 43 0 1
1 2 3 2 1 0
1 2 3 1 0 0
1 3 3 3 1 0
1 1 3 2 0 1
1 1 1 2 0 1
0 1 3 1 0 1
end
*attempt 1
fvset base 1 race
reg y race##i1.prg
reg y i.race prg race#i1.prg
*attempt 2
reg y ib1.race##i1.prg
reg y ib1.race prg ib1.race#i1.prg
*attempt 3
replace race = 6 if race==1
fvset base 6 race
reg y race##i1.prg
reg y i.race prg race#i1.prg
Comment