Announcement

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

  • Making Food Insecurity Index

    Using This dataset
    . dataex

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long hhcode byte(province region) long psu int district byte(c01 c02 c03 c04 c05 c06 c07 c08)
    101100101 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100102 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100103 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100104 1 1 1011001 101 1 1 2 2 2 2 2 2
    101100105 1 1 1011001 101 1 1 1 2 1 2 2 2
    101100106 1 1 1011001 101 2 1 1 2 1 2 2 2
    101100107 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100108 1 1 1011001 101 2 1 2 2 2 2 2 2
    101100109 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100110 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100111 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100112 1 1 1011001 101 2 1 2 2 2 2 2 2
    101100113 1 1 1011001 101 1 1 1 2 1 2 2 2
    101100114 1 1 1011001 101 1 1 1 2 1 1 2 2
    101100115 1 1 1011001 101 2 2 2 2 1 2 2 2
    101100116 1 1 1011001 101 1 1 1 2 2 2 1 1
    101100117 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100118 1 1 1011001 101 1 1 1 2 2 2 2 2
    101100119 1 1 1011001 101 1 2 1 2 2 1 2 2
    101100120 1 1 1011001 101 1 1 2 2 2 2 2 2
    101100121 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100122 1 1 1011001 101 1 1 2 2 2 2 2 2
    101100123 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100124 1 1 1011001 101 1 2 1 2 2 2 2 2
    101100125 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100126 1 1 1011001 101 1 1 1 2 2 2 2 2
    101100127 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100128 1 1 1011001 101 1 1 1 2 2 2 2 2
    101100129 1 1 1011001 101 2 2 2 2 2 2 2 2
    101100130 1 1 1011001 101 1 2 2 2 2 2 2 2
    101100201 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100202 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100203 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100204 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100205 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100206 1 1 1011002 101 1 1 1 2 1 2 2 2
    101100207 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100208 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100209 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100210 1 1 1011002 101 2 1 1 2 2 2 2 2
    101100211 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100212 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100213 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100214 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100215 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100217 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100218 1 1 1011002 101 1 1 1 2 2 2 1 1
    101100219 1 1 1011002 101 2 2 1 2 2 2 2 2
    101100220 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100221 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100222 1 1 1011002 101 2 2 1 2 2 2 2 2
    101100223 1 1 1011002 101 2 2 1 2 2 2 2 2
    101100224 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100225 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100226 1 1 1011002 101 2 2 1 2 2 2 2 2
    101100227 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100228 1 1 1011002 101 2 2 1 2 2 2 2 2
    101100229 1 1 1011002 101 2 2 2 2 2 2 2 2
    101100230 1 1 1011002 101 1 1 1 2 2 2 2 2
    101100401 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100402 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100403 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100404 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100405 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100406 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100407 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100408 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100409 1 1 1011004 101 1 1 2 2 2 2 2 2
    101100410 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100412 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100413 1 1 1011004 101 1 2 1 2 2 2 2 2
    101100414 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100415 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100416 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100417 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100418 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100420 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100421 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100422 1 1 1011004 101 2 2 1 2 2 2 2 2
    101100423 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100424 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100425 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100426 1 1 1011004 101 1 1 1 2 2 2 2 2
    101100427 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100428 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100429 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100430 1 1 1011004 101 2 2 2 2 2 2 2 2
    101100501 1 1 1011005 101 2 2 2 2 2 2 2 2
    101100502 1 1 1011005 101 2 2 2 2 2 2 2 2
    101100503 1 1 1011005 101 2 2 2 2 2 2 2 2
    101100504 1 1 1011005 101 2 2 2 2 2 2 2 2
    101100505 1 1 1011005 101 1 1 1 2 1 2 2 2
    101100506 1 1 1011005 101 1 1 1 2 1 2 2 2
    101100507 1 1 1011005 101 1 1 1 2 2 2 2 2
    101100508 1 1 1011005 101 2 2 2 2 2 2 2 2
    101100509 1 1 1011005 101 1 1 1 2 2 2 2 2
    101100510 1 1 1011005 101 2 2 2 2 2 2 2 2
    101100511 1 1 1011005 101 2 2 1 2 2 2 2 2
    101100512 1 1 1011005 101 2 2 1 2 2 2 2 2
    101100513 1 1 1011005 101 2 2 1 2 2 2 2 2
    end
    label values province province
    label def province 1 "kp", modify
    label values region region
    label def region 1 "rural", modify
    label values district district
    label def district 101 "abbottabad", modify
    keep if province==2
    drop if c01 == 98 | c01 == 99
    drop if c02 == 98 | c02 == 99
    drop if c03 == 98 | c03 == 99
    drop if c04 == 98 | c04 == 99
    drop if c05 == 98 | c05 == 99
    drop if c06 == 98 | c06 == 99
    drop if c07 == 98 | c07 == 99
    drop if c08 == 98 | c08 == 99
    recode c01 (1=1 "1") (2=0 "0"), generate(binary_c01)
    recode c02 (1=1 "1") (2=0 "0"), generate(binary_c02)
    recode c03 (1=1 "1") (2=0 "0"), generate(binary_c03)
    recode c04 (1=1 "1") (2=0 "0"), generate(binary_c04)
    recode c05 (1=1 "1") (2=0 "0"), generate(binary_c05)
    recode c06 (1=1 "1") (2=0 "0"), generate(binary_c06)
    recode c07 (1=1 "1") (2=0 "0"), generate(binary_c07)
    recode c08 (1=1 "1") (2=0 "0"), generate(binary_c08)
    collapse (mean) binary_c01 binary_c02 binary_c03 binary_c04 binary_c05 binary_c06 binary_c07 binary_c08 , by(district)
    foreach var of varlist binary_c01 binary_c02 binary_c03 binary_c04 binary_c05 binary_c06 binary_c07 binary_c08 {
    egen min_`var' = min(`var')
    egen max_`var' = max(`var')
    gen normalized_`var' = (`var' - min_`var') / (max_`var' - min_`var')
    }
    list binary_c01 normalized_binary_c01 in 1/10
    gen food_insecurity_index = (normalized_binary_c01 + normalized_binary_c02 + normalized_binary_c03 + normalized_binary_c04 + normalized_binary_c05 + normalized_binary_c06 + normalized_binary_c07 + normalized_binary_c08) / 8
    list district food_insecurity_index
    ------------------ copy up to and including the previous line ------------------
    
    Listed 100 out of 160654 observations
    Use the count() option to list more
    Result:
    district food_i~x
    
    1. attock .0878222
    2. bahawaln .7673687
    3. bahawalp .6395296
    4. bhakhar .384757
    5. chakwal .2943359
    
    6. chiniot .2689224
    7. d. g. kh .5084416
    8. faisalab .1328354
    9. gujranwa .2444148
    10. gujrat .0180971
    
    11. hafizaba .2025424
    12. islamaba .1586573
    13. jehlum .4989371
    14. jhang .5090191
    15. kasur .7063363
    
    16. khanewal .7514324
    17. khushab .2625226
    18. lahore .4137256
    19. layyah .4822337
    20. lodhran .6053461
    
    21. mandi ba .1896518
    22. mianwali .2228872
    23. multan .3976084
    24. muzaffar .6404075
    25. nankana .2188804
    
    26. narowal .3084604
    27. okara .0613527
    28. pakpatta .2036972
    29. rahim ya .4872369
    30. rajanpur .3854529
    
    31. rawalpin .1842262
    32. sahiwal .1838323
    33. sargodha .3961037
    34. sheikhup .3443179
    35. sialkot .1976983
    
    36. t.t. sin .2923453
    37. vehari .3706231
    I just want to ask whether this is the correct method for making a food insecurity index?
    Thank You for Your Assistance
    Last edited by aafaque ali; 19 Jul 2024, 09:41.

  • #2
    This is the relevant portion of code from what I can tell.

    Code:
    foreach var of varlist binary_c01 binary_c02 binary_c03 binary_c04 binary_c05 binary_c06 binary_c07 binary_c08 {
        egen min_`var' = min(`var')
        egen max_`var' = max(`var')
        gen normalized_`var' = (`var' - min_`var') / (max_`var' - min_`var')
    }
    list binary_c01 normalized_binary_c01 in 1/10
    gen food_insecurity_index = (normalized_binary_c01 + normalized_binary_c02 + normalized_binary_c03 + normalized_binary_c04 + normalized_binary_c05 + normalized_binary_c06 + normalized_binary_c07 + normalized_binary_c08) / 8
    The for loop is a little strange since it looks like you are treating the data as quantitative when each variable is in fact dichotomous. The minimum for each var should be zero every time, so when you subtract off min_`var' that isn't having any effect. This leaves you "normalizing" by dividing each binary variable by one, so if 1, it should be 1, and if 0 it should remain zero. There is no reason I can see to do this. Since each variable is binary, I actually don't think you need to normalize here at all.

    The last line should be okay. Whether or not you exclude the for loop and don't try to normalize your dichotomous variables, the result of the last line is interpretable as the proportion of the binary variables with a 1. Notice that if you want this to be an index, the meaning of the ones have to go in the same direction. So if 1 means the presence of some feature of food insecurity on one variable, it has to mean the presence (not absense) of some feature of food insecurity on every other variable.

    Edit: I assume you used a guide to finish this? Just to be clear, what your for loop does is it takes a quantitative value and rescales it to be between 0 and 1. Since dichotomies variables are already on a 0/1 scale, you don't need to rescale.
    Last edited by Daniel Schaefer; 19 Jul 2024, 09:57.

    Comment


    • #3
      By the way, "correct" is a relative term. There are better methods in confirmatory factor analysis. Different fields construct indexes differently, so the "best" way to do it might be field dependent.

      Comment

      Working...
      X