Hi Folks,
In Stata 14, following an -xtreg- regression, I am generating -margins- in two different ways, but getting different results. I have a categorical variable, "race", and I want to understand the margins over a range of a continuous variable called "count". If I consider margins separately for each race category, I get different results than when I consider them as part of the i.race command. Why is this? Am I not considering something? A selection of my data is here also, generated with -dataex-. Thanks for any input.
In Stata 14, following an -xtreg- regression, I am generating -margins- in two different ways, but getting different results. I have a categorical variable, "race", and I want to understand the margins over a range of a continuous variable called "count". If I consider margins separately for each race category, I get different results than when I consider them as part of the i.race command. Why is this? Am I not considering something? A selection of my data is here also, generated with -dataex-. Thanks for any input.
Code:
tsset id mdate, delta(4) xtreg quartergpa count_oncampus i.race financial year margins, at(race==0) at(count=(0(2)10)) saving(file_race0, replace) margins, at(race==1) at(count=(0(2)10)) saving(file_race1, replace) margins, at(race==2) at(count=(0(2)10)) saving(file_race2, replace) margins i.race, at(count=(0(2)10)) saving(file_race_count, replace)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(quartergpa count race financial year) 3.7 11 2 0 2013 3.07 11 2 0 2013 3.7 11 2 0 2013 4 11 2 0 2014 3.3 11 2 0 2014 4 11 2 0 2014 3.3 11 2 0 2015 2.7 11 2 0 2015 4 11 2 0 2015 4 11 2 0 2016 4 11 2 0 2016 4 10 0 0 2012 4 10 0 0 2012 3.7 10 0 0 2014 3 10 0 0 2014 3.85 10 0 0 2014 3.3 10 0 0 2015 3.15 10 0 0 2015 3.16 10 0 0 2015 3.53 10 0 0 2016 3.93 10 0 0 2016 3.3 16 0 0 2012 3.7 16 0 0 2012 2.7 16 0 0 2012 3 16 0 0 2013 3.2 16 0 0 2013 2.65 16 0 0 2013 3.57 16 0 0 2014 2.01 16 0 0 2014 3.66 16 0 0 2014 3.7 16 0 0 2015 3.35 16 0 0 2015 2.98 16 0 0 2015 4 16 0 0 2016 3.12 16 0 0 2016 2.96 16 0 0 2016 2.77 16 0 0 2017 3.85 3 0 0 2012 3.7 3 0 0 2012 3.65 3 0 0 2012 3.7 3 1 1 2012 3 3 1 1 2012 3.42 3 1 1 2012 3.76 6 2 1 2013 0 16 0 0 2012 0 16 0 0 2012 0 16 0 0 2012 2 16 0 0 2013 2 16 0 0 2013 3 16 0 0 2013 4 16 0 0 2014 4 16 0 0 2014 4 16 0 0 2014 4 16 0 0 2015 3.55 16 0 0 2015 3.85 16 0 0 2015 3.27 16 0 0 2016 3.86 16 0 0 2016 3.85 16 0 0 2016 2.7 16 0 0 2017 3 8 0 0 2012 2 8 0 0 2012 3.3 8 0 0 2012 4 8 0 0 2013 4 8 0 0 2013 3.8 8 0 0 2013 3.7 8 0 0 2014 1.3 8 0 0 2014 3.35 8 2 1 2012 3.5 8 2 1 2012 3.9 8 2 1 2012 3.13 8 2 1 2013 3.5 8 2 1 2013 3.85 8 2 1 2013 3 8 2 1 2014 3.47 8 2 1 2014 3.783 3 2 1 2012 3.95 3 2 1 2012 4 3 2 1 2012 4 12 0 0 2012 4 12 0 0 2012 4 12 0 0 2013 4 12 0 0 2013 4 12 0 0 2014 4 12 0 0 2014 3.85 12 0 0 2014 4 12 0 0 2015 4 12 0 0 2015 4 12 0 0 2015 3 12 0 0 2016 3.9 12 0 0 2016 4 2 2 1 2016 3.85 2 2 1 2017 2 4 0 1 2012 1.185 4 0 1 2012 2 4 0 1 2012 0 4 0 1 2013 3.086 5 0 0 2012 2.666 5 0 0 2012 2.53 5 0 0 2012 end
Comment