1
votes

I display the results of two regressions using the community-contributed command esttab:

sysuse auto, clear

quietly reg price weight
est store ols

quietly nl (price = {b0} + {b1} * weight)
est store nls

esttab *

--------------------------------------------
                      (1)             (2)   
                    price           price   
--------------------------------------------
main                                        
weight              2.044***                
                   (5.42)                   

_cons              -6.707          -6.707   
                  (-0.01)         (-0.01)   
--------------------------------------------
b1                                          
_cons                               2.044***
                                   (5.42)   
--------------------------------------------
N                      74              74   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

How can I make the b1 coefficient from the nl command to appear in the weight row?

1

1 Answers

2
votes

The easiest way of doing this is the following:

sysuse auto, clear
estimates clear

regress price weight
estimates store ols

nl (price = {b0} + {b1} * weight)

matrix b = e(b)
matrix V = e(V)

matrix coleq b = " "
matrix coleq V = " "

matrix colnames b = _cons weight
matrix colnames V = _cons weight

erepost b = b V = V, rename
estimates store nls

Results:

esttab ols nls


--------------------------------------------
                      (1)             (2)   
                    price           price   
--------------------------------------------
weight              2.044***        2.044***
                   (5.42)          (5.42)   

_cons              -6.707          -6.707   
                  (-0.01)         (-0.01)   
--------------------------------------------
N                      74              74   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

Note that erepost is a community-contributed command, which you can download from SSC:

ssc install erepost