Home » Topics » Wealth Index » identifying households with a servant
identifying households with a servant [message #3891] |
Mon, 02 March 2015 06:59 |
cpfeifer
Messages: 10 Registered: January 2015 Location: Kenya
|
Member |
|
|
Hello
I am trying to construct the variable "household has a servant"
So I am extracting the data of HV101 (.01-.22), relation to the head of household in the household data, as well as V705 and V717 the women or her husband's.
Any suggestion on how i can link the two datasets? and if possible, what R function can i use to link them?
Thanks a lot!
|
|
|
|
|
Re: identifying households with a servant [message #4133 is a reply to message #4056] |
Fri, 03 April 2015 08:15 |
Trevor-DHS
Messages: 802 Registered: January 2013
|
Senior Member |
|
|
Here is some code in R that merges datasets, constructs the variable, and then aggregates to the household level:
library(foreign)
setwd("C:/Data/DHS_stata/")
# read the Individual Recode (IR) dataset
ir <- read.dta("DRIR61FL.dta", convert.factors = FALSE)
# read the Person's Recode (PR) dataset
pr <- read.dta("DRPR61FL.dta", convert.factors = FALSE)
# create a subset of the IR dataset
ir_subset <- ir[c("caseid","v001","v002","v003","v005","v034","v705","v717")]
# create a subset of the PR dataset
pr_subset <- pr[c("hhid","hv001","hv002","hv003","hv005","hvidx","hv101","hv102","hv103")]
# merge the IR subset variables onto the PR subset by the key variables, keeping all PR cases
prir <- merge(pr_subset, ir_subset, by.x = c("hv001","hv002","hvidx"), by.y = c("v001","v002","v003"), all.x=TRUE )
# Create the servant variable
# If the person is coded as a servant or house maid according to the relationship code
prir$servant <- ifelse(prir$hv101==16, 1, 0)
# If the person works as a domestic household worker and is not related to the head of the household
prir$servant[prir$v705==6 & prir$hv101==12] <- 1
# If the person's husband works as a domestic household worker, and is listed in the household (v034), and is not related to the head of the household according to their record
prir$servant[prir$v717==6 & prir$v034 > 0 & prir$hv101[which(prir$hvidx > 0)-prir$hvidx+prir$v034]==12] <- 1
# aggregate from household members to produce the variable servant for each household
hh <- aggregate(prir[c("hv001","hv002","servant")], by=list(prir$hhid), max)
head(hh)
Note, though, that there are very few servants (if any) in most DHS surveys, and it is not clear that it is worth it to use this variable.
[Updated on: Fri, 03 April 2015 08:21] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Nov 8 22:11:04 Coordinated Universal Time 2024
|