Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plotting matrices with estout

    Dear Statalist,
    I have a question about the use of estout.

    I'm using Stata 17 with the user-written commands estout and shapley2.

    My aim is to save multiple matrices with eststore and to then report them with estout. In this specific case the example is with the output of the user-written command shapley2, but the question is generalizable to all kind of matrices that are added with estimates store.

    In the example I calculate Shapley values once for the full model and then for the restricted model. I save the regression coefficients together with the shapley values in `all' and `if_1', respectively.


    Code:
    // ssc install estout
    // ssc install shapley2
    
    sysuse auto, clear
    
    * Add e-return shapley_rel to all
    reg price rep78 weight
    eststo all
    shapley2, stat(r2)
    eststo all
    
    * Add e-return shapley_rel to if_1
    reg price rep78 weight if foreign == 1
    eststo if_1
    shapley2, stat(r2)
    eststo if_1
    
    * Check that shapley_rel is added to all:
    estimates restore all
    ereturn list
    
    * Check that shapley_rel is added to if_1:
    estimates restore if_1
    ereturn list

    How do I now print the results of the e-return shapley_rel with estout?


    I came up with this solution:

    Code:
    local shapley_fill
    forvalues num = 1/2 {
        local shapley_fill `shapley_fill' shapley_rel[`num']
    }
    
    estout all if_1, cell(`shapley_fill')
    With this solution the rownames are not kept, and it's difficult to generalize this code to all settings with added matrices.



    Other solutions I considered:

    estout e(shapley_rel)
    only prints the output of the last eststo


    estout all if_1, cell(shapley_rel)
    only reports the first row. This is line with the help file that states "The default is to report the results from the first row." But how can I cange the default?

Working...
X