Dear all,
i have opinions of different people (person) on different subjects (id) for different years (year). I want to take 3 random people for every subject and year, take the mean of these people from (value), then take that mean value as a DV for a regression with yearly fixed effects. I want to do that 1000 times with random groups of 3 every time and then somehow display the average regression.
So basically doing this 1000 times:
xtset year
xtreg meanvaluefrom3randompersonsperyear x1 x2 x3, fe robust
I am new to stata and know how to label random observations by year and subject as a kind person explained that to me a few weeks ago on here. But there must be a better way of doing that 1000 times per hand. Also not sure how to combine the results of the 1000 regressions.
Here's the data. it's reconstructed and obviously much more complicated than that. x1,x2,x3 are characteristics of the subjects per year
i have opinions of different people (person) on different subjects (id) for different years (year). I want to take 3 random people for every subject and year, take the mean of these people from (value), then take that mean value as a DV for a regression with yearly fixed effects. I want to do that 1000 times with random groups of 3 every time and then somehow display the average regression.
So basically doing this 1000 times:
xtset year
xtreg meanvaluefrom3randompersonsperyear x1 x2 x3, fe robust
I am new to stata and know how to label random observations by year and subject as a kind person explained that to me a few weeks ago on here. But there must be a better way of doing that 1000 times per hand. Also not sure how to combine the results of the 1000 regressions.
Here's the data. it's reconstructed and obviously much more complicated than that. x1,x2,x3 are characteristics of the subjects per year
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(id person) int year float(value x1 x2) byte x3 1 1 2019 3 1.5 2 3 1 2 2019 2 1.5 2 3 1 3 2019 3 1.5 2 3 1 4 2018 2 2 2.5 3 1 5 2018 2 2 2.5 3 1 6 2018 3 2 2.5 3 1 7 2018 4 2 2.5 3 1 8 2018 2 2 2.5 3 1 9 2018 3 2 2.5 3 2 10 2019 6 10 8 12 2 11 2019 8 10 8 12 2 12 2019 9 10 8 12 2 13 2019 8 10 8 12 2 14 2019 8 10 8 12 2 15 2018 3 8 7 10 2 16 2018 2 8 7 10 2 17 2018 2.5 8 7 10 2 18 2018 3 8 7 10 2 19 2018 2 8 7 10 2 20 2018 2 8 7 10 2 21 2018 1.5 8 7 10 2 22 2018 2 8 7 10 3 23 2020 5 15 3 7 3 24 2020 4 15 3 7 3 25 2020 5 15 3 7 3 26 2020 4 15 3 7 3 27 2019 6 12 2 7 3 28 2019 6 12 2 7 3 29 2019 7 12 2 7 4 30 2017 3 12 3 8 4 31 2017 6 12 3 8 4 32 2017 3 12 3 8 4 33 2017 4 12 3 8 4 34 2017 6 12 3 8 end
Comment