rm(list=ls(all=t))
filename <- "midline3" # !!!Update filename
functions_vers <- "functions_1.7.R" # !!!Update helper functions file
source (functions_vers)
Visually inspect variables in "dictionary.csv" and flag for risk, using the following flags:
# Direct PII: Respondent Names, Addresses, Identification Numbers, Phone Numbers
# Direct PII-team: Interviewer Names, other field team names
# Indirect PII-ordinal: Date of birth, Age, income, education, household composition.
# Indirect PII-categorical: Gender, education, ethnicity, nationality,
# occupation, employer, head of household, marital status
# GPS: Longitude, Latitude
# Small Location: Location (<100,000)
# Large Location (>100,000)
# Weight: weightVar
# Household ID: hhId,
# Open-ends: Review responses for any sensitive information, redact as necessary
# !!!No Direct PII
# !!!No Direct PII-team
!!!Include relevant variables, but check their population size first to confirm they are <100,000
mydata$mid3_child_municipality <- as.numeric(mydata$mid3_child_municipality)
locvars <- c("mid3_villagename",
"mid3_settlement",
"mid3_municipality",
"mid3_wardno",
"mid3_child_municipality",
"mid3_child_wardno",
"mid3_child_villagename",
"mid3_child_settlement")
mydata <- encode_location (variables= locvars, missing=999999)
## [1] "Frequency table before encoding"
## mid3_villagename. Villagename
## .parariya /kharsal /Rajesh gupta
## 1 7 4 6
## aadarsa tol aadarsamani tol Aadarsh tole Aadarsha tol
## 3 11 5 23
## Aalau aarba Aarba Adalat road
## 37 9 5 4
## adarshnagar Adarshnagar Adarsnagar Alakha Road
## 5 4 4 8
## Apauni arba Arba Armalakot
## 24 19 21 18
## arva Ashok batika Ashokbatika Ashokvatika
## 22 6 30 2
## Atharaha Athraha badhahare tol bagaicha
## 31 4 5 4
## Bahuwari Bajrang tole Banahari Bangau
## 9 19 25 29
## Barwa Basant inarwa Basantpur tole Basudevpur
## 35 14 15 87
## Basydevpur Bawanipur Bayokhola Belanye
## 5 7 5 2
## Belganar Belganari Bhagawati tole Bhagwatitol
## 2 20 4 8
## bhakti path bhalam Bhalam bhandari dhar
## 4 12 26 4
## bhansartole Bhansartole Bhawanipur Bhawaniyapur
## 7 11 75 94
## Bhediyahi Bijeynagar Bindabasini Bindawasini
## 13 53 13 54
## Birgunj Birta Brahmpur Budagaun tole
## 13 52 40 12
## Capkaiya Centre Parseni tole Chailaheli Chailai
## 7 4 5 3
## chanutae Chapkaiya Chapkaya Chappa dada
## 16 187 6 4
## Chhapkaiya Chitraguptnagar Cigarette factory Dadathok
## 64 10 4 8
## Dadathok tol Dadrini Dasarath nager Dasharthnager
## 3 7 3 4
## Deurali piple Dhadagari Dhalepipal Dihi gau
## 13 17 7 4
## Dinesh sah Fulbari Furthi chook Furthichook
## 5 43 26 3
## Gahatera Gahawa garjathi garjati
## 8 32 5 10
## Gaurigau Geetanagae Geetanagar Geetnagar
## 6 3 169 4
## ghadgai ghadhai Ghariwarha Gharmikhola
## 16 6 42 6
## Ghoraneti Ghoraneti tol Ghurmi gimirae
## 5 3 14 7
## Gitpur tole Golauri Golouri Gopal chook
## 5 5 5 9
## Gurudev ram Gyanjyoti Halawar Hamagara
## 4 5 10 6
## hanumanagar hanumannagae hanumannagar hanunam nagar
## 4 4 5 3
## Haripaura Harpatganj Harpatgunj Hasnapur
## 4 11 38 8
## Hatiya Hatti lote hemja Hemja
## 19 5 55 37
## Himalay tole Indarpur jagriti tole Jagriti tole
## 37 92 5 5
## Jailroad Jaispur Jaspur Jimire dil
## 12 90 5 6
## Jispur Jogindra Raut kurmi Jumleti tol Kachila
## 6 6 7 8
## Kachili Kahu kahun Kalakhola
## 15 8 11 6
## Kalakhola pulchok Kalyakhola vewdar Kalyanpur Kanchan pur road
## 3 6 5 3
## Kanchanpurroad Kapadadevi karai chautari Kataha
## 4 11 7 17
## kaun Kawari khadha Khadrye
## 39 6 6 12
## khaluwatole Khaluwatole khaluwatole sirsiya Khaluwatole Sirsiya
## 4 9 8 5
## Khalwa tol Khardye Kharsal Kharsal purnipokhari
## 5 4 58 8
## Kharsal tole Khas karandoo Khas karkandoo khastar
## 7 6 85 9
## khaster Khumkhane Kimdi Kirana line
## 10 21 5 29
## kristi Kristi Kulayen marga Kumartole
## 29 29 6 11
## Kumhal tol Kuwari Kwangi Lachhamamu
## 11 7 17 7
## Lachhamanu Lachhumanu Lalmateya Lamachaur
## 27 7 6 5
## lamachaure Lamidada Lamidamar Lilja tole
## 14 3 3 5
## Madhumaya thapa Mainroad Maisthaan Maisthan
## 5 9 8 81
## Mandannagar Mangalpur Manihari Manikapur
## 4 13 29 84
## Matera tole Mathalno halwar Maujetole maula tol bikas
## 4 3 5 4
## Mohanpur Mohon pur tol Moteratole Mulibhagaicha
## 5 4 4 5
## Mulkot tol Murli Murli Bagaicha Murlibagaicha
## 6 12 7 4
## Musilamtol Muslimtol Nagarpalika road Naguwa
## 18 13 4 42
## Nagwa Naule tol Naulpur Naya gaun
## 26 4 9 6
## Naya tole Nayagaun Nayatole murli nirmal pkhari
## 12 11 17 3
## nirmal pokhari Nirmal pokhari nirmalpokhari Nirmalpokhari
## 35 17 5 33
## padam pokhari padampokhari Paddha padhali
## 15 4 10 11
## pain tanki Pani tanki Panitanki Parariya
## 4 4 5 3
## Parasanagar Parasnagar Paraspur Parsauni
## 4 6 105 35
## Parwanipur Paschim rampur Patahani pateheni
## 81 22 19 5
## Pathani patihani Patihani patihani town
## 5 24 104 14
## patlahara Piara Pipara Piple
## 18 19 38 3
## Piprahwa Pokheral tole Pragatinagar Prasauni
## 90 7 3 64
## Puaina Puaraina pullar Pumbdi
## 6 7 7 8
## Pumdi Pumdi bhumdi Pumdi vumdi Pumdibhumdi
## 15 5 15 8
## Pumdikot Pundgi pundi vundi pundivundi
## 4 6 4 3
## Puraina Puraini Raam tole Raampur
## 115 120 9 13
## Radha devi gurung Radhemai Rahamatpur Raikhalyan
## 5 40 10 5
## Rajbiraj Rajdevi road Rajdevi tole Rajhena
## 159 3 41 3
## Ram,gaduwa Ramgaduwa Ramgadwa Ranighat
## 7 110 14 30
## Ranighat tol Resham kothi Resham Kothi Reshamkhoti
## 5 35 8 14
## ReshamKothi Reshamkoti Reshsm kothi Ryale patle
## 5 35 7 12
## Sabathuwa Sabitawa sahardhar Sai krishna tola
## 10 13 5 5
## Sai krishna tole Sajha tol santipur sarangkot
## 4 12 23 24
## Sarangkot Sarankot Saranpur Sarbodey tole
## 12 4 43 4
## Sardar tole sardhar sardhgar Sarswati tole
## 3 5 7 3
## Shanti tole Shimra gau tol Shiromanar Shiromaninagar
## 12 7 5 6
## shiva nagar Shiva shakti Shivaghat shivanagar
## 7 2 5 31
## Shivanagar Shivnagar Shreepur Simlegaire
## 83 20 20 6
## Sirha rod Sirshiya Sirshyia Sirsiya
## 4 42 7 8
## Sisobari Sitalpur Siva shakti tole Sivanagar
## 8 5 4 27
## Sreepur Srswati tole Sugauli SUGAULI
## 18 12 30 5
## Sugauli birta Sukarua Sukaura Sunderbasti
## 53 5 5 8
## Surya nagar Swarn Swarn tole Talno halwar tol
## 9 4 21 4
## Tarigau Tarigau Basbot Tarigaun Tatrigachi
## 73 6 21 5
## Tejaratole Tetari gachhi Tetri gachi Tetri tole
## 20 10 4 7
## Tetrigachi Thangachi Thapa tol Thulo,pipra
## 3 4 3 4
## Tuhure pasal Uadayapur Udaepur ghurmi Udahapur
## 3 18 8 9
## Udayapur Udaypue Udaypur Udaypur bhurmi
## 93 6 21 5
## Udaypur ghurmi Udaypur Gurmi Udaypur,ghurmi Urahari
## 15 14 6 10
## Uttar sukaura valam Valam vedi
## 3 8 8 4
## vimshen nagar vishennagar Vishwa Yamdi
## 4 7 10 8
## yandi tol
## 3
## [1] "Frequency table after encoding"
## mid3_villagename. Villagename
## 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
## 13 5 6 81 15 8 10 11 5 5 14 19 12 23 4 8 9 3
## 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858
## 13 6 4 7 7 7 31 5 5 21 9 7 3 7 24 5 5 6
## 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876
## 3 35 4 3 27 18 21 10 29 30 92 8 73 39 10 35 8 3
## 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894
## 17 110 4 7 6 6 6 38 53 12 5 29 7 3 4 5 19 8
## 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912
## 4 4 104 5 4 5 12 6 3 5 4 9 41 12 7 10 7 40
## 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930
## 7 2 43 9 83 5 14 90 37 3 26 4 5 5 8 10 5 4
## 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948
## 15 85 29 19 4 15 5 14 4 4 55 18 20 42 8 13 13 4
## 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966
## 6 14 6 5 4 15 5 4 8 4 6 3 4 43 6 6 4 24
## 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984
## 8 40 10 8 120 2 5 12 3 3 5 5 18 14 5 11 4 5
## 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
## 58 6 2 5 11 11 3 4 26 1 16 17 3 6 8 87 17 93
## 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
## 15 5 20 8 5 4 38 4 5 11 25 64 26 17 31 5 4 90
## 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038
## 3 6 94 3 52 14 4 32 13 7 5 3 21 7 19 81 6 27
## 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
## 53 20 7 6 29 12 64 159 4 21 75 5 7 5 5 6 21 7
## 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
## 42 7 6 13 23 12 35 4 9 22 54 7 5 7 8 6 5 169
## 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
## 10 7 3 105 4 4 33 42 8 5 5 12 5 8 7 13 7 30
## 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110
## 2 9 4 84 6 9 29 9 3 5 3 4 4 5 4 4 4 4
## 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
## 3 6 14 8 5 4 4 8 11 9 35 35 6 22 16 4 115 5
## 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
## 10 10 8 6 18 24 4 15 3 5 187 18 5 3 6 6 4 4
## 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164
## 5 11 30 12 7 13 11 4 3 10 5 19 12 6 3 5 37 3
## 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
## 7 7 17 4 8 12 3 5 9 5 4 3 7 37 8 11 20 4
## 1183
## 4
## [1] "Frequency table before encoding"
## mid3_settlement.
## aadarsa mani aadarsa pokhrel tol
## 1 5 6
## aadarsa tol aadarsamani tol Aadarsh tole
## 6 6 5
## Aalau Adalat road Adarsa tol
## 37 4 6
## adarshnagar Adarshnagar Adarsnagar
## 5 4 4
## Adhikari gaun Agree gaurishankar Ahmad pur
## 4 5 6
## Alakha Road Alanagar Amar
## 8 8 4
## Ammarbasti annapurna tol Apauni
## 8 3 32
## Armalakot Ashok batika Ashokbatika
## 18 6 30
## Ashokvatika Atharaha Athraha
## 2 31 4
## Babu gaun Babugaun Badahare
## 27 11 4
## badhahare Badhare bagaicha
## 5 4 4
## Bagbani tol Baghakholi tol Bagyasworitol
## 3 4 4
## Bahaun tol bahu khola Bahuhori
## 4 5 19
## Bahuwari Bahyekhola Bajrang tole
## 9 3 5
## Bajrangi tole Bale gaun Balegaun
## 40 18 44
## Banahari Bandh tole Banjare gaau
## 9 5 20
## bankatta baralthar Barampuri
## 9 4 9
## Barauji Barewa Barwa
## 8 8 28
## Basan purawa Basantpur Basbot
## 9 15 6
## baseri tol baspani Baya khola
## 3 3 4
## Bayokhola Belanye.tol bhadgau
## 5 2 2
## bhadhahara bhadhara Bhagaerithana
## 5 4 3
## Bhagari than Bhagawanpur Bhagawati tole
## 6 5 4
## Bhagwatitol bhakti path bhalam
## 8 4 5
## bhandari dhar Bhandaridahar Bhandarigaun
## 4 5 6
## Bhansartole bhanshartole Bhata tole
## 11 7 5
## Bhawani tol Bhawanipur Bhayapur
## 11 31 10
## Bhediyahi BhgawotiTol Bhiri road
## 13 6 4
## Bhitri road Bhola chowk Bhujaigaun
## 16 7 21
## Bhujigaun Bhuwanpur Bijaya tole
## 19 4 6
## Bijeynagar Bijeynagar bazar Bijeynagar dairy
## 4 4 8
## Bijeynagar,way to haraiya Bindawasini Bindraban
## 9 61 7
## Birta Birtakhet Bishanu
## 115 6 3
## Bishnupur Bokati botetol
## 5 4 15
## Budagau Chailahe Chamartol and dhobitol
## 12 5 4
## chanauta chanaute chanutae
## 10 7 3
## Chapkaiya tole Chathghat chauntae
## 6 11 6
## Chauthari tol Chiranjivi chowk Chitraguptnagar
## 4 7 20
## Chock bajar Choudhaghare Cigarette factory
## 4 14 9
## Cigarette factory area Cold store Dadathok
## 4 5 4
## Dadathok tol Dadathok tole Dadre
## 4 3 7
## Dadrini tol Dahara Dakshin tole
## 7 3 19
## Darsa nager Dasarath nager Deurali
## 5 7 4
## Devi chook Devnagar Devthan
## 5 22 10
## Devthan tlo Devthan tol dhakalthar
## 7 5 4
## Dhale Pipal Dhalepipal dhanauji
## 3 7 5
## Dharai tol Dhore gaun Dihi
## 5 30 4
## Dihi gau Dihi tol Driport
## 10 6 10
## Duhar tole Dumari Dumri
## 6 9 40
## Duwar tole fedi fokshing deurali
## 10 4 3
## Fulbari Furhi chook Furthi chook
## 5 3 6
## Furthi chook bazer Futaha Gahatera
## 6 7 8
## Ganesh chok Ganeshgunj Ganganaga
## 8 9 5
## Ganganagar Gangapur Gapalgunj
## 51 11 7
## garjati Gauri shanker tol Gayarjati
## 15 5 4
## Geeta mandir Geetanagar ghadgai
## 8 11 22
## Ghariwarha ghimire chok tol Ghoraneti
## 42 8 8
## Ghumtichook Ghurali tol Ghurmi
## 5 4 51
## Ghurmi udayapur Ghusakpur Ghusukpur
## 4 10 17
## gimire Gitpur Gopal chook
## 7 5 4
## Gopalgunj Gorkhali Gorkhali tole
## 8 18 23
## Gouri purwa Gouriipurwa Gouripurwa
## 8 6 6
## Gumba chour Gurung gau Gurung tol
## 3 3 5
## Gurungchowk Gyanjyoti gyarjyoti
## 6 5 9
## Hal pachadi Halawar Halwar
## 12 3 11
## hanuman nagar Hanuman nagar tole hanumannagar
## 3 5 20
## Haripaura Haripauri Harpatgunj
## 4 10 38
## Harpatjanj Hatiya Himal
## 3 24 7
## Himalay tole Himalaya Himalsy tole
## 25 4 10
## Himaly tole Inaruwamaniyari Inarwa
## 2 23 14
## Indargaau Indrapuri Indrapuri chok
## 15 5 7
## jagarit tol Jagriri jagriti
## 3 8 10
## Jagriti jagriti tol Jagriti tol
## 14 3 5
## Jagriti Tol Jagritinagar Jailroad
## 5 8 12
## Jaispur Jamnaha Janajagran tol
## 96 39 5
## Janajagrati janjagriti tol Jayanagar
## 4 5 15
## Jhakaruwa Jhakrawathuti tol Jhanjhane
## 6 5 6
## Jhumaryathuti tol Jhumaryatol Jimire dil
## 5 5 6
## Jodhapurwa Kabadi tol Kabhre tole, Indrachowk
## 15 3 7
## Kabhreghat Kachili Kalakhola
## 11 7 9
## Kalayanpur bazer kalika tol Kalwatole
## 5 4 7
## Kalya khola vewdar Kalyankari tol kamere pani
## 6 4 8
## Kanchanpur road Kanchanpurtole Kanchi chok
## 3 4 9
## Kanthipur Kapadadevi karai chautari
## 24 6 7
## Karkandoo Karkichok Karkichowk
## 20 4 4
## Karmohna Kasarbag kasari
## 5 6 4
## Kaseri Kaseri dumre kastan
## 4 3 5
## Katahasami tol Katilya Katulya
## 2 4 4
## Kawari Kehuniya Kepa chock
## 6 5 4
## kesari Kesharbag khadha thare
## 3 4 6
## Khadrye Khalla Puraini khalutole
## 4 24 8
## Khaluwatole Khaluwatole sirsiya khaluwatolw
## 5 14 4
## khalwa tole Khalwatole Kharsal
## 7 7 34
## Kharsal dev tole Kharsal tole khaster
## 5 26 14
## Khayarghari Khayarghari chowki Khittari
## 6 10 2
## khlwatole Khumkhane Kigrinpurwa
## 8 21 28
## Kirana line Kodi Kohadi
## 18 6 10
## Koiri tole Kulain Kulani tole
## 10 5 4
## kulayan marga Kulayen marga Kumartole
## 5 6 11
## Kumeya Kumhal tol Kumhal tole
## 5 11 6
## Kumhaltole Kusanchour Kuwari
## 5 9 7
## Lachhamanu Lagdhawa Lalapurwa
## 41 31 30
## laliguras tol Laliguras tol Lalmatya tol
## 9 5 4
## Lamachowk Lamakhet Lamidada tol
## 5 3 3
## Lamidamar lampata Laptanchwok
## 3 3 5
## Lilja tole Lodhai Lodhai gau
## 5 5 3
## Lodhaigau Lodhayi goun Lonionpurawa
## 10 6 5
## Loniyanpurwa Lukunsawara Machhapucher tol
## 8 8 7
## Madjid tol Magar tole Magartole
## 14 3 3
## Mahajid Tol Mahapurwa Mainroad
## 6 16 9
## Maisthan Majdada Malpot tole
## 57 5 6
## Manahari Mandannagar Mangalpur bazer vitra
## 6 4 4
## Manihari Maniyadanda tol Masjid tol
## 21 2 23
## Masjid tole Maszid tole Matera
## 8 6 4
## Maujetole maula tol Milan tol
## 10 4 14
## Milantol Milijulichowk Mohanpur
## 15 5 47
## Mohanpur tol Mohonpur Motera
## 5 4 4
## Mulkot murli Murli
## 6 6 12
## Murlibagaicha MurliBagaicha Murlubagaicha
## 5 7 4
## Musilamtol Muslimtol Musulamtol
## 12 13 6
## Nabin chook nachnechaur Nadai gaun
## 3 6 5
## Nadaigaun Naditole Nagarpalika road
## 14 17 4
## Naguwa Nagwa Naharpurwa
## 23 26 24
## Namuna tol Natanpurwa Nayabasti
## 3 25 6
## Nayagaun Nayak tol Nayatole murli
## 9 9 17
## Neta chowk Neuli Neuli tol
## 4 6 6
## nirmal pokhari Nirmal pokhari Nirmal pokhri
## 17 3 5
## Nirmalpokhari Pabitra tol Pachhim sukaura
## 6 8 5
## padam pokhari padampokhari Padampokhari
## 4 15 8
## Paddha Pade ghumti padeli
## 5 6 5
## padhali Pain tanki Pakaudi
## 11 4 14
## Pani tanki Panitanki Parajuli chok
## 4 12 11
## Parariya Parasnagar Paraspur
## 10 7 47
## Parbatinagar Parsanpurawa Parsauni
## 14 9 35
## Parseni Parwanipur Pasupati
## 9 20 5
## Patelnagar Patelnager patihani town
## 8 14 14
## Patihani town patlahara Patle
## 9 18 5
## Phoolwari Tol Pipaldali Pipara
## 12 7 18
## Piple Pokheral tole Pokhreal tole
## 3 14 4
## Pothedarpurwa Pragatinagar Prasauni
## 13 11 64
## Profhesar koloni pullar Pullar
## 6 7 5
## Pumdi kot Pumdikot Puraina
## 4 7 42
## Puraini Purnipokhari Raam tole
## 21 8 9
## Raampur Raamur Radha krishna
## 6 7 5
## Radha krishna Tol radhakrishna tol Radhakrishna tol
## 4 3 18
## radhakrisna tol Radhakrisna tole Radhapur
## 6 7 46
## Radhemai Rahamatpur Rajdevi
## 36 10 6
## Rajdevi road Rajdevi tole Rajhana tol
## 3 23 5
## Rajhanatol Rajhena tharugau Rajheni tol
## 6 3 5
## Ram Ram tol Rameshorpurwa
## 4 4 46
## Ramgaduwa Ramgadwa Ramghadwa
## 112 14 5
## Ramtole Ramwapur Ranighat
## 12 52 30
## Resham kothi Resham Kothi Reshamkhoti
## 15 18 7
## Reshamkothi Reshamkoti Reshan kothi
## 12 35 17
## Risinge tole Road tol Sabaithuwa
## 6 8 10
## Sabitawa Sai krishna Sai krishna tole
## 13 4 6
## Saja sajha sidhartha sajha sidhartha tol
## 4 6 8
## sajha tol Sajha tol Sangamtol
## 8 12 4
## Sanoganesh gunj Santi chook santipur
## 3 4 23
## Saranpur Saraswati tole Sarbodeytole
## 6 3 4
## Sardar tole sardhar saudaha
## 3 12 6
## Saudahachautara Sauraha School road
## 5 30 7
## School road/ malpot road Shanti Shanti tol
## 7 11 14
## Shanti tole Shantichowk Shantitol
## 12 11 24
## shardhar Shibnagar Shimragau
## 5 4 7
## Shiromani Shiromaninagar Shiva chock
## 6 11 6
## Shiva Shakti tol Shivaghat aagadi Shivanagar
## 2 5 39
## Shivashakti tol Shivnagar Shivthan
## 4 20 8
## Shreepur sibalaya Sibalaya
## 24 11 7
## Sibasundar tol simalchair simalchaur
## 10 4 7
## simalchaur tol Simlegaire Siraha road
## 3 6 4
## Sirha rod Sirisiya khalwa Sirsiya
## 4 5 8
## Sisobari Sitalpur Srswatitole
## 8 11 12
## Sugauli birta suikhet Suikhet
## 62 11 12
## Suiya Sukaura tol Sukidaha
## 29 5 3
## Sunaulo tol Sunaulo tol Sundada
## 6 4 10
## sundada khet Sundarchok Sunder basti
## 16 4 4
## Sunderbasti Surya nagar Suryanagar
## 23 5 3
## Swara swaraha Swarn tole
## 5 4 25
## Swarna tole swekhet swikhet
## 4 10 3
## Syalghari Taajpur Tanga tole
## 14 29 7
## Tangpasri Tarigai tharugaun Tarigain
## 33 4 5
## Tejaratole Telipatti Telipatti mas
## 20 15 7
## Teliyanpur Tetari gachhi Tetri gachi
## 12 10 3
## Tetri tole Tetrihi tole Thangaxi
## 11 5 4
## thapa Thapa gau Thapa tol
## 3 3 10
## thulachaur Thulachaur Thulachawor
## 4 3 4
## Thulachhaur Thulo pipara Thulo,pipra
## 6 15 4
## Thulobesi marga Treebenitol Tuhure pasal
## 7 4 3
## Tulo pipara Udayapur Udaypur bhurmi
## 5 5 5
## Udaypur ghurmi Udaypur Gurmi Ujalnagar
## 5 14 5
## Ujjewalnagar Ujjwalnagar Urahari rajmarg tol
## 5 51 5
## Uttar sukaura Uttarsukaura Valuwahi
## 3 5 5
## Vangushara Vatha tole Vawanpur
## 4 4 6
## Vhagabati Vhagawanpur Vidhyapith
## 3 7 12
## vimsennagar vimshen nagar vimshen nager
## 6 7 4
## vimshennagar Vishwa word office
## 21 10 4
## yamdi Yamdi Yamdi Tol
## 13 6 8
## Yatimkhana tol
## 14
## [1] "Frequency table after encoding"
## mid3_settlement.
## 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964
## 5 6 5 3 3 5 3 5 6 6 3 35 9 8 7 4 4 2
## 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
## 3 20 7 6 30 5 62 7 12 3 23 15 5 3 44 15 2 15
## 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
## 12 3 5 3 11 9 36 41 4 8 18 9 7 7 6 12 5 7
## 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
## 5 3 21 4 5 15 20 7 14 7 47 4 24 8 7 10 4 6
## 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
## 9 4 4 3 6 6 4 10 6 5 10 3 7 10 11 51 4 23
## 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
## 4 52 11 4 4 4 3 6 6 5 14 24 5 3 8 5 4 5
## 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
## 7 5 4 17 4 12 3 11 6 8 6 4 10 21 9 6 10 5
## 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
## 4 6 3 17 11 11 7 11 8 4 5 5 18 5 3 6 3 5
## 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
## 17 5 6 5 19 5 6 4 8 12 7 7 7 4 4 8 4 8
## 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
## 38 23 7 5 4 7 64 10 14 6 15 6 21 3 7 20 18 4
## 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
## 7 6 6 5 5 3 31 7 5 11 14 5 7 6 8 5 33 7
## 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162
## 12 3 4 12 4 3 6 6 9 4 13 14 4 23 4 10 4 4
## 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
## 3 6 9 4 6 7 5 17 28 2 16 4 7 5 5 10 3 12
## 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
## 4 23 4 4 5 10 5 14 5 9 2 8 3 5 7 10 5 6
## 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216
## 6 7 34 7 8 12 5 4 10 4 5 5 5 6 3 3 31 25
## 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234
## 14 24 4 6 4 35 4 10 46 4 4 4 8 6 4 5 6 4
## 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252
## 3 42 9 4 10 10 5 17 10 2 27 24 3 8 6 5 5 8
## 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270
## 4 7 30 5 5 5 8 4 8 9 20 3 4 9 6 6 8 5
## 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288
## 4 30 19 20 12 15 4 6 12 20 6 5 42 8 18 11 3 4
## 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
## 4 3 3 13 5 14 4 26 13 4 6 5 9 4 8 40 4 14
## 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324
## 5 6 7 15 3 9 5 4 4 5 9 4 6 6 6 6 29 3
## 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342
## 5 4 4 3 7 5 4 3 4 4 18 5 5 21 5 3 6 14
## 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
## 3 7 32 7 24 4 3 5 6 96 5 14 5 4 11 4 4 16
## 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378
## 5 29 25 8 10 7 10 3 5 5 3 51 112 4 6 6 4 11
## 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
## 3 22 7 8 18 3 11 8 18 4 6 15 7 6 5 4 4 11
## 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
## 57 9 30 4 7 7 5 4 7 31 8 5 5 12 8 8 39 12
## 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432
## 9 21 4 5 4 2 13 11 6 4 7 10 3 4 14 3 9 10
## 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450
## 46 14 5 5 11 1 3 5 15 5 26 5 3 10 4 14 47 5
## 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468
## 6 37 9 5 30 4 6 23 22 4 4 8 13 61 10 15 25 4
## 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486
## 9 11 5 5 6 9 16 10 8 5 15 115 11 5 5 39 14 5
## 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504
## 20 8 6 6 8 8 51 4 5 3 3 10 14 3 12 5 4 5
## 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522
## 8 24 6 11 6 18 14 6 12 11 2 2 4 3 4 6 23 4
## 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
## 6 6 11 7 19 9 8 7 28 12 4 14 40 6 6 4 4 6
## 1541
## 4
## [1] "Frequency table before encoding"
## mid3_municipality.
## 1 2 3 4 5 6 <NA>
## 932 2219 1118 860 572 567 1
## [1] "Frequency table after encoding"
## mid3_municipality.
## 747 748 749 750 751 752 <NA>
## 860 567 932 572 2219 1118 1
## [1] "Frequency table before encoding"
## mid3_wardno.
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## 160 180 156 79 75 124 133 78 114 96 41 68 193 109 133 220 254 334
## 19 20 21 22 23 24 25 26 27 28 29 30 <NA>
## 348 307 286 356 315 309 325 366 388 382 237 102 1
## [1] "Frequency table after encoding"
## mid3_wardno.
## 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
## 75 79 41 114 133 156 325 334 220 382 309 68 315 286 96 348 366 254
## 129 130 131 132 133 134 135 136 137 138 139 140 <NA>
## 388 133 193 109 180 102 124 78 160 356 307 237 1
## [1] "Frequency table before encoding"
## mid3_child_municipality.
## 1 3 4 5 6 <NA>
## 53 29 63 21 6 6097
## [1] "Frequency table after encoding"
## mid3_child_municipality.
## 497 498 499 500 501 <NA>
## 21 63 53 29 6 6097
## [1] "Frequency table before encoding"
## mid3_child_wardno. Ward No.
## 1 2 3 4 5 9 10 13 15 16 17 18 19 20 21 23 24 25
## 1 1 2 2 8 6 1 1 7 7 1 13 16 21 5 16 20 13
## 26 27 28 29 <NA>
## 10 14 6 1 6097
## [1] "Frequency table after encoding"
## mid3_child_wardno. Ward No.
## 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
## 1 6 16 10 5 14 16 7 21 13 8 7 1 20 1 1 2 1
## 367 368 369 370 <NA>
## 2 13 6 1 6097
## [1] "Frequency table before encoding"
## mid3_child_villagename. Name of the village/ community
## Aadarsha tol badhahare tol Basantpur tole bhakti path bhalam
## 6097 1 1 3 2 4
## Bhalam bhandari dhar Bhawaniyapur Bijeynagar Dadathok tol Deurali piple
## 1 1 9 7 1 3
## Dhadagari Dhalepipal Furthi chook garjati Geetanagar Golouri
## 1 1 4 2 10 1
## Gopal chook Hatiya hemja Hemja Himalay tole Indarpur
## 1 1 5 4 8 10
## Kahu kahun kaun khadha khastar khaster
## 1 1 1 1 2 1
## Kirana line kristi Kristi Lamachaur lamachaure Mangalpur
## 2 8 4 2 2 1
## Moteratole Nirmalpokhari padhali Paschim rampur Patihani patihani town
## 2 3 1 1 5 2
## Piprahwa Pumdi vumdi Pundgi Raampur Rajbiraj Rajdevi tole
## 5 3 1 1 3 2
## sarangkot Saranpur shiva nagar shivanagar Shivanagar Tatrigachi
## 3 1 1 6 10 3
## Tetari gachhi Tuhure pasal Udayapur Valam vishennagar
## 1 2 5 3 1
## [1] "Frequency table after encoding"
## mid3_child_villagename. Name of the village/ community
## 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918
## 2 3 2 1 5 2 1 2 7 3 4 4 1 2 1 10 8 3
## 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936
## 1 1 5 2 2 6 3 1 1 1 3 1 3 1 3 2 1 10
## 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954
## 1 1 1 1 2 1 8 5 1 2 3 4 1 9 6097 1 1 4
## 955 956 957 958 959
## 1 10 5 1 1
## [1] "Frequency table before encoding"
## mid3_child_settlement. Name of the Settlements
## Agree gaurishankar Amar annapurna tol
## 6097 1 1 1
## badhahare Badhare Balegaun Banjare gaau
## 1 2 9 3
## Basantpur Baya khola bhadgau Bhagaerithana
## 3 2 2 2
## bhakti path bhalam bhandari dhar Bhandaridahar
## 2 1 1 2
## Bhandarigaun Bijaya tole Bijeynagar Bijeynagar dairy
## 2 3 2 2
## Dadathok tole Darsa nager Deurali Devi chook
## 1 1 1 1
## Dhalepipal Dumri Furthi chook Furthi chook bazer
## 1 1 1 1
## Ganganaga Gangapur garjati Geetanagar
## 2 3 2 2
## Gorkhali Gorkhali tole Gurung gau gyarjyoti
## 1 1 1 1
## Hatiya Himalay tole Himalsy tole Himaly tole
## 1 4 3 1
## Indargaau Jamnaha Jayanagar Jhanjhane
## 4 4 3 1
## kastan khadha thare khaster Khittari
## 1 1 2 1
## Kirana line Kodi Kulani tole Kusanchour
## 1 1 2 2
## laliguras tol Motera nachnechaur padhali
## 2 2 1 1
## Pakaudi Parajuli chok patihani town Patihani town
## 1 1 2 2
## Pokhreal tole Pumdi kot Pumdikot Raampur
## 1 1 2 1
## Radha krishna Tol Radhakrishna tol radhakrisna tol Radhapur
## 1 4 1 3
## Rajdevi tole Ramwapur Sangamtol Santi chook
## 2 3 2 1
## saudaha Shantichowk Shivanagar simalchaur
## 2 1 5 2
## Syalghari Tangpasri Tetari gachhi Tetrihi tole
## 1 1 1 3
## thapa thulachaur Thulachaur Thulachhaur
## 2 2 1 2
## Tuhure pasal Udayapur Ujalnagar Ujjwalnagar
## 2 2 1 5
## vimsennagar vimshen nagar vimshennagar word office
## 2 1 4 2
## yamdi
## 1
## [1] "Frequency table after encoding"
## mid3_child_settlement. Name of the Settlements
## 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
## 2 1 2 2 1 4 5 2 2 3 3 2 2 2 1 1 2 1
## 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978
## 1 1 1 1 3 1 1 2 2 1 1 2 1 1 2 1 1 1
## 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996
## 1 1 3 1 2 1 2 1 1 3 2 4 2 4 2 1 2 1
## 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
## 1 2 6097 3 1 2 1 1 3 1 9 1 2 2 2 1 2 1
## 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032
## 2 1 3 1 1 1 3 1 1 1 2 4 2 4 1 2 2 1
## 1033 1034 1035
## 5 1 2
# Focus on variables with a "Lowest Freq" of 10 or less.
mydata <- top_recode ("mid3_s3q3", break_point=80, missing=999999) # Topcode cases age 80 or older
## [1] "Frequency table before encoding"
## mid3_s3q3. Age in completed years at the time of survey:
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
## 16 33 52 86 93 106 106 168 170 158 185 133 182 185 199 172 156 135
## 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
## 153 89 88 38 69 41 38 86 60 64 74 46 134 39 135 64 50 189
## 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
## 99 58 90 47 186 49 103 45 34 135 30 32 35 20 82 21 32 28
## 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
## 16 64 27 21 19 14 57 21 21 22 20 55 19 12 20 11 46 6
## 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
## 22 12 8 23 6 3 6 4 7 2 4 1 2 5 2 2 1 1
## 90 92 98 100 <NA>
## 3 3 1 1 761
## [1] "Frequency table after encoding"
## mid3_s3q3. Age in completed years at the time of survey:
## 0 1 2 3 4 5 6 7
## 16 33 52 86 93 106 106 168
## 8 9 10 11 12 13 14 15
## 170 158 185 133 182 185 199 172
## 16 17 18 19 20 21 22 23
## 156 135 153 89 88 38 69 41
## 24 25 26 27 28 29 30 31
## 38 86 60 64 74 46 134 39
## 32 33 34 35 36 37 38 39
## 135 64 50 189 99 58 90 47
## 40 41 42 43 44 45 46 47
## 186 49 103 45 34 135 30 32
## 48 49 50 51 52 53 54 55
## 35 20 82 21 32 28 16 64
## 56 57 58 59 60 61 62 63
## 27 21 19 14 57 21 21 22
## 64 65 66 67 68 69 70 71
## 20 55 19 12 20 11 46 6
## 72 73 74 75 76 77 78 79
## 22 12 8 23 6 3 6 4
## 80 or more <NA>
## 35 761
mydata <- top_recode ("mid3_s4q7", break_point=60, missing=999999) # Topcode cases with 60 or farther
## [1] "Frequency table before encoding"
## mid3_s4q7. How far is the school from home?
## 0 1 2 3 4 5 6 7 8 9 10 12 20 45 130 200 320 500
## 73 740 367 153 29 64 12 10 4 3 7 3 1 1 1 8 1 34
## 520 <NA>
## 1 4757
## [1] "Frequency table after encoding"
## mid3_s4q7. How far is the school from home?
## 0 1 2 3 4 5 6 7
## 73 740 367 153 29 64 12 10
## 8 9 10 12 20 45 60 or more <NA>
## 4 3 7 3 1 1 45 4757
mydata <- top_recode ("mid3_child_nhhmmbrs", break_point=10, missing=999999) # Topcode cases with 10 or more members
## [1] "Frequency table before encoding"
## mid3_child_nhhmmbrs.
## 2 3 4 5 6 7 8 10 13 <NA>
## 11 31 46 32 25 13 10 3 1 6097
## [1] "Frequency table after encoding"
## mid3_child_nhhmmbrs. 10
## 2 3 4 5 6 7 8 10 or more
## 11 31 46 32 25 13 10 4
## <NA>
## 6097
mydata <- top_recode ("mid3_s17q7", break_point=60, missing=999999) # Topcode cases with 60 or farther
## [1] "Frequency table before encoding"
## mid3_s17q7. How far is the school from home?
## 0 1 2 3 4 5 6 7 8 9 10 12 13 30 45 200 500 <NA>
## 82 712 329 142 29 60 15 9 4 2 8 2 1 2 1 9 34 4828
## [1] "Frequency table after encoding"
## mid3_s17q7. How far is the school from home?
## 0 1 2 3 4 5 6 7
## 82 712 329 142 29 60 15 9
## 8 9 10 12 13 30 45 60 or more
## 4 2 8 2 1 2 1 43
## <NA>
## 4828
mydata <- top_recode ("mid3_s4q8", break_point=60, missing=999999) # Topcode cases with 60 or longer
## [1] "Frequency table before encoding"
## mid3_s4q8. How long does it take to get to this school?
## 0 1 2 3 5 6 7 8 9 10 12 13 15 16 18 20 25 26
## 6 7 10 5 341 1 3 7 2 443 8 1 420 1 4 259 76 1
## 28 30 35 38 40 45 50 60 65 80 120 180 240 <NA>
## 4 251 17 1 7 21 3 53 1 3 1 1 1 4310
## [1] "Frequency table after encoding"
## mid3_s4q8. How long does it take to get to this school?
## 0 1 2 3 5 6 7 8
## 6 7 10 5 341 1 3 7
## 9 10 12 13 15 16 18 20
## 2 443 8 1 420 1 4 259
## 25 26 28 30 35 38 40 45
## 76 1 4 251 17 1 7 21
## 50 60 or more <NA>
## 3 60 4310
# !!!Include relevant variables in list below
indirect_PII <- c("mid3_occup0",
"mid3_s5q6c",
"mid3_occup1",
"mid3_s19q4c",
"mid3_ind0",
"mid3_s5q6_2c",
"mid3_ind1",
"mid3_s19q4bc",
"mid3_nhhmmbrs",
"mid3_s8q0",
"mid3_s10q6b",
"mid3_s11q2",
"mid3_s11q3",
"mid3_s11q4",
"mid3_s11q5",
"mid3_s11q6",
"mid3_s11q7",
"mid3_s11q8",
"mid3_s11q9",
"mid3_s13q1_1",
"mid3_s13q1_2",
"mid3_s13q1_3",
"mid3_s13q1_4",
"mid3_s13q1_5",
"mid3_s13q1_6",
"mid3_s13q1_7",
"mid3_s13q1_8",
"mid3_s13q1_9",
"mid3_s13q1_10",
"mid3_s13q1_11",
"mid3_s13q1_12",
"mid3_s13q1_13",
"mid3_s13q1_14",
"mid3_s13q1_96",
"mid3_s3q2",
"mid3_s3q2a",
"mid3_s3q3",
"mid3_s3q4",
"mid3_s3q5_1",
"mid3_onlychild",
"mid3_s3q6",
"mid3_s3q7",
"mid3_s3q8",
"mid3_s3q9a",
"mid3_s3q9b",
"mid3_s3q9c",
"mid3_s3q9d",
"mid3_s3q9e",
"mid3_s3q10",
"mid3_s4q1",
"mid3_s4q2",
"mid3_s4q3",
"mid3_s4q3_1",
"mid3_s4q4",
"mid3_s4q6_1",
"mid3_s4q6_2",
"mid3_s4q6_5",
"mid3_s4q6_9",
"mid3_s4q7",
"mid3_s4q8",
"mid3_s4q9",
"mid3_s4q9_1",
"mid3_s4q9_2",
"mid3_s4q9_3",
"mid3_s4q9_4",
"mid3_s4q9_5",
"mid3_s4q9_6",
"mid3_s4q9_7",
"mid3_s4q9_8",
"mid3_s4q9_96",
"mid3_s5q1",
"mid3_s5q1_1",
"mid3_s5q1_2",
"mid3_s5q1_3",
"mid3_s5q1_4",
"mid3_s5q1_5",
"mid3_s5q1_6",
"mid3_s5q1_7",
"mid3_s5q1_8",
"mid3_s5q1_9",
"mid3_s5q2a",
"mid3_s5q2b",
"mid3_s5q2c",
"mid3_s5q2d",
"mid3_s5q2e",
"mid3_s5q2f",
"mid3_s5q2g",
"mid3_s5q2h",
"mid3_s5q3",
"mid3_s5q4a",
"mid3_s5q4b",
"mid3_s5q4c",
"mid3_s5q4d",
"mid3_s5q4e",
"mid3_s5q4f",
"mid3_s5q4g",
"mid3_s5q4h",
"mid3_s5q4i",
"mid3_s5q5",
"mid3_s5q6a",
"mid3_s5q7",
"mid3_s5q8",
"mid3_s5q9",
"mid3_s5q11",
"mid3_s5q12",
"mid3_s5q15",
"mid3_s5q16",
"mid3_s5q18",
"mid3_s6q2",
"mid3_s6q7",
"mid3_s6q8",
"mid3_s16q3",
"mid3_s17q1",
"mid3_s17q2",
"mid3_s17q3",
"mid3_s17q4",
"mid3_s17q7",
"mid3_s17q8",
"mid3_s17q8_1",
"mid3_s17q8_2",
"mid3_s17q8_3",
"mid3_s17q8_4",
"mid3_s17q8_5",
"mid3_s17q8_6",
"mid3_s17q8_7",
"mid3_s17q8_8",
"mid3_s18q1_1",
"mid3_s18q1_2",
"mid3_s18q1_3",
"mid3_s18q1_4",
"mid3_s18q1_5",
"mid3_s18q1_6",
"mid3_s18q1_7",
"mid3_s18q1_8",
"mid3_s18q1_9",
"mid3_s18q2a",
"mid3_s18q2b",
"mid3_s18q2c",
"mid3_s18q2d",
"mid3_s18q2e",
"mid3_s18q2f",
"mid3_s18q2g",
"mid3_s18q2h",
"mid3_s18q3_1",
"mid3_s18q3_2",
"mid3_s18q3_3",
"mid3_s18q3_4",
"mid3_s18q3_5",
"mid3_s18q3_96",
"mid3_s18q4",
"mid3_s19q1",
"mid3_s19q2a",
"mid3_s19q2b",
"mid3_s19q2c",
"mid3_s19q2d",
"mid3_s19q2e",
"mid3_s19q2f",
"mid3_s19q2g",
"mid3_s19q2h",
"mid3_s19q2i",
"mid3_s19q3",
"mid3_s19q4a",
"mid3_s19q5",
"mid3_s19q6",
"mid3_s19q7",
"mid3_s19q12",
"mid3_s19q13",
"mid3_s19q14",
"mid3_s20q2",
"mid3_s20q4",
"mid3_s20q5",
"mid3_s20q7",
"mid3_s20q8",
"mid3_child_nhhmmbrs",
"mid3_numhhmbrs",
"mid3_female",
"mid3_ppi1",
"mid3_ppi2",
"mid3_ppi3",
"mid3_ppi4",
"mid3_ppi5",
"mid3_ppi6",
"mid3_ppi7",
"mid3_ppi8",
"mid3_ppi9",
"mid3_ppi10",
"mid3_CL_P",
"mid3_CL_C",
"mid3_CLC5_11",
"mid3_CLC12_13",
"mid3_CLC14_15",
"mid3_CLP5_11",
"mid3_CLP12_13",
"mid3_CLP14_15")
capture_tables (indirect_PII)
# Recode those with very specific values
# Removed, as verbatim responses are partially or entirely in Nepali.
dropvars <- c("mid3_occup0", "mid3_occup1", "mid3_ind0", "mid3_ind1")
mydata <- mydata[!names(mydata) %in% dropvars]
# Top code household composition variables with large and unusual numbers
mydata <- top_recode ("mid3_nhhmmbrs", break_point=10, missing=c(999999)) # Topcode cases with 10 or more members
## [1] "Frequency table before encoding"
## mid3_nhhmmbrs.
## 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 26
## 119 655 1154 1403 1115 558 434 148 165 126 152 86 42 32 17 23 19 20
## <NA>
## 1
## [1] "Frequency table after encoding"
## mid3_nhhmmbrs. 10
## 2 3 4 5 6 7 8 9
## 119 655 1154 1403 1115 558 434 148
## 10 or more <NA>
## 682 1
mydata <- top_recode ("mid3_numhhmbrs", break_point=10, missing=c(999999)) # Topcode cases with 10 or more members
## [1] "Frequency table before encoding"
## mid3_numhhmbrs.
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 19 20
## 1 56 443 968 1183 1169 831 447 342 190 99 192 90 98 30 68 19 20
## 23
## 23
## [1] "Frequency table after encoding"
## mid3_numhhmbrs. 10
## 1 2 3 4 5 6 7 8
## 1 56 443 968 1183 1169 831 447
## 9 10 or more
## 342 829
# Based on dictionary inspection, select variables for creating sdcMicro object
# See: https://sdcpractice.readthedocs.io/en/latest/anon_methods.html
# All variable names should correspond to the names in the data file
# selected categorical key variables: gender, occupation/education and age
mydata$sex <- mydata$mid3_s3q2
mydata$sex [is.na(mydata$sex)] <- mydata$mid3_s3q2a[is.na(mydata$sex)]
selectedKeyVars = c('sex', 'mid3_s3q8', 'mid3_s3q3') ##!!! Replace with candidate categorical demo vars
# weight variable
# !!! No weight
# selectedWeightVar = c('projwt') ##!!! Replace with weight var
# household id variable (cluster)
selectedHouseholdID = c('hhid')
# creating the sdcMicro object with the assigned variables
sdcInitial <- createSdcObj(dat = mydata,
keyVars = selectedKeyVars,
hhId = selectedHouseholdID)
## Warning in cbind(reshier, unique(dataX[, 1])): number of rows of result is not a multiple
## of vector length (arg 1)
sdcInitial
## The input dataset consists of 6269 rows and 552 variables.
## --> Categorical key variables: sex, mid3_s3q8, mid3_s3q3
## --> Cluster/Household-Id variable: hhid
## ----------------------------------------------------------------------
## Information on categorical key variables:
##
## Reported is the number, mean size and size of the smallest category >0 for recoded variables.
## In parenthesis, the same statistics are shown for the unmodified data.
## Note: NA (missings) are counted as seperate categories!
## Key Variable Number of categories Mean size Size of smallest (>0)
## sex 3 (3) 2753.000 (2753.000) 2724 (2724)
## mid3_s3q8 10 (10) 580.556 (580.556) 3 (3)
## mid3_s3q3 82 (82) 68.000 (68.000) 3 (3)
## ----------------------------------------------------------------------
## Infos on 2/3-Anonymity:
##
## Number of observations violating
## - 2-anonymity: 146 (2.329%)
## - 3-anonymity: 324 (5.168%)
## - 5-anonymity: 808 (12.889%)
##
## ----------------------------------------------------------------------
Show values of key variable of records that violate k-anonymity
notAnon <- sdcInitial@risk$individual[,2] < 2 # for 2-anonymity
as.data.frame(mydata[notAnon,selectedKeyVars])
## sex mid3_s3q8 mid3_s3q3
## 1 1 3 70
## 2 1 6 8
## 3 1 1 65
## 4 0 98 70
## 5 1 3 53
## 6 1 98 65
## 7 0 4 58
## 8 1 3 55
## 9 1 3 47
## 10 0 1 31
## 11 1 3 56
## 12 1 4 15
## 13 0 5 48
## 14 1 6 5
## 15 0 3 62
## 16 0 3 61
## 17 1 1 57
## 18 1 4 64
## 19 1 2 51
## 20 1 3 61
## 21 1 98 22
## 22 1 5 43
## 23 0 5 57
## 24 1 2 47
## 25 0 1 71
## 26 1 0 71
## 27 1 6 55
## 28 1 6 56
## 29 1 4 60
## 30 0 1 66
## 31 0 5 19
## 32 1 6 14
## 33 0 0 12
## 34 0 2 69
## 35 0 4 34
## 36 0 3 71
## 37 0 5 37
## 38 1 1 67
## 39 0 6 7
## 40 0 5 54
## 41 0 5 70
## 42 0 5 62
## 43 0 0 58
## 44 1 98 24
## 45 0 5 79
## 46 1 4 45
## 47 0 2 57
## 48 0 4 48
## 49 1 99 28
## 50 0 4 61
## 51 1 3 51
## 52 1 1 24
## 53 0 5 38
## 54 0 0 54
## 55 0 2 10
## 56 0 0 79
## 57 0 1 24
## 58 0 0 10
## 59 0 1 67
## 60 0 98 49
## 61 0 98 60
## 62 1 3 52
## 63 1 98 48
## 64 0 0 23
## 65 0 6 13
## 66 0 3 76
## 67 1 4 10
## 68 1 1 69
## 69 1 1 70
## 70 0 2 75
## 71 0 3 72
## 72 1 2 69
## 73 0 2 80
## 74 0 1 33
## 75 1 5 27
## 76 0 4 59
## 77 1 2 55
## 78 1 3 64
## 79 1 6 60
## 80 0 6 77
## 81 1 4 46
## 82 0 5 66
## 83 1 98 7
## 84 0 5 60
## 85 1 3 58
## 86 0 6 11
## 87 0 6 6
## 88 1 6 32
## 89 1 2 54
## 90 1 6 25
## 91 0 4 49
## 92 0 6 10
## 93 1 5 26
## 94 0 5 47
## 95 0 3 68
## 96 1 99 73
## 97 0 2 60
## 98 0 3 54
## 99 1 98 80
## 100 0 4 66
## 101 1 6 23
## 102 1 0 9
## 103 1 4 53
## 104 0 1 51
## 105 0 4 31
## 106 1 1 44
## 107 0 3 51
## 108 1 2 49
## 109 1 2 9
## 110 1 2 63
## 111 1 2 61
## 112 0 6 5
## 113 0 6 8
## 114 0 98 40
## 115 1 3 11
## 116 0 4 24
## 117 0 5 56
## 118 0 3 66
## 119 1 98 21
## 120 1 98 18
## 121 1 4 38
## 122 1 3 63
## 123 1 4 49
## 124 0 0 27
## 125 1 6 19
## 126 1 2 60
## 127 0 3 64
## 128 1 0 76
## 129 0 6 64
## 130 1 1 74
## 131 0 4 55
## 132 1 2 74
## 133 0 4 62
## 134 0 1 74
## 135 0 0 44
## 136 1 98 32
## 137 0 5 49
## 138 0 2 27
## 139 1 1 46
## 140 1 3 49
## 141 0 98 80
## 142 1 99 36
## 143 0 3 53
## 144 1 98 23
## 145 1 6 33
## 146 0 4 57
sdcFinal <- localSuppression(sdcInitial)
## Warning in cbind(reshier, unique(dataX[, 1])): number of rows of result is not a multiple
## of vector length (arg 1)
# Recombining anonymized variables (exclude children, as critical for analysis)
extractManipData(sdcFinal)[notAnon,selectedKeyVars] # manipulated variables HH
## Warning in if (cc != class(v_p)) {: the condition has length > 1 and only the first element
## will be used
## Warning in if (cc != class(v_p)) {: the condition has length > 1 and only the first element
## will be used
## sex mid3_s3q8 mid3_s3q3
## 7 1 3 NA
## 9 1 6 NA
## 26 1 1 NA
## 42 0 98 NA
## 88 1 3 NA
## 159 1 98 NA
## 181 0 4 NA
## 182 1 3 NA
## 201 1 3 NA
## 209 0 1 NA
## 213 1 3 NA
## 216 1 4 NA
## 237 0 5 NA
## 299 1 6 NA
## 354 0 3 NA
## 390 0 3 NA
## 441 1 1 NA
## 490 1 4 NA
## 538 1 2 NA
## 544 1 3 NA
## 604 1 98 NA
## 624 1 5 NA
## 677 0 5 NA
## 696 1 2 NA
## 750 0 1 NA
## 815 1 0 NA
## 821 1 6 NA
## 867 1 6 NA
## 906 1 4 NA
## 951 0 1 NA
## 990 0 5 NA
## 1028 1 6 NA
## 1085 0 0 NA
## 1222 0 2 NA
## 1256 0 4 NA
## 1302 0 3 NA
## 1304 0 5 NA
## 1430 1 1 NA
## 1464 0 6 NA
## 1538 0 5 NA
## 1570 0 5 NA
## 1594 0 5 NA
## 1971 0 0 NA
## 2008 1 98 NA
## 2047 0 5 NA
## 2049 1 4 NA
## 2059 0 2 NA
## 2117 0 4 NA
## 2174 1 99 NA
## 2190 0 4 NA
## 2191 1 3 NA
## 2202 1 1 NA
## 2225 0 5 NA
## 2243 0 0 NA
## 2323 0 2 NA
## 2353 0 0 NA
## 2370 0 1 NA
## 2375 0 0 NA
## 2401 0 1 NA
## 2437 0 98 NA
## 2460 0 98 NA
## 2509 1 3 NA
## 2577 1 98 NA
## 2678 0 0 NA
## 2679 0 6 NA
## 2742 0 3 NA
## 2803 1 4 NA
## 2850 1 1 NA
## 2890 1 1 NA
## 2929 0 2 NA
## 2945 0 3 NA
## 2946 1 2 NA
## 3001 0 2 NA
## 3048 0 1 NA
## 3050 1 5 NA
## 3051 0 4 NA
## 3087 1 2 NA
## 3108 1 3 NA
## 3112 1 6 NA
## 3116 0 6 NA
## 3118 1 4 NA
## 3268 0 5 NA
## 3292 1 98 NA
## 3304 0 5 NA
## 3311 1 3 NA
## 3383 0 6 NA
## 3386 0 6 NA
## 3388 1 6 NA
## 3398 1 2 NA
## 3405 1 6 NA
## 3451 0 4 NA
## 3491 0 6 NA
## 3507 1 5 NA
## 3583 0 5 NA
## 3640 0 3 NA
## 3652 1 99 NA
## 3700 0 2 NA
## 3773 0 3 NA
## 3781 1 98 NA
## 3853 0 4 NA
## 3931 1 6 NA
## 3983 1 0 NA
## 4030 1 4 NA
## 4115 0 1 NA
## 4204 0 4 NA
## 4245 1 1 NA
## 4262 0 3 NA
## 4308 1 2 NA
## 4374 1 2 NA
## 4395 1 2 NA
## 4526 1 2 NA
## 4605 0 6 NA
## 4606 0 6 NA
## 4609 0 98 NA
## 4652 1 3 NA
## 4686 0 4 NA
## 4755 0 5 NA
## 4771 0 3 NA
## 4803 1 98 NA
## 4806 1 98 NA
## 4873 1 4 NA
## 4879 1 3 NA
## 4975 1 4 NA
## 5182 0 0 NA
## 5201 1 6 NA
## 5248 1 2 NA
## 5250 0 3 NA
## 5262 1 0 NA
## 5408 0 6 NA
## 5478 1 1 NA
## 5480 0 4 NA
## 5515 1 2 NA
## 5518 0 4 NA
## 5540 0 1 NA
## 5567 0 0 NA
## 5577 1 98 NA
## 5695 0 5 NA
## 5764 0 2 NA
## 5905 1 1 NA
## 5918 1 3 NA
## 5931 0 98 NA
## 5956 1 99 NA
## 6045 0 3 NA
## 6102 1 98 NA
## 6120 1 6 NA
## 6264 0 4 NA
mydata [notAnon & mydata$mid3_s3q3 >17,"mid3_s3q3"] <- NA
#Check that 2-anonimity is now maintained
createSdcObj(dat = mydata, keyVars = selectedKeyVars, hhId = selectedHouseholdID)
## Warning in cbind(reshier, unique(dataX[, 1])): number of rows of result is not a multiple
## of vector length (arg 1)
## The input dataset consists of 6269 rows and 552 variables.
## --> Categorical key variables: sex, mid3_s3q8, mid3_s3q3
## --> Cluster/Household-Id variable: hhid
## ----------------------------------------------------------------------
## Information on categorical key variables:
##
## Reported is the number, mean size and size of the smallest category >0 for recoded variables.
## In parenthesis, the same statistics are shown for the unmodified data.
## Note: NA (missings) are counted as seperate categories!
## Key Variable Number of categories Mean size Size of smallest (>0)
## sex 3 (3) 2753.000 (2753.000) 2724 (2724)
## mid3_s3q8 10 (10) 580.556 (580.556) 3 (3)
## mid3_s3q3 82 (82) 66.432 (66.432) 2 (2)
## ----------------------------------------------------------------------
## Infos on 2/3-Anonymity:
##
## Number of observations violating
## - 2-anonymity: 0 (0.000%)
## - 3-anonymity: 0 (0.000%)
## - 5-anonymity: 18 (0.287%)
##
## ----------------------------------------------------------------------
mydata <- mydata[!names(mydata) %in% "sex"]
# !!! Identify open-end variables here:
open_ends <- c("mid3_s9q1_1other",
"mid3_s9q2_2other",
"mid3_s9q2_1other",
"mid3_s9q1_2other",
"mid3_s9q5other",
"mid3_s9q6other",
"mid3_s10q3other",
"mid3_s10q5other",
"mid3_s10q8other",
"mid3_s10q10other",
"mid3_s11q3other",
"mid3_s11q6other",
"mid3_s13q1other",
"mid3_s3q1other",
"mid3_s3q5other",
"mid3_s4q6other",
"mid3_s4q9other",
"mid3_s4q11other",
"mid3_s5q6",
"mid3_s5q6_2",
"mid3_s5q13other",
"mid3_s5q14other",
"mid3_s17q6other",
"mid3_s17q9other",
"mid3_s18q3other",
"mid3_s19q4",
"mid3_s19q4b")
report_open (list_open_ends = open_ends)
# Review "verbatims.csv". Identify variables to be deleted or redacted and their row number
mydata <- mydata[!names(mydata) %in% open_ends] # SDC risk could not be ascertained as all verbatims are partially or completely in Nepali.
# !!! No GPS data.
Adds "_PU" (Public Use) to the end of the name
haven::write_dta(mydata, paste0(filename, "_PU.dta"))
haven::write_sav(mydata, paste0(filename, "_PU.sav"))
#Add report title dynamically
title_var <- paste0("DOL-ILAB SDC - ", filename)