SJTU CMGPD Methodological Lecture Day 8 Family and contextual influences
Feb 23, 2016
SJTU CMGPDMethodological Lecture
Day 8Family and contextual influences
Existing variables
• The various datasets already have a number of basic kinship variables such as counts of various types of kin.– Next slide is parental survival
• When creating kinship variables, be careful about mixing them with existing kinship variables– Kinship variables are sensitive to assumptions
made in their creation, so be consistent
Parental survivaluse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\
DS0001\27063-0001-Data.dta", clearmerge 1:1 RECORD_NUMBER using "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN
from ICPSR\ICPSR_27063\DS0003\27063-0003-Data.dta"keep if FATHER_ALIVE >= 0 & MOTHER_ALIVE >= 0keep if AGE_IN_SUI >= 1 & AGE_IN_SUI <= 80keep if SEX == 2 & PRESENTbysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen p_both_parents_alive = mean(FATHER_ALIVE & MOTHER_ALIVE)bysort AGE_IN_SUI: egen p_one_parent_alive = mean((FATHER_ALIVE + MOTHER_ALIVE)==1)bysort AGE_IN_SUI: egen p_no_parent_alive = mean((FATHER_ALIVE + MOTHER_ALIVE)==0)bysort AGE_IN_SUI: egen p_father_alive = mean(FATHER_ALIVE)bysort AGE_IN_SUI: egen p_mother_alive = mean(MOTHER_ALIVE)line p_both_parents_alive p_one_parent_alive p_no_parent_alive p_father_alive p_mother_alive
AGE_IN_SUI if first_in_age, ytitle("Proportion") xtitle("Age in sui") legend(order(1 "Both parents alive" 2 "One parent alive" 3 "No parent alive" 4 "Father alive" 5 "Mother alive")) scheme(s1mono) lpattern(solid dash dot dash_dot shortdash)
0.2
.4.6
.81
Pro
porti
on
0 20 40 60 80Age in sui
Both parents alive One parent aliveNo parent alive Father aliveMother alive
Basic principles for locating descendants in same year
• Sons– Males in the same YEAR whose FATHER_ID is same as individual’s PERSON_ID
• Daughters – Never-married females (MARITAL_STATUS == 2) in the same YEAR whose
FATHER_ID is same as an individual’s PERSON_ID• Married daughters-in-law
– Married women (MARITAL_STATUS == 1 or 4) in the same year whose FATHER_ID is same as individual’s PERSON_ID
– For married and widowed women, kinship identifiers for father, mother etc. all refer to in-laws
• Widowed daughters-in-law– Widowed women (MARITAL_STATUS == 3) in the same year whose FATHER_ID
is same as individual’s PERSON_ID• Grandchildren
– Same as above, but look for values of GRANDFATHER_ID that match PERSON_ID
Counting descendants alive in the current register year
• Sons– Create for each unique combination of FATHER_ID and YEAR
• Number of people who have specified FATHER_ID in the current register year
– Rename FATHER_ID to PERSON_ID and save– Load original file and merge on PERSON_ID and YEAR
• Grandsons– Do the same, except use GRANDFATHER_ID
• Could do this with MOTHER_ID and GRANDMOTHER_ID as well– Would need minor adjustments
Numbers of living sonsuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if FATHER_ID != "-99"keep if PRESENTkeep if SEX == 2bysort FATHER_ID YEAR: generate sons_alive = _Nbysort FATHER_ID YEAR: keep if _n == 1keep FATHER_ID YEAR sons_aliverename FATHER_ID PERSON_IDsave sons_aliveuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearmerge m:1 PERSON_ID YEAR using sons_alive, keep(match master)keep if SEX == 2replace sons_alive = 0 if sons_alive == .keep if AGE_IN_SUI > 0 & AGE_IN_SUI <= 80bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_sons_alive = mean(sons_alive)line mean_sons_alive AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Mean number of living sons") xtitle("Age in sui")bysort AGE_IN_SUI: egen p_sons_alive_0 = mean(sons_alive == 0)bysort AGE_IN_SUI: egen p_sons_alive_1 = mean(sons_alive == 1)bysort AGE_IN_SUI: egen p_sons_alive_2 = mean(sons_alive == 2)bysort AGE_IN_SUI: egen p_sons_alive_3 = mean(sons_alive == 3)bysort AGE_IN_SUI: egen p_sons_alive_4 = mean(sons_alive == 4)bysort AGE_IN_SUI: egen p_sons_alive_gt_5 = mean(sons_alive >= 5)line p_sons_alive_0 p_sons_alive_1 p_sons_alive_2 p_sons_alive_3 p_sons_alive_4 p_sons_alive_gt_5 AGE_IN_SUI if
first_in_age, scheme(s1mono) ytitle("Prop. of men with specified # of living sons") xtitle("Age in sui") legend(order(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5+"))
0.2
.4.6
.81
Pro
p. o
f men
with
spe
cifie
d #
of li
ving
son
s
0 20 40 60 80Age in sui
0 12 34 5+
Numbers of living grandsonsuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if GRANDFATHER_ID != "-99"keep if PRESENTkeep if SEX == 2bysort GRANDFATHER_ID YEAR: generate grandsons_alive = _Nbysort GRANDFATHER_ID YEAR: keep if _n == 1keep GRANDFATHER_ID YEAR grandsons_aliverename GRANDFATHER_ID PERSON_IDsave grandsons_alive, replaceuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearmerge m:1 PERSON_ID YEAR using grandsons_alive, keep(match master)keep if SEX == 2replace grandsons_alive = 0 if grandsons_alive == .keep if AGE_IN_SUI > 0 & AGE_IN_SUI <= 80bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_gsons_alive = mean(grandsons_alive)line mean_gsons_alive AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Mean # living grandsons") xtitle("Age in sui")bysort AGE_IN_SUI: egen p_gsons_alive_0 = mean(grandsons_alive == 0)bysort AGE_IN_SUI: egen p_gsons_alive_1 = mean(grandsons_alive == 1)bysort AGE_IN_SUI: egen p_gsons_alive_2 = mean(grandsons_alive == 2)bysort AGE_IN_SUI: egen p_gsons_alive_3 = mean(grandsons_alive == 3)bysort AGE_IN_SUI: egen p_gsons_alive_4 = mean(grandsons_alive == 4)bysort AGE_IN_SUI: egen p_gsons_alive_gt_5 = mean(grandsons_alive >= 5)line p_gsons_alive_0 p_gsons_alive_1 p_gsons_alive_2 p_gsons_alive_3 p_gsons_alive_4 p_gsons_alive_gt_5 AGE_IN_SUI if
first_in_age, scheme(s1mono) ytitle("Prop. of men with # of living grandsons") xtitle("Age in sui") legend(order(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5+"))
0.2
.4.6
.81
Pro
p. o
f men
with
# o
f liv
ing
gran
dson
s
0 20 40 60 80Age in sui
0 12 34 5+
Counting up sons (or grandsons) with specified characteristics
• Apply additional restrictions in keep to count up sons or grandsons with specified characteristics
• The following adds a restriction so that only boys aged 1 to 10 sui are included in the count.
• Could just as well have been sons with position, or other characteristics such as marriage.
Counting young sonsuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if FATHER_ID != "-99"keep if PRESENTkeep if SEX == 2 & AGE_IN_SUI >= 1 & AGE_IN_SUI <= 10bysort FATHER_ID YEAR: generate sons_alive = _Nbysort FATHER_ID YEAR: keep if _n == 1keep FATHER_ID YEAR sons_aliverename FATHER_ID PERSON_IDsave sons_aliveuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearmerge m:1 PERSON_ID YEAR using sons_alive, keep(match master)keep if SEX == 2replace sons_alive = 0 if sons_alive == .keep if AGE_IN_SUI > 0 & AGE_IN_SUI <= 80bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_sons_alive = mean(sons_alive)line mean_sons_alive AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Mean number of living sons") xtitle("Age in sui")bysort AGE_IN_SUI: egen p_sons_alive_0 = mean(sons_alive == 0)bysort AGE_IN_SUI: egen p_sons_alive_1 = mean(sons_alive == 1)bysort AGE_IN_SUI: egen p_sons_alive_2 = mean(sons_alive == 2)bysort AGE_IN_SUI: egen p_sons_alive_3 = mean(sons_alive == 3)bysort AGE_IN_SUI: egen p_sons_alive_4 = mean(sons_alive == 4)bysort AGE_IN_SUI: egen p_sons_alive_gt_5 = mean(sons_alive >= 5)line p_sons_alive_0 p_sons_alive_1 p_sons_alive_2 p_sons_alive_3 p_sons_alive_4 p_sons_alive_gt_5 AGE_IN_SUI if first_in_age,
scheme(s1mono) ytitle("Prop. of men with specified # of living sons") xtitle("Age in sui") legend(order(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5+"))
0.2
.4.6
.81
Pro
p. o
f men
with
# o
f liv
ing
sons
age
1-1
0
0 20 40 60 80Age in sui
0 12 34 5+
Locating members of the same generation
• Brothers– Males in the same YEAR who have the same FATHER_ID
• Sisters– Never-married females in the same YEAR who have the same FATHER_ID
• Sisters-in-law– Married or widowed females in the same YEAR who have the same
FATHER_ID• Male cousins
– Males in the same YEAR with the same GRANDFATHER_ID but a different FATHER_ID
• Male second cousins– Males in the same YEAR with the same F_ID_3 but a different
GRANDFATHER_ID and FATHER_ID
Numbers of living brothersuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if FATHER_ID != "-99" & PRESENT & SEX == 2bysort FATHER_ID YEAR: generate brothers_alive = _N-1bysort FATHER_ID YEAR: keep if _n == 1keep FATHER_ID YEAR brothers_alivesave brothers_alive, replaceuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if FATHER_ID != "-99" & SEX == 2merge m:1 FATHER_ID YEAR using brothers_alive, keep(match master)replace brothers_alive = 0 if brothers_alive == .keep if AGE_IN_SUI > 0 & AGE_IN_SUI <= 80bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_brothers_alive = mean(brothers_alive)line mean_brothers_alive AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Mean number of living brothers") xtitle("Age in
sui")bysort AGE_IN_SUI: egen p_brothers_alive_0 = mean(brothers_alive == 0)bysort AGE_IN_SUI: egen p_brothers_alive_1 = mean(brothers_alive == 1)bysort AGE_IN_SUI: egen p_brothers_alive_2 = mean(brothers_alive == 2)bysort AGE_IN_SUI: egen p_brothers_alive_3 = mean(brothers_alive == 3)bysort AGE_IN_SUI: egen p_brothers_alive_4 = mean(brothers_alive == 4)bysort AGE_IN_SUI: egen p_brothers_alive_gt_5 = mean(brothers_alive >= 5)line p_brothers_alive_0 p_brothers_alive_1 p_brothers_alive_2 p_brothers_alive_3 p_brothers_alive_4 p_brothers_alive_gt_5
AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Prop. of men with specified # of living brothers") xtitle("Age in sui") legend(order(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5+"))
Saving and merging isn’t necessary for counting siblings, cousins…
use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear
keep if FATHER_ID != "-99" & PRESENT & SEX == 2bysort FATHER_ID YEAR: generate brothers_alive = _N-1keep if AGE_IN_SUI > 0 & AGE_IN_SUI <= 80bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_brothers_alive = mean(brothers_alive)line mean_brothers_alive AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Mean number of living
brothers") xtitle("Age in sui")bysort AGE_IN_SUI: egen p_brothers_alive_0 = mean(brothers_alive == 0)bysort AGE_IN_SUI: egen p_brothers_alive_1 = mean(brothers_alive == 1)bysort AGE_IN_SUI: egen p_brothers_alive_2 = mean(brothers_alive == 2)bysort AGE_IN_SUI: egen p_brothers_alive_3 = mean(brothers_alive == 3)bysort AGE_IN_SUI: egen p_brothers_alive_4 = mean(brothers_alive == 4)bysort AGE_IN_SUI: egen p_brothers_alive_gt_5 = mean(brothers_alive >= 5)line p_brothers_alive_0 p_brothers_alive_1 p_brothers_alive_2 p_brothers_alive_3 p_brothers_alive_4
p_brothers_alive_gt_5 AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Prop. of men with specified # of living brothers") xtitle("Age in sui") legend(order(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5+"))
.4.6
.81
1.2
1.4
Mea
n nu
mbe
r of l
ivin
g br
othe
rs
0 20 40 60 80Age in sui
0.2
.4.6
.8P
rop.
of m
en w
ith s
peci
fied
# of
livi
ng b
roth
ers
0 20 40 60 80Age in sui
0 12 34 5+
Brothers w/ specified characteristicskeep if FATHER_ID != "-99" & PRESENT & SEX == 2bysort FATHER_ID YEAR: egen brothers_alive = total(MARITAL_STATUS == 1 | MARITAL_STATUS == 4)replace brothers_alive = brothers_alive - 1 if MARITAL_STATUS == 1 | MARITAL_STATUS == 4keep if AGE_IN_SUI > 0 & AGE_IN_SUI <= 80bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_brothers_alive = mean(brothers_alive)
line mean_brothers_alive AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Mean number of married brothers") xtitle("Age in sui")
bysort AGE_IN_SUI: egen p_brothers_alive_0 = mean(brothers_alive == 0)bysort AGE_IN_SUI: egen p_brothers_alive_1 = mean(brothers_alive == 1)bysort AGE_IN_SUI: egen p_brothers_alive_2 = mean(brothers_alive == 2)bysort AGE_IN_SUI: egen p_brothers_alive_3 = mean(brothers_alive == 3)bysort AGE_IN_SUI: egen p_brothers_alive_4 = mean(brothers_alive == 4)bysort AGE_IN_SUI: egen p_brothers_alive_gt_5 = mean(brothers_alive >= 5)
line p_brothers_alive_0 p_brothers_alive_1 p_brothers_alive_2 p_brothers_alive_3 p_brothers_alive_4 p_brothers_alive_gt_5 AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Prop. of men with specified # of married brothers") xtitle("Age in sui") legend(order(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5+"))
0.2
.4.6
.81
Pro
p. o
f men
with
spe
cifie
d #
of m
arrie
d br
othe
rs
0 20 40 60 80Age in sui
0 12 34 5+
Numbers of living cousinsuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if GRANDFATHER_ID != "-99" & FATHER_ID != "-99" & PRESENT == 1 & SEX == 2bysort FATHER_ID YEAR: generate brothers_alive = _N-1bysort GRANDFATHER_ID YEAR: generate cousins_alive = _N - brothers_alive - 1bysort GRANDFATHER_ID YEAR: keep if _n == 1keep GRANDFATHER_ID YEAR cousins_alivesave cousins_alive, replaceuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if GRANDFATHER_ID != "-99" & FATHER_ID != "-99" & SEX == 2merge m:1 GRANDFATHER_ID YEAR using cousins_alive, keep(match master)replace cousins_alive = 0 if cousins_alive == .keep if AGE_IN_SUI > 0 & AGE_IN_SUI <= 80bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_cousins_alive = mean(cousins_alive)line mean_cousins_alive AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Mean number of living cousins") xtitle("Age in sui")bysort AGE_IN_SUI: egen p_cousins_alive_0 = mean(cousins_alive == 0)bysort AGE_IN_SUI: egen p_cousins_alive_1 = mean(cousins_alive == 1)bysort AGE_IN_SUI: egen p_cousins_alive_2 = mean(cousins_alive == 2)bysort AGE_IN_SUI: egen p_cousins_alive_3 = mean(cousins_alive == 3)bysort AGE_IN_SUI: egen p_cousins_alive_4 = mean(cousins_alive == 4)bysort AGE_IN_SUI: egen p_cousins_alive_gt_5 = mean(cousins_alive >= 5)line p_cousins_alive_0 p_cousins_alive_1 p_cousins_alive_2 p_cousins_alive_3 p_cousins_alive_4 p_cousins_alive_gt_5
AGE_IN_SUI if first_in_age, scheme(s1mono) ytitle("Prop. of men with specified # of living cousins") xtitle("Age in sui") legend(order(1 "0" 2 "1" 3 "2" 4 "3" 5 "4" 6 "5+"))
Second cousinsuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\
ICPSR_27063\DS0001\27063-0001-Data.dta", clearmerge 1:1 RECORD_NUMBER using "C:\Users\Cameron Campbe\
Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0004\27063-0004-Data.dta", keepusing(F_ID_3)
keep if PRESENT == 1 & SEX == 2 & F_ID_3 != "-99" & FATHER_ID != "-99" & GRANDFATHER_ID != "-99"
bysort GRANDFATHER_ID YEAR: generate cousins = _N-1bysort F_ID_3 YEAR: generate second_cousins = _N – cousins - 1bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen second_cousins_mean = mean(second_cousins) line second_cousins_mean AGE_IN_SUI if first_in_age & AGE_IN_SUI >= 1 &
AGE_IN_SUI <= 80, scheme(s1mono) ytitle("Mean number of second cousins") xtitle("Age in sui")
Coresidence
• Can also group on HOUSEHOLD_ID to distinguish between sets of kin living in separate households
• For that matter, could also group on village identifier to identify kin in other versus same village
• Coresidence only makes sense from 1789 on
Second cousinsby co-residence
use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear
merge 1:1 RECORD_NUMBER using "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0004\27063-0004-Data.dta", keepusing(F_ID_3)
keep if PRESENT == 1 & SEX == 2 & F_ID_3 != "-99" & FATHER_ID != "-99" & GRANDFATHER_ID != "-99" & HOUSEHOLD_ID != "-99"
bysort GRANDFATHER_ID YEAR: generate cousins = _N-1bysort GRANDFATHER_ID HOUSEHOLD_ID YEAR: generate cousins_hh = _N-1bysort F_ID_3 YEAR: generate second_cousins = _N – cousins -1bysort F_ID_3 HOUSEHOLD_ID YEAR: generate second_cousins_hh = _N - cousins_hh -1bysort AGE_IN_SUI: generate byte first_in_age = _n == 1bysort AGE_IN_SUI: egen second_cousins_mean = mean(second_cousins) bysort AGE_IN_SUI: egen second_cousins_hh_mean = mean(second_cousins_hh) line second_cousins_mean second_cousins_hh_mean AGE_IN_SUI if first_in_age &
AGE_IN_SUI >= 1 & AGE_IN_SUI <= 80, scheme(s1mono) ytitle("Mean") xtitle("Age in sui") legend(order(1 "Second cousins" 2 "Second cousins in household"))
Variables measured according to location within a generation
• Can sort members grouped by GRANDFATHER_ID, FATHER_ID etc. to measure characteristics relative to other members of the same generation
• Sort men with the same FATHER_ID by BIRTHYEAR to order brothers according to seniority
• Can count up unmarried older brothers (for example) with a running total of MARITAL_STATUS == 2 within FATHER_ID and YEAR, minus 1 for unmarried men.
Older unmarried brothers
use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear
keep if SEX == 2 & FATHER_ID != "-99" & PRESENTgenerate byte unmarried = MARITAL_STATUS == 2bysort FATHER_ID YEAR (BIRTHYEAR): gen older_unmarried_brothers = sum(unmarried)replace older_unmarried_brothers = older_unmarried_brothers - 1 if MARITAL_STATUS
== 2tab older_unmarried_brothersbysort AGE_IN_SUI: egen mean_older_unmarried_brothers =
mean(older_unmarried_brothers)bysort AGE_IN_SUI: generate byte first_in_age = _n == 1line mean_older_unmarried_brothers AGE_IN_SUI if first_in_age & AGE_IN_SUI >= 1 &
AGE_IN_SUI <= 80, scheme(s1mono) ytitle("Mean number of older unmarried brothers") xtitle("Age")
Kin in other generations
• Uncles– Men whose FATHER_ID is the same as the individual’s
GRANDFATHER_ID– But whose PERSON_ID is not the individual’s
FATHER_ID• Nephews
– Men whose GRANDFATHER_ID is the same as the individual’s FATHER_ID
– But whose FATHER_ID is not the individual’s PERSON_ID
Unclesuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\
DS0001\27063-0001-Data.dta", clearkeep if SEX == 2 & PRESENT & FATHER_ID != "-99"bysort FATHER_ID YEAR: generate uncles = _Nbysort FATHER_ID YEAR: keep if _n == _Nkeep FATHER_ID YEAR unclesrename FATHER_ID GRANDFATHER_IDsave uncles, replaceuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\
DS0001\27063-0001-Data.dta", clearkeep if SEX == 2 & PRESENT & FATHER_ID != "-99"bysort PERSON_ID YEAR: keep if _n == _Ngenerate byte father_alive = 1keep PERSON_ID FATHER_ID YEAR father_aliverename FATHER_ID GRANDFATHER_IDrename PERSON_ID FATHER_IDsave father, replace
use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear
keep if GRANDFATHER_ID != "-99" & FATHER_ID != "-99"keep if SEX == 2 & PRESENTmerge m:1 GRANDFATHER_ID YEAR using uncles, keep(match master)drop _mergemerge m:1 GRANDFATHER_ID FATHER_ID YEAR using father, keep(match
master)replace father_alive = 0 if father_alive == .replace uncles = 0 if uncles == .tab uncles father_alivereplace uncles = uncles - father_alivebysort AGE_IN_SUI: generate first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_uncles = mean(uncles)line mean_uncles AGE_IN_SUI if first_in_age & AGE_IN_SUI >= 1 & AGE_IN_SUI
<= 80, scheme(s1mono) xtitle("Age in sui") ytitle("Mean number of uncles")
Kin with specified characteristics
• Use egen to count up kin with specified characteristics
• Following example counts up uncles with position
• Could just as well count up uncles meeting any criteria of interest– Age, marital status, etc.
Uncles with positionuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\
DS0001\27063-0001-Data.dta", clearkeep if SEX == 2 & PRESENT & FATHER_ID != "-99"bysort FATHER_ID YEAR: egen uncles_with_position = total(HAS_POSITION == 1)bysort FATHER_ID YEAR: keep if _n == _Nkeep FATHER_ID YEAR unclesrename FATHER_ID GRANDFATHER_IDsave uncles_with_position, replaceuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\
DS0001\27063-0001-Data.dta", clearkeep if SEX == 2 & PRESENT & FATHER_ID != "-99" & HAS_POSITIONbysort PERSON_ID YEAR: keep if _n == _Ngenerate byte father_has_position = 1keep PERSON_ID FATHER_ID YEAR father_has_positionrename FATHER_ID GRANDFATHER_IDrename PERSON_ID FATHER_IDsave father_has_position, replace
use "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clear
keep if GRANDFATHER_ID != "-99" & FATHER_ID != "-99"keep if SEX == 2 & PRESENTmerge m:1 GRANDFATHER_ID YEAR using uncles_with_position, keep(match master)drop _mergemerge m:1 GRANDFATHER_ID FATHER_ID YEAR using father_has_position, keep(match master)replace father_has_position = 0 if father_has_position == .replace uncles_with_position = 0 if uncles_with_position == .tab uncles_with_position father_has_positionreplace uncles_with_position = uncles_with_position - father_has_positionbysort AGE_IN_SUI: generate first_in_age = _n == 1bysort AGE_IN_SUI: egen mean_uncles_with_position = mean(uncles_with_position)line mean_uncles AGE_IN_SUI if first_in_age & AGE_IN_SUI >= 1 & AGE_IN_SUI <= 80,
scheme(s1mono) xtitle("Age in sui") ytitle("Mean number of uncles with position")
Fixed characteristics of individuals in previous times
• So far all examples have been characteristics of kin in the same year
• For analysis of influence of early-life characteristics, can construct measures of interest at one age (e.g. number of brothers when first observed) and copy forward to later records.
• In some cases, would like to collapse information from multiple records of father, grandfather, etc. to produce a single variable
• Typical example: did a father or grandfather hold a position at any point in his life– Regardless of whether he is still alive– Indeed, regardless of whether grandfather died before index
individual was born
Father, grandfather ever held positionuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if SEX == 2 & HAS_POSITION == 1& PRESENTbysort PERSON_ID: keep if _n == 1rename HAS_POSITION FATHER_EVER_HAD_POSITIONkeep PERSON_ID FATHER_EVER_HAD_POSITIONrename PERSON_ID FATHER_IDsave father_ever_held_positionrename FATHER_ID GRANDFATHER_IDrename FATHER_EVER_HAD_POSITION GF_EVER_HAD_POSITIONsave gf_ever_held_positionuse "C:\Users\Cameron Campbe\Documents\Baqi\CMGPD-LN from ICPSR\ICPSR_27063\DS0001\27063-0001-Data.dta", clearkeep if SEX == 2 & FATHER_ID != "-99" & GRANDFATHER_ID != "-99"keep if PRESENTmerge m:1 FATHER_ID using father_ever_held_position, keep(match master)replace FATHER_EVER_HAD_POSITION = 0 if FATHER_EVER_HAD_POSITION == .drop _mergemerge m:1 GRANDFATHER_ID using gf_ever_held_position, keep(match master)drop _mergereplace GF_EVER_HAD_POSITION = 0 if GF_EVER_HAD_POSITION == .generate age_group = 1 + 5*int((AGE_IN_SUI-1)/5)generate ever_married = MARITAL_STATUS != 2keep if MARITAL_STATUS >= 1xi:logit HAS_POSITION i.age_group FATHER_EVER_HAD_POSITION GF_EVER_HAD_POSITION if AGE_IN_SUI >= 21 & AGE_IN_SUI
<= 50 & HAS_POSITION >= 0
Logistic regression Number of obs = 363157 LR chi2(7) = 9814.74 Prob > chi2 = 0.0000Log likelihood = -33618.005 Pseudo R2 = 0.1274
------------------------------------------------------------------------------HAS_POSITION | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+----------------------------------------------------------------_Iage_gro~_6 | (omitted)…_Iage_gr~_41 | -.163177 .0378302 -4.31 0.000 -.2373228 -.0890313_Iage_gr~_46 | (omitted)…_Iage_gr~721 | (omitted)FATHER_EVE~N | 2.337024 .0264432 88.38 0.000 2.285196 2.388852GF_EVER_HA~N | .7563838 .0323022 23.42 0.000 .6930727 .8196948 _cons | -3.813408 .0280527 -135.94 0.000 -3.86839 -3.758426------------------------------------------------------------------------------