source("0_helpers.R")
## Warning: package 'rmarkdown' was built under R version 3.4.3
## Warning: package 'knitr' was built under R version 3.4.3
##
## Attaching package: 'formr'
## The following object is masked from 'package:rmarkdown':
##
## word_document
## Warning: package 'lubridate' was built under R version 3.4.3
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
## Warning: package 'stringr' was built under R version 3.4.3
## Loading required package: carData
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
##
## Attaching package: 'data.table'
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday, week, yday, year
## The following objects are masked from 'package:formr':
##
## first, last
## Loading required package: Matrix
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:stats':
##
## step
## Warning: package 'haven' was built under R version 3.4.3
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
## This is lavaan 0.5-23.1097
## lavaan is BETA software! Please report any bugs.
##
## Attaching package: 'lavaan'
## The following object is masked from 'package:psych':
##
## cor2cov
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following object is masked from 'package:psych':
##
## describe
## The following objects are masked from 'package:base':
##
## format.pval, round.POSIXt, trunc.POSIXt, units
## Warning: package 'tidyr' was built under R version 3.4.3
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:Matrix':
##
## expand
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:Hmisc':
##
## combine, src, summarize
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following objects are masked from 'package:lubridate':
##
## intersect, setdiff, union
## The following objects are masked from 'package:formr':
##
## first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Warning: package 'coefplot' was built under R version 3.4.3
##
## Attaching package: 'codebook'
## The following object is masked from 'package:psych':
##
## bfi
## The following objects are masked from 'package:formr':
##
## asis_knit_child, expired, paste.knit_asis
## Warning: package 'effsize' was built under R version 3.4.4
##
## Attaching package: 'effsize'
## The following object is masked from 'package:psych':
##
## cohen.d
### Import alldata used for birthorder
alldata_birthorder = readRDS("data/alldata_birthorder.rds")
Number of individuals we were able to reconstruct the three different birth orders based on pregnancy and marriage history for
## Count Birthorder
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive)),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg)),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes)),
Naive_Maternal_Birth_Order = sum(!is.na(birthorder_naive)))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order | Naive_Maternal_Birth_Order |
---|---|---|---|
43322 | 48546 | 42682 | 67026 |
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1,
na.rm = T),
Naive_Maternal_Birth_Order = sum(!is.na(birthorder_naive) & (is.na(any_multiple_birth) | any_multiple_birth != 1),
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order | Naive_Maternal_Birth_Order |
---|---|---|---|
40189 | 45034 | 39589 | 63451 |
## Count Birthorder - without only children
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1,
na.rm = T),
Naive_Maternal_Birth_Order = sum(!is.na(birthorder_naive) & any_multiple_birth != 1 &
sibling_count_naive != 1,
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order | Naive_Maternal_Birth_Order |
---|---|---|---|
36014 | 41204 | 34786 | 41692 |
## Count Birthorder - without only children
alldata_birthorder = alldata_birthorder %>%
mutate(alive = ifelse(!is.na(g_factor_2015_old), 1, alive)) # for seven people its reported that they are not alive anymore but they participated in IFLS5 ?
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1 & alive != 3,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1 & alive != 3,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1 & alive != 3,
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order |
---|---|---|
32714 | 33678 | 31635 |
### All people in the birthorder data file that have ANY g-factor, educational attainment, personality or risk values have to be marked
alldata_birthorder = alldata_birthorder %>%
mutate(used_any = ifelse(!is.na(g_factor_2015_old) | !is.na(g_factor_2015_young) | !is.na(g_factor_2007_old) |
!is.na(g_factor_2007_young) | !is.na(big5_ext) | !is.na(big5_open) | !is.na(big5_agree) |
!is.na(big5_neu) | !is.na(big5_con) | !is.na(riskA) | !is.na(riskB) |
is.na(years_of_education), 1, 0))
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1 & alive != 3 &
used_any == 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1 & alive != 3 &
used_any == 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1 & alive != 3 &
used_any == 1,
na.rm = T),
Naive_Maternal_Birth_Order = sum(!is.na(birthorder_naive) & (is.na(any_multiple_birth) | any_multiple_birth != 1) &
sibling_count_naive != 1 & alive != 3 &
used_any == 1,
na.rm = T)
)
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order | Naive_Maternal_Birth_Order |
---|---|---|---|
32643 | 33606 | 31566 | 41693 |
### All people in the birthorder data file that have all Intelligence measurements
alldata_birthorder = alldata_birthorder %>%
mutate(used_iq = ifelse(!is.na(g_factor_2015_old) | !is.na(g_factor_2015_young) | !is.na(g_factor_2007_old) |
!is.na(g_factor_2007_young), 1, 0)) # used_iq = 1:included, 0:not_included
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1 & alive != 3 &
used_iq == 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1 & alive != 3 &
used_iq == 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1 & alive != 3 &
used_iq == 1,
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order |
---|---|---|
12503 | 12631 | 12193 |
### All people in the birthorder data file that have Personality Measurements
missingness_patterns(alldata_birthorder %>% select(big5_ext, big5_con, big5_open, big5_neu, big5_agree, big5_open))
## index col missings
## 1 big5_ext 69795
## 2 big5_con 69795
## 3 big5_open 69795
## 4 big5_neu 69795
## 5 big5_agree 69795
Pattern | Freq | Culprit |
---|---|---|
1_2_3_4_5 | 69795 | |
_________ | 31446 | _ |
# Missingness Pattern shows that if one of the personality measurements is missing all Measurements are missing
alldata_birthorder = alldata_birthorder %>%
mutate(used_pers = ifelse(!is.na(big5_ext), 1, 0))
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1 & alive != 3 &
used_pers == 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1 & alive != 3 &
used_pers == 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1 & alive != 3 &
used_pers == 1,
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order |
---|---|---|
5922 | 5976 | 5803 |
### All people in the birthorder data file that have Risk Measurements
missingness_patterns(alldata_birthorder %>% select(riskA, riskB))
## index col missings
## 1 riskA 73461
## 2 riskB 71663
Pattern | Freq | Culprit |
---|---|---|
1_2 | 70149 | |
___ | 26266 | _ |
1__ | 3312 | riskA |
__2 | 1514 | riskB |
## Missingness Pattern shows that sometimes A and sometimes B is missing
alldata_birthorder = alldata_birthorder %>%
mutate(used_riskA = ifelse(!is.na(riskA), 1, 0),
used_riskB = ifelse(!is.na(riskB), 1, 0))
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1 & alive != 3 &
used_riskA == 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1 & alive != 3 &
used_riskA == 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1 & alive != 3 &
used_riskA == 1,
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order |
---|---|---|
5331 | 5383 | 5230 |
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1 & alive != 3 &
used_riskB == 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1 & alive != 3 &
used_riskB == 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1 & alive != 3 &
used_riskB == 1,
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order |
---|---|---|
5603 | 5658 | 5490 |
### All people in the birthorder data file that have educational attainment measurements
missingness_patterns(alldata_birthorder %>% select(years_of_education))
## index col missings
## 1 years_of_education 67423
Pattern | Freq | Culprit |
---|---|---|
1 | 67423 | years_of_education |
_ | 33818 | _ |
alldata_birthorder = alldata_birthorder %>%
mutate(used_ea = ifelse(!is.na(years_of_education), 1, 0))
n_birthorder = alldata_birthorder %>%
summarise(Maternal_Birth_Order = sum(!is.na(birthorder_uterus_alive) & any_multiple_birth != 1 &
sibling_count_uterus_alive != 1 & alive != 3 &
used_ea == 1,
na.rm = T),
Maternal_Pregnancy_Order = sum(!is.na(birthorder_uterus_preg) & any_multiple_birth != 1 &
sibling_count_uterus_preg != 1 & alive != 3 &
used_ea == 1,
na.rm = T),
Parental_Full_Sibling_Birth_Order = sum(!is.na(birthorder_genes) & any_multiple_birth != 1 &
sibling_count_genes != 1 & alive != 3 &
used_ea == 1,
na.rm = T))
n_birthorder
Maternal_Birth_Order | Maternal_Pregnancy_Order | Parental_Full_Sibling_Birth_Order |
---|---|---|
6150 | 6209 | 6030 |