Announcement

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

  • problems with seg package for calculating segregation measures

    Hi,

    I am using seg package to calculate different education segregation measures (dissimilarity, exposure and isolation) by district areas. I am using STATA 15.1 and trying to simulate different scenario of school segregation. I have got a baseline scenario and a simulated one if the students would have chosen the closest school of their residence. My variable is Ajut menjador (food allowance) it is a dummy coded variable 0 for not receiving any financial help. SCH_C_Distri is a variable indicating different districts of the city. Stata returns for all the segregation measures I calculate a value of 1. Here is my code, a sample of the data and the results. I hope you can help. Thanks a lot for your help.

    Best,


    code:

    # tab Ajut_menjador, gen (Ajut_menjador_)
    # seg Ajut_menjador_1 Ajut_menjador_2, d n s by(SCH_C_Distri) gen(d D_real_FS n E_real_FS s I_real_FS)

    results:

    . tab Ajut_menjador, gen (Ajut_menjador_)

    Ajut_menjad |
    or | Freq. Percent Cum.
    ------------+-----------------------------------
    0 | 87,126 80.70 80.70
    1 | 20,833 19.30 100.00
    ------------+-----------------------------------
    Total | 107,959 100.00

    . seg Ajut_menjador_2 Ajut_menjador_1, d n s by(SCH_C_Distri) gen(d D_real_AM
    > n E_real_AM s I_real_AM)

    Group Variables: Ajut_menjador_2 Ajut_menjador_1

    Total Counts and Diversity Measures

    --------------------------------------------------------------
    SCH_C_Dis |
    tri | Total Units Total Count Interaction Norm. Int.
    ----------+---------------------------------------------------
    1 | 4956 4956 0.4777 0.9555
    2 | 15099 15099 0.2253 0.4507
    3 | 9005 9005 0.4146 0.8293
    4 | 6562 6562 0.1196 0.2391
    5 | 15425 15425 0.0604 0.1208
    6 | 8238 8238 0.2454 0.4909
    7 | 11994 11994 0.3128 0.6257
    8 | 10125 10125 0.4912 0.9825
    9 | 10984 10984 0.3417 0.6834
    10 | 15571 15571 0.3174 0.6347
    --------------------------------------------------------------

    Segregation Measures

    -------------------------------------------------
    SCH_C_Dis |
    tri | Dissim. Isolation 2G Norm Exp
    ----------+--------------------------------------
    1 | 1.0000 1.0000 1.0000
    2 | 1.0000 1.0000 1.0000
    3 | 1.0000 1.0000 1.0000
    4 | 1.0000 1.0000 1.0000
    5 | 1.0000 1.0000 1.0000
    6 | 1.0000 1.0000 1.0000
    7 | 1.0000 1.0000 1.0000
    8 | 1.0000 1.0000 1.0000
    9 | 1.0000 1.0000 1.0000
    10 | 1.0000 1.0000 1.0000
    -------------------------------------------------

    Index Values Written to Current File

    Result # of obs.
    -----------------------------------------
    not matched 0
    matched 107,959 (__00000Y==3)
    -----------------------------------------

    .
    end of do-file



    ***********DATA***********

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(Ajut_menjador SCH_C_Distri)
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 2
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    0 5
    end

  • #2
    You didn't get a quick answer despite posting the desired materials. With a community-contributed procedure like seg, an answer often depends on whether one of the active folks happen to use the procedures. In your data, the first variable is 0 for all observations - this could give you strange results.

    After making absolutely certain it is not a data problem (try to replicate the seg measures from someone else's data or create an artificial data set with known segregation), I suspect you have several possible courses of action: (i) code the measures yourself, (ii) look into the other Stata procedures that deal with segregation [findit seg produces a list of possible procedures), or (iii) contact the procedure's authors.

    Comment


    • #3
      Thanks Phil for your reply.
      My variable of interest is a dummy 0/1.
      I have tried with another dataset and it gives the same results. All indexes produced have a value of 1.
      So I suspect it is not a matter of data.
      I have already contacted both the authors of the package, but neither of them reply.
      I will try to code the measures by myself since I do not find any routine in STATA for calculating measure of exposure and isolation by sub-unit levels.

      Comment


      • #4
        If a variable is constant, no segregation by subgroups can be discernible. I don't know, let alone use, this command, but I will assert that as a folk theorem.

        You're asked (FAQ Advice #12) to explain community-contributed commands. This appears to be what you're using.

        . ssc desc seg

        --------------------------------------------------------------------------------------
        package seg from http://fmwww.bc.edu/repec/bocode/s
        --------------------------------------------------------------------------------------

        TITLE
        'SEG': module to compute multiple-group diversity and segregation indices

        DESCRIPTION/AUTHOR(S)

        SEG calculates a variety of indices to measure diversity and
        mutual segregation among multiple groups. A 'by' option allows
        the calculation of the indices within different organizational
        levels, and a Unit option allows calculation of the indices
        between different organizational levels. Generate and File
        options allow the indices to be output to either the current
        data set or a new data set.

        KW: segregation
        KW: diversity

        Requires: Stata version 13.1


        Author: Sean F. Reardon, Stanford University
        Support: email [email protected]

        Author: Joseph B. Townsend
        Support: email [email protected]

        Distribution-Date: 20180418


        INSTALLATION FILES (type net install seg)
        seg.ado
        seg.sthlp
        --------------------------------------------------------------------------------------
        (type ssc install seg to install)
        Last edited by Nick Cox; 16 Jan 2019, 13:27.

        Comment

        Working...
        X