Support #1340
open
relationship_dv code request
Added by Chris Playford over 4 years ago.
Updated over 4 years ago.
Category:
Derived variables
Description
Hi
Please may I request the code to identify errors in the ‘relationship_dv’ variable that is referred to in the variable description? (see below).
https://www.understandingsociety.ac.uk/documentation/mainstage/dataset-documentation/variable/relationship_dv
“There are a considerable number of relationships which continue to be inconsistent over time, or are highly implausible even in the current wave. The majority of these relate to sibling and parent status. For example, there are a large number of children who are natural siblings in one wave, then become half-, step- or adopted siblings later on. Code to identify the errors is available upon request.”
Many thanks,
Chris
- Status changed from New to In Progress
- Assignee changed from Gundi Knies to Chris Playford
- % Done changed from 0 to 50
- Private changed from Yes to No
Hi Chris,
the note is from quite a while back and did not get updated as 'the code' developed. There are two distinct aspects to the code: identifying cases that are inconsistent on relationship hence were inspected for editing, and code to identify cross-wave inconsistent relationships (relationship_dv).
To identify cross-wave inconsistencies, you can adapt the code below. It lists natural child relationships that changed at least once throughout the observation period. You can list other inconsistencies by adjusting the line: bys ID: gen _natch=sum(L.relationship_dv==4 & !inlist(relationship_dv,4,.).
- Start code
local w=1
foreach x in a b c d e f g h i {
use pidp apidp `x'_relationship_dv using ${inpath}/`x'_egoalt, clear
rename `x'_relationship_dv relationship_dv
gen wave=`w'
save M:/egoalt_`x', replace
local w=`w'+1
}
foreach x in a b c d e f g h {
append using ${outpath}/egoalt_`x'
}
sort pidp apidp wave
egen long ID=group(pidp apidp)
bysort ID (wave): gen index=_n
xtset ID index
replace relationship_dv=. if relationship_dv<1
bys ID: gen _natch=sum(L.relationship_dv==4 & !inlist(relationship_dv,4,.)
bys ID: egen Dnatch=max(_natch)
recode Dnatch (0=0) (else=1)
lab var Dnatch "Nat child relationshp changes to something else"
li ID index pidp apidp relationship if Dnatch==1, sepby(ID)
- end code
The code to identify cases that are inconsistent within a wave now requires quite a bit of editing and commenting before we could share it meaningfully. If this is the aspect of 'the code' that you are interested in we can look into how it might be done. In principle, we are looking into sharing do-files but this particular set is a bit of a beast and it may take a bit longer. Do let us know.
Hope this helps,
Gundi
- Status changed from In Progress to Resolved
- % Done changed from 50 to 100
Chris confirmed this solved the query.
Also available in: Atom
PDF