Announcement

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

  • Dividing samples in groups by mean of variables

    Hi, guys

    I'm a hookie with stata and I hope to make myself clear.

    I'm developing a panel analysis and I'm are trying to divide the sample by groups. These groups would be:

    a) countries above the mean of x, z, w variables
    b) countries below the mean of x, z, w variables


    Therefore, i would a run a regression analysis with these divided groups.


    Here is attached a print screen that shows how it would look like and the paper that i am trying to replicate is this one https://reader.elsevier.com/reader/s...75860C4B5CA8AF.


    Any insight would be very appreciated

    Thanks a lot



    Click image for larger version

Name:	Captura de Tela 2019-03-29 às 21.37.28.png
Views:	1
Size:	239.2 KB
ID:	1490878






  • #2
    I don't understand how the printed table you show relates to what you have asked for. I'm guessing that what you mean is that you have three variables, x, w, and z, and you want to create a variable that divides your sample into 8 groups based on all 8 combinations of being above or below the mean on all three variables. If that is what you want:

    Code:
    gen group = 0
    local to_add = 1
    foreach v of varlist x z w {
        summ `v', meanonly
        replace group = group + `to_add' if `v' > `r(mean)'
        local to_add = 2*`to_add'
    }
    label define group 0 "x low z low w low" ///
        1 "x high z low w low" ///
        2 "x low z high w low" ///
        3 "x high z high w low" ///
        4 "x low z low w high" ///
        5 "x high z low w high" ///
        6 "x low z high w high" ///
        7 "x high z high w high"
    label values group group
    
    // SHOW THE RESULTS
    tabstat x z w, by(group) statistics(min max)
    will do this.

    Comment


    • #3
      Dear Roberto, If I understand correctly, the solution is easier than Clyde's suggestion, according to

      Click image for larger version

Name:	f5.png
Views:	1
Size:	25.2 KB
ID:	1490895
      .


      For each of your variables, generate the means of those variables as (taking for example)
      Code:
      egen mz = mean(z)
      and then you can do something like
      Code:
      xtreg y x1 x2 ... if z > mz, fe robust
      xtreg y x1 x2 ... if z < mz, fe robust
      Ho-Chuan (River) Huang
      Stata 19.0, MP(4)

      Comment

      Working...
      X