northernaland
northernaland

Reputation: 27

How to extract any result from the output table

I am doing a weighted average and here is the table:

mean Income [fweight=Group]

Mean estimation
Number of obs    =    1000


             |     Mean   Std. Err.     [95% Conf. Interval]

     Income  |   612.863   10.748      627.554    594.921

I really want to get the standard error and the confidence interval. However, I can only get variance by e(V). So my current method is to store e(V) in a matrix and store the element in a scalar and then use sqrt(). This is tedious!

Is there any way I can extract these statistics easily?

For example in R, all the output table is saved in a matrix RESULT and you can get the standard error simply through RESULT[1,2].

Upvotes: 0

Views: 678

Answers (1)

user8682794
user8682794

Reputation:

The command mean returns r(table) with the results you require:

webuse highschool, clear

mean height [pw = weight]


Mean estimation                   Number of obs   =      4,071

--------------------------------------------------------------
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
      height |   432.8991   .4149654      432.0856    433.7127
--------------------------------------------------------------


matrix list r(table)

r(table)[9,1]
           height
     b  432.89913
    se  .41496538
     t  1043.2175
pvalue          0
    ll  432.08557
    ul  433.71269
    df       4070
  crit   1.960547
 eform          0

More generally, different Stata commands return different results. However, in nearly all cases they give you all the ingredients to easily calculate what you need.

It may require a bit more effort to calculate further results but this is easily programmable and if you need to do something often you can write a wrapper program for the command.

Upvotes: 1

Related Questions