Announcement

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

  • Add column of independent variable means to regression table using esttab

    I have perhaps a simple question regarding eststo/esttab/estout, but I'm struggling to find a solution online. Thoughts appreciated!

    I would like to add a column to my regression table that shows the mean of each independent variable. For factor variables, I'd like to show the proportion of the same that falls within each category.

    A simple example:
    Code:
    sysuse auto, clear
    lab def origin 2 "Lunar", add
    replace foreign = 2 in 10/20
    eststo clear
    eststo: reg mpg i.foreign weight
    esttab, label nobase
    I'd like a new column with cells displaying 0.30, 0.15, and 777

    Thank you!

  • #2
    estout is from Stata Journal, as you are asked to explain in FAQ Advice #12.

    Code:
    sysuse auto, clear
    lab def origin 2 "Lunar", add
    replace foreign = 2 in 10/20
    eststo clear
    eststo: reg mpg i.foreign weight
    eststo: mean i.foreign weight if e(sample)
    esttab, label nobase
    Last edited by Andrew Musau; 05 Nov 2020, 17:20.

    Comment


    • #3
      Hi Andrew, thanks for your response!

      I get this error: "factor-variable and time-series operators not allowed" when running the line you added.

      Comment


      • #4
        What version of Stata do you have? Note the FAQ Advice (#12) to state your version if it is not the current version. You can use the -xi- prefix consistently and label the coefficients subsequently.

        Code:
        sysuse auto, clear
        lab def origin 2 "Lunar", add
        replace foreign = 2 in 10/20
        eststo clear
        eststo: xi: reg mpg i.foreign weight
        eststo: xi: mean i.foreign weight if e(sample)
        esttab, coeflabel(_Iforeign_1 "Foreign" _Iforeign_2 "Lunar") nobase

        Comment


        • #5
          Success! Thanks Andrew. Apologies, I am using Stata 15.1.

          Comment

          Working...
          X