Announcement

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

  • Creating coefplot after linear and instrumental-variable regressions

    Hi,

    I'm trying to use lincom to plot the linear combination of coefficients for my linear and instrumental-variable regressions.


    Problem is, I'm not sure how to store my output and plot it using coefplot with the respective confidence intervals.

    This is my attempt with a snippet of my data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double re_schedule float(post high_female_manager2 high_female_crew2) str3 store_code float periodo
    143 0 0 1 "125" 4
    94 1 0 1 "125" 25
    136 1 0 1 "125" 35
    116 1 0 1 "125" 24
    305 1 0 1 "125" 27
    142 1 0 1 "125" 16
    85 0 0 1 "125" 5
    71 1 0 1 "125" 14
    53 0 0 1 "125" 6
    83 1 0 1 "125" 20
    84 1 0 1 "125" 23
    83 1 0 1 "125" 13
    192 1 0 1 "125" 33
    199 1 0 1 "125" 17
    64 0 0 1 "125" 7
    70 0 0 1 "125" 12
    93 0 0 1 "125" 11
    205 1 0 1 "125" 18
    193 0 0 1 "125" 2
    15 0 0 1 "125" 0
    170 0 0 1 "125" 1
    174 1 0 1 "125" 19
    180 1 0 1 "125" 32
    59 1 0 1 "125" 15
    302 1 0 1 "125" 28
    99 1 0 1 "125" 22
    220 1 0 1 "125" 30
    14 1 0 1 "125" 36
    257 1 0 1 "125" 26
    60 0 0 1 "125" 10
    168 0 0 1 "125" 3
    71 1 0 1 "125" 21
    40 0 0 1 "125" 9
    144 1 0 1 "125" 31
    220 1 0 1 "125" 34
    57 0 0 1 "125" 8
    304 1 0 1 "125" 29
    15 1 1 0 "138" 27
    17 1 1 0 "138" 29
    5 1 1 0 "138" 36
    20 1 1 0 "138" 20
    57 0 1 0 "138" 4
    23 1 1 0 "138" 30
    14 0 1 0 "138" 8
    25 1 1 0 "138" 28
    16 1 1 0 "138" 24
    34 0 1 0 "138" 5
    17 0 1 0 "138" 10
    17 1 1 0 "138" 21
    112 1 1 0 "138" 34
    42 0 1 0 "138" 16
    72 0 1 0 "138" 18
    17 0 1 0 "138" 12
    46 0 1 0 "138" 1
    13 0 1 0 "138" 14
    11 0 1 0 "138" 7
    9 0 1 0 "138" 11
    53 0 1 0 "138" 3
    16 0 1 0 "138" 6
    16 0 1 0 "138" 15
    20 1 1 0 "138" 22
    29 1 1 0 "138" 31
    66 0 1 0 "138" 17
    25 1 1 0 "138" 26
    15 1 1 0 "138" 23
    24 1 1 0 "138" 25
    49 0 1 0 "138" 2
    88 1 1 0 "138" 33
    14 0 1 0 "138" 9
    32 0 1 0 "138" 19
    29 1 1 0 "138" 32
    4 0 1 0 "138" 0
    25 0 1 0 "138" 13
    73 1 1 0 "138" 35
    44 1 0 1 "AND" 19
    35 0 0 1 "AND" 3
    35 1 0 1 "AND" 20
    31 0 0 1 "AND" 12
    33 0 0 1 "AND" 1
    29 1 0 1 "AND" 27
    30 0 0 1 "AND" 13
    17 0 0 1 "AND" 5
    22 1 0 1 "AND" 32
    29 1 0 1 "AND" 23
    38 0 0 1 "AND" 11
    23 1 0 1 "AND" 30
    17 0 0 1 "AND" 7
    43 1 0 1 "AND" 34
    22 0 0 1 "AND" 9
    2 0 0 1 "AND" 0
    56 0 0 1 "AND" 17
    15 0 0 1 "AND" 6
    30 1 0 1 "AND" 21
    34 1 0 1 "AND" 29
    14 0 0 1 "AND" 14
    18 0 0 1 "AND" 15
    28 1 0 1 "AND" 26
    30 1 0 1 "AND" 33
    15 0 0 1 "AND" 10
    43 0 0 1 "AND" 4
    end
    Code:
     reghdfe re_schedule i.post##i.high_female_manager2##i.high_female_crew2, abs(store_code periodo) cluster(store_code)
    
    eststo m1: lincom 1.post
    eststo m2: lincom 1.post + 1.post#1.high_female_manager2
    eststo m3: lincom 1.post + 1.post#1.high_female_crew2
    eststo m4: lincom 1.post + 1.post#1.high_female_manager2 + 1.post#1.high_female_crew2 + 1.post#1.high_female_crew2#1.high_female_manager2
    
    coefplot m1 m2 m3 m4, recast(bar)  drop(_cons) vertical
    Could someone tell me what I'm doing wrong and how I can plot these estimates after lincom?

    For reference, I have attached an image of what I would like my plot to look like.

    Thanks!
    Attached Files
    Last edited by Brendan Clark; 05 May 2022, 06:40.

  • #2
    lincom doesn't store anything in e(), so unfortunately cannot be used with eststo. Furthermore, only one linear combination can be calculated at a time. xlincom (from SSC) overcomes both of these limitations.
    Code:
    ssc install xlincom
    
    reghdfe re_schedule i.post##i.high_female_manager2##i.high_female_crew2, abs(store_code periodo) cluster(store_code)
    
    xlincom (imp = 1.post) ///
            (imp_fm = 1.post + 1.post#1.high_female_manager2) ///
            (imp_fc = 1.post + 1.post#1.high_female_crew2) ///
            (imp_fm_fc = 1.post + 1.post#1.high_female_manager2 + 1.post#1.high_female_crew2 + 1.post#1.high_female_crew2#1.high_female_manager2), post
    coefplot, recast(bar) vertical
    Last edited by Wouter Wakker; 10 May 2022, 06:57.

    Comment

    Working...
    X