Metrics
Metrics

Reputation: 15458

Estpost returns error for factor variables

I am trying to output the mean and sd for continuous and factor variables with the community-contributed family of commands estout (ssc install estout).

The code that I used is the following:

sysuse auto,clear
estpost sum price length foreign bn.rep78, listwise 
esttab, cells("mean sd min max") nomtitle nonumber

However, I get the error:

factor variables and time-series operators not allowed
r(101);

I was wondering whether it is possible to fix this error.

Upvotes: 0

Views: 1960

Answers (2)

Giovanni Colitti
Giovanni Colitti

Reputation: 2344

Another way to generate dummies on the fly:

sysuse auto,clear

xi: estpost sum price length foreign i.rep78, listwise 
esttab ., cells("mean sd min max") nomtitle nonumber

----------------------------------------------------------------
                     mean           sd          min          max
----------------------------------------------------------------
price            6146.043      2912.44         3291        15906
length           188.2899      22.7474          142          233
foreign          .3043478     .4635016            0            1
_Irep78_2         .115942     .3225009            0            1
_Irep78_3        .4347826     .4993602            0            1
_Irep78_4        .2608696     .4423259            0            1
_Irep78_5        .1594203     .3687494            0            1
----------------------------------------------------------------
N                      69                                       
----------------------------------------------------------------

The xi prefix will expand any factor notation and can be used with commands that do not support factor notation.

Upvotes: 1

Steve Samuels
Steve Samuels

Reputation: 908

The following syntax is legal:

regress mpg bn.rep78  

For estpost to work, you need to remove the bn. prefix from rep78:

estpost sum price length foreign rep78, listwise

However, if you want to summarize the 0/1 indicator variables for the categories of rep78 (whose means are the category proportions), you will need to create them manually:

tab rep78, gen(rep78x)
estpost sum price length foreign rep78x* , listwise 

Upvotes: 3

Related Questions