Announcement

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

  • Generating result of dissim command as new variable

    Hello,
    I am using the dissim command to calculate the gender occupational segregation. How can i store the result in a new variable so that I can use it for further calculations? It doesn't work in combination with the egen command such as "egen new_variable = dissim sex eseg"

  • #2
    Indeed. egen doesn't work like that. It only recognises functions specifically written for it and in any case its syntax is different in other ways. It's not a framework for other commands' results.

    On a search I find that dissim was mine and is on SSC. You're asked (FAQ Advice #12) to explain where community-contributed commands come from, not least because programmers don't always recognise their own progeny.

    On dissim: as of 2021 you are recommended to use dissim_index instead as help dissim now fires up an official Stata help file. But dissim_index is equally useless if you want a new variable. It is (was) only ever written to display summary measures.

    entropyetc from SSC may be more helpful. Here I adapt an example from its help.

    Code:
    . webuse nlsw88, clear 
    (NLSW, 1988 extract)
    
    . entropyetc occupation, by(industry) 
    
    ------------------------------------------------------------------------------------
                            |  Shannon H      exp(H)     Simpson   1/Simpson     dissim.
    ------------------------+-----------------------------------------------------------
      Ag/Forestry/Fisheries |      1.646       5.186       0.239       4.188       0.534
                     Mining |      0.562       1.755       0.625       1.600       0.846
               Construction |      1.399       4.050       0.353       2.832       0.597
              Manufacturing |      1.470       4.348       0.316       3.167       0.575
     Transport/Comm/Utility |      1.484       4.411       0.342       2.922       0.556
     Wholesale/Retail trade |      1.740       5.698       0.214       4.681       0.554
    Finance/Ins/Real estate |      1.206       3.340       0.355       2.818       0.707
        Business/Repair svc |      1.579       4.849       0.277       3.608       0.588
          Personal services |      1.597       4.937       0.243       4.107       0.599
      Entertainment/Rec svc |      1.712       5.538       0.218       4.587       0.516
      Professional services |      1.590       4.902       0.219       4.558       0.612
      Public administration |      1.195       3.304       0.404       2.473       0.701
    ------------------------------------------------------------------------------------
    . entropyetc occupation, by(industry)  gen(5=dissim)
    
    ------------------------------------------------------------------------------------
                            |  Shannon H      exp(H)     Simpson   1/Simpson     dissim.
    ------------------------+-----------------------------------------------------------
      Ag/Forestry/Fisheries |      1.646       5.186       0.239       4.188       0.534
                     Mining |      0.562       1.755       0.625       1.600       0.846
               Construction |      1.399       4.050       0.353       2.832       0.597
              Manufacturing |      1.470       4.348       0.316       3.167       0.575
     Transport/Comm/Utility |      1.484       4.411       0.342       2.922       0.556
     Wholesale/Retail trade |      1.740       5.698       0.214       4.681       0.554
    Finance/Ins/Real estate |      1.206       3.340       0.355       2.818       0.707
        Business/Repair svc |      1.579       4.849       0.277       3.608       0.588
          Personal services |      1.597       4.937       0.243       4.107       0.599
      Entertainment/Rec svc |      1.712       5.538       0.218       4.587       0.516
      Professional services |      1.590       4.902       0.219       4.558       0.612
      Public administration |      1.195       3.304       0.404       2.473       0.701
    ------------------------------------------------------------------------------------
    
    . tabdisp industry if industry < ., c(dissim) format(%4.3f)
    
    ---------------------------------------------
                   Industry | dissimilarity index
    ------------------------+--------------------
      Ag/Forestry/Fisheries |               0.534
                     Mining |               0.846
               Construction |               0.597
              Manufacturing |               0.575
     Transport/Comm/Utility |               0.556
     Wholesale/Retail trade |               0.554
    Finance/Ins/Real estate |               0.707
        Business/Repair svc |               0.588
          Personal services |               0.599
      Entertainment/Rec svc |               0.516
      Professional services |               0.612
      Public administration |               0.701
    ---------------------------------------------

    Comment


    • #3
      Thank you for your response! If I have a variable occ for the occupation groups plus a variable sex for the gender, would the command be entropyetc occ, by (sex)?

      Comment


      • #4
        That might well be what you want.

        Comment


        • #5
          A follow up question on this: if i want to use the dissim variable in a regression model as an independent variable, Stata omitts it from the model due to collinearity. How can I use the dissim variable in the regression model?

          Comment


          • #6
            I think that #5 is a new question and one that can only be answered in general terms (for example, what kind of regression model?), although perhaps helpfully.

            You need to find out which other variables that are candidate predictors turn out to be collinear and then -- if it is important to use dissimilarity as a predictor -- omit the other variable(s) in that bundle. A correlation or scatter plot matrix can help here.

            In a complicated model all sorts of other things could happen. For example the dissimilarity index will be exactly zero if a group is homogeneous, which might clash with any (0, 1) indicator variables you are including in a model.

            Comment

            Working...
            X