The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Domestic Violence » Matching the Kenya 2014 DHS domestic violence data
Re: Matching the Kenya 2014 DHS domestic violence data [message #11445 is a reply to message #11175] Thu, 22 December 2016 00:59 Go to previous messageGo to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 803
Registered: January 2013
Senior Member
To match the number of women for the domestic violence module, use the following to initialize your sexualviolence or physicalviolence variables:
replace sexualviolence = 0 if v044==1

However, you have many other problems in your code:
1) You only ever assign values 0 or 1 to sexual violence, but you label values 2, 3, and 4 as well.
2) The label value statement should be as follows - you had the label and the variable names reversed:
label value sexualviolence sexual_violence 
3) When creating your physicalviolence variable, you write:
replace physicalviolence = 0 if d105a - d105f == 0 | d105j == 0
but this is subtracting d105f from d105a and testing the result against 0. You need to add in a loop through the variables to test d105a to d105f individually. I suggest using something like:
gen physicalviolence = .
foreach dvar of var d105a d105b d105c d105d d105e d105f d105j {
  replace physicalviolence = 0 if `dvar' == 0
}
4) You need to figure out the hierarchy order for each of the categories and test for them in the correct order.

Here is my best guess at the coding:
* GENERATING THE VARIABLE 'sexualviolence' 
gen sexualviolence = 0 if v044==1
foreach dval in 1 2 4 3 {
  foreach dvar of var d105h d105i d105k {
    replace sexualviolence = `dval' if sexualviolence == 0 & `dvar' == `dval'
  }
}
replace sexualviolence = 1 if sexualviolence == 0 & d130b == 1
replace sexualviolence = 3 if sexualviolence == 0 & d130b == 2
replace sexualviolence = 4 if sexualviolence == 0 & (d130b == 3 | d130b == 4)
replace sexualviolence = 2 if sexualviolence == 0 & d124 == 1 
replace sexualviolence = 3 if sexualviolence == 0 & d125 == 1

label variable sexualviolence "EVER EXPERIENCED SEXUAL VIOLENCE"
label define sexual_violence 0 "Never" 1 "Often" 2 "Sometimes" ///
  3 "Yes, but not in the last 12 months" 4 "Yes, but frequency in last 12 months missing" ///
  5 "Yes, but no information when"
label value sexualviolence sexual_violence
tab sexualviolence [iweight=d005/1000000] 

*GENERATE VARIABLE "physicalviolence"
gen physicalviolence = 0 if v044==1
foreach dval in 1 2 4 3 {
  foreach dvar of var d105a d105b d105c d105d d105e d105f d105j d117a {
    replace physicalviolence = `dval' if physicalviolence == 0 & `dvar' == `dval'
  }
}
replace physicalviolence = 1 if physicalviolence == 0 & d130a == 1
replace physicalviolence = 3 if physicalviolence == 0 & d130a == 2
replace physicalviolence = 4 if physicalviolence == 0 & (d130a == 3 | d130a == 4)
replace physicalviolence = 4 if physicalviolence == 0 & d115y == 0
replace physicalviolence = 5 if physicalviolence == 0 & d118y == 0

label define physical_violence 0 "Never" 1 "Often" 2 "Sometimes" ///
  3 "Yes, but not in the last 12 months" 4 "Yes, but frequency in last 12 months missing" ///
  5 "Yes, but no information when"
label value physicalviolence physical_violence
tab physicalviolence [iweight=d005/1000000]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Domestic violence
Next Topic: Physical violence
Goto Forum:
  


Current Time: Mon Nov 25 16:42:56 Coordinated Universal Time 2024