使用stata中的areg吸收选项输出所选的虚拟var系数

时间:2015-10-21 00:03:06

标签: regression stata

对租金,可用口味和公司虚拟变量进行价格回归

clear all
set obs 300
gen firm = ""
forvalues i = 1/150{
   replace firm = "firm_`i'" in `i'
}
replace firm = "Ben & Jerry's" in 151/200
replace firm = "Cold Stone" in 201/250
replace firm = "Rita's" in 251/300
gen rent = rnormal(1000,50)
gen flavors_avail = rnormal(30,10)
gen price = rnormal(5,1.5)

areg price rent flavors_avail, absorb(firm)

如何输出代表三大公司(Ben& Jerry's,Cold Stone和Rita's)的虚拟变量的系数和显着性,但抑制150个独立公司的产量?

1 个答案:

答案 0 :(得分:2)

我只会使用regress(它会显示所有内容,但会静静地显示它们),但是然后使用margins只显示您想要的内容:

capture ssc install sencode 
capture ssc install esttab
sencode firm, replace
gen constant = 1
quietly reg price rent flavors_avail i.firm constant, nocons
margins, dydx(rent flavors_avail 151.firm 152.firm 153.firm constant)

请注意,我欺骗margins显示常量,以便您将其用于与3大链的比较。

您也可以使用SSC中的esttab执行此类操作:

esttab, keep(rent flavors_avail 151.firm 152.firm 153.firm constant) label