Announcement

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

  • Difference between groups

    I study tax and accounting practices in business. The dependent variable is var1 , the independent ones are var2, var3 and a number of control variables such as var4 and var5

    But the whole analysis is based on how this dependent var1 differs between the 2 groups. I have devided the obs in 2 groups. Therefore all commands should be related between group 1 and group 2. So I have to split all the statistics analysis into 2 groups each time, because that's what I want to show.

    Oh, and don't forget. I would like you to tell me how to do operations ( subtraction or addition ) on values of variables belonging to 2 or more time periods. For example, I want to examine whether there is a positive or negative change of var2 and var3 between 2000 and 2001 and whether this ( the difference )has an effect on in 2001.

  • #2
    Theofanis:
    there's no way to split your regression in two, as you can add one categorical predictor in the right-hand side of your regression equation to take the two groups in to account:
    Code:
    . use "https://www.stata-press.com/data/r17/nlswork.dta"
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . xtset idcode year
    
    Panel variable: idcode (unbalanced)
     Time variable: year, 68 to 88, but with gaps
             Delta: 1 unit
    
    . xtreg ln_wage i.union c.age##c.age, fe vce(cluster idcode)
    
    Fixed-effects (within) regression               Number of obs     =     19,229
    Group variable: idcode                          Number of groups  =      4,150
    
    R-squared:                                      Obs per group:
         Within  = 0.0978                                         min =          1
         Between = 0.0461                                         avg =        4.6
         Overall = 0.0587                                         max =         12
    
                                                    F(3,4149)         =     225.93
    corr(u_i, Xb) = 0.0183                          Prob > F          =     0.0000
    
                                 (Std. err. adjusted for 4,150 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         1.union |   .1054165   .0098217    10.73   0.000     .0861607    .1246723
             age |   .0324229   .0051058     6.35   0.000     .0224129     .042433
                 |
     c.age#c.age |  -.0002752   .0000818    -3.37   0.001    -.0004355   -.0001149
                 |
           _cons |   .9942539   .0782432    12.71   0.000     .8408553    1.147652
    -------------+----------------------------------------------------------------
         sigma_u |  .42293457
         sigma_e |  .26192667
             rho |  .72278248   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    As the regression above is in log-linear mode, others things being equal being member of the union increases -ln_wage- of about 11%:
    Code:
    . di exp(.1054165)-1
    .11117332
    The difference for -age- for each -idcode- across years can be calculated as follows:
    Code:
    . bysort idcode (year): gen wanted=age[_n+1]-age[_n]
    
    
    . list idcode year age wanted if idcode==1
    
           +------------------------------+
           | idcode   year   age   wanted |
           |------------------------------|
        1. |      1     70    18        1 |
        2. |      1     71    19        1 |
        3. |      1     72    20        1 |
        4. |      1     73    21        2 |
        5. |      1     75    23        2 |
           |------------------------------|
        6. |      1     77    25        1 |
        7. |      1     78    26        2 |
        8. |      1     80    28        3 |
        9. |      1     83    31        2 |
       10. |      1     85    33        2 |
           |------------------------------|
       11. |      1     87    35        2 |
       12. |      1     88    37        . |
           +------------------------------+
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you Carlo!

      Comment

      Working...
      X