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