Stata: combining regression results with other results

自作多情 提交于 2019-12-11 21:10:58

问题


I am trying to replicate some results from a study. therefore often i need to compare my regression results with results from the study that i'm trying to replicate. I have been manually combining my esttab results with the study results in excel. this however is tedious since i'm working with lot of variables. I was wondering whether there is a way to store the study results and then calling them to go next to my regression results. I tried storing them as scalars and calling them using estout however this puts the stored scalars below the regression results. i would prefer to have them side by side as another column.

Example:

Reference study results are

var b
x  2.1
z  4.2

I entered these into Stata

estadd scalar x=2.1
estadd scalar z=4.2

My regression is

eststore: reg y x z
estout, stats(x,z)

but when i do this i get a table like this

var        b
my reg x   5.3
my reg z   2.3
scalar x   2.1
scalar z   4.2

But I would want the results like this

var        b      scalar b
my reg x   5.3     2.1
my reg z   2.3     4.2

回答1:


The following might help. Find comments inline.

clear 
set more off

*----- example data -----

sysuse auto
keep price weight mpg

*----- what you want -----

//regress and store
reg price weight mpg 
eststo m1

// create matrix of "scalars"
matrix w = (2.1 , 2.4 , 3.2) 

// rename matrix columns to coincide with those of regression
mat colnames w = weight mpg _cons 

// add
estadd matrix w

// print
estout m1, cells("b w")


来源:https://stackoverflow.com/questions/26168113/stata-combining-regression-results-with-other-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!