Announcement

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

  • balance table using esttab

    I am having trouble creating a table that checks the balance of the covariates. My goal is to have four columns, each one reporting for each variable the mean (and the standard deviation) of the total sample, of the control and treatment subsamples and finally the difference in means (with the appropriate standard error).

    The command I an using is the following:
    Code:
        eststo totsample: estpost summarize $COVS
        eststo treatment: estpost summarize $COVS if train==1
        eststo control: estpost summarize $COVS if train==0
        eststo groupdiff: estpost ttest $COVS, by(train)
    
        esttab totsample treatment control groupdiff using table1.tex, replace /// 
        cell(mean(pattern(1 1 1 0) fmt(4)) b(pattern(0 0 0 1) fmt(4)) sd(pattern(1 1 1 0) fmt(4)) ///
        se(pattern(0 0 0 1) fmt(2))) mtitle("Full sample" "Training" "Control" "Difference (3)-(2)")
    This code yields an issue because the values of the last column are not on the same line as the other ones. I have tried solving this issue by creating a tab with only the first 3 columns and then appending the last one, however by doing so the table also appends the column containing the name of the variables.
    How can I solve this issue?
    If there is a faster, better way please let me know!
    Thank you in advance

  • #2
    Hi Vincenzo Alfano Viola ,

    if you want to put different cell contents for different models into the same physical cell in the table, you need to tell estout to merge these cells with the "&" operator (I just added a few more line breaks for better legibility):
    Code:
    esttab totsample treatment control groupdiff using table1.tex , replace ///
        cell( ///
            mean(pattern(1 1 1 0) fmt(4)) & b(pattern(0 0 0 1) fmt(4)) ///
            sd(pattern(1 1 1 0) fmt(4)) & se(pattern(0 0 0 1) fmt(2)) ///
        ) mtitle("Full sample" "Training" "Control" "Difference (3)-(2)")
    Is this what you wanted?

    Kind regards
    Bela

    Comment


    • #3

      Yes it worked, thank you Daniel Bela !

      Kind Regards,
      Vincenzo

      Comment

      Working...
      X