*************************************************************************
***Code to support D. Smith (2017) 'O Brother, where art thou? Investment in
***siblings for inclusive fitness benefits, not father absence, predicts
***earlier age at menarche' - Biology Letters
***NOTE: Data used for this submission will be made available on request to the
***Executive (alspac-exec@bristol.ac.uk). The ALSPAC data management plan
***(available here: http://www.bristol.ac.uk/alspac/researchers/data-access/
***documents/alspac-data-management-plan.pdf) describes in detail the policy
***regarding data sharing, which is through a system of managed open access.
*Age at menarche stratifed by allsibs categories (sort by allsibs first)
sort allsibs
by allsibs: sum(AGE_MENARCHE_YEARS_comp)
sort aln qlet
*Average age at menarche in sample
sum AGE_MENARCHE_YEARS_comp
***Descriptove stats of all predictor variables (if have data for menarche and sibs)
* Categorical/binary variables first
tab1 nodad c645a home moneyprobs allsibs if AGE_MENARCHE_YEARS_comp!=. & allsibs != .
*Continuous variables
sum kz030 tot_sibs d010 if AGE_MENARCHE_YEARS_comp!=. & allsibs != .
***Tests of collinearity for sibling categories
*Sibling categories and FA (removing all cases not included in analysis)
tab allsibs nodad if AGE_MENARCHE_YEARS_comp != ., chi row
*Sibling categories and mum education level
tab allsibs c645a if AGE_MENARCHE_YEARS_comp != ., chi row
*Sibling categories and home ownership
tab allsibs home if AGE_MENARCHE_YEARS_comp != ., chi row
*Sibling categories and financial problems
tab allsibs moneyprobs if AGE_MENARCHE_YEARS_comp != ., chi row
*Sibling categories and birthweight
sort allsibs
by allsibs: sum(kz030) if AGE_MENARCHE_YEARS_comp != .
sort aln qlet
anova kz030 ib2.allsibs if AGE_MENARCHE_YEARS_comp != .
regress
*Sibling categories and mother's age at menarche
sort allsibs
by allsibs: sum(d010) if AGE_MENARCHE_YEARS_comp != .
sort aln qlet
anova d010 ib2.allsibs if AGE_MENARCHE_YEARS_comp != .
regress
*Sibling categories and total number of siblings
sort allsibs
by allsibs: sum(tot_sibs) if AGE_MENARCHE_YEARS_comp != .
sort aln qlet
anova tot_sibs ib2.allsibs if AGE_MENARCHE_YEARS_comp != .
regress
***Regression Models
*Model 1 - Use 'Only full sibs' as outgroup as as biggest sample size
regress AGE_MENARCHE_YEARS_comp ib2.allsibs
*Effect size for model 1
esize twosample AGE_MENARCHE_YEARS_comp if (allsibs == 1 | allsibs == 2) & AGE_MENARCHE_YEARS_comp != ., by(allsibs) all
*Cohen's D = 0.37 - r = 0.182 - r2 = 0.033
*Model 2 - Father absence model
regress AGE_MENARCHE_YEARS_comp nodad
*Effect size for model 2 (Father absense)
esize twosample AGE_MENARCHE_YEARS_comp if AGE_MENARCHE_YEARS_comp != ., by(nodad) all
* Cohen's D = 0.196 - r = 0.098 - r2 = 0.0095
*Model 3 - Add 'siblings relatedness' and 'father absence' in same model
regress AGE_MENARCHE_YEARS_comp ib2.allsibs nodad
vif
*Sample size for half/step sibs vs full sibs (step=84; full=2,492) in model 3
esize twosample AGE_MENARCHE_YEARS_comp if (allsibs == 1 | allsibs == 2) & AGE_MENARCHE_YEARS_comp != . & nodad != ., by(allsibs) all
*t = 2.79 - n1 (only step-sibs) = 84 - n2 (only full sibs) = 2492 - cohen's D = 0.31 - r = 0.153 - r2 = 0.023
*Model 4 - Add all other controls (inc. mum menarche as continuous variable and total sibs)
regress AGE_MENARCHE_YEARS_comp ib2.allsibs nodad kz030 i.c645a home moneyprobs d010 tot_sibs
vif
*Model 5 - Relaxed optimsed model (p<0.1) with just sig vars left (allsibs, education and mum menarche)
regress AGE_MENARCHE_YEARS_comp ib2.allsibs d010 i.c645a
vif
*Sample size for half/step sibs vs full sibs in model 5 (step=79; full=2,170)
esize twosample AGE_MENARCHE_YEARS_comp if (allsibs == 1 | allsibs == 2) & AGE_MENARCHE_YEARS_comp != . & c645a != . & d010 != ., by(allsibs) all
*t = 3.16 - n1 (only step-sibs) = 79 - n2 (only full sibs) = 2170 - cohen's D = 0.36 - r = 0.178 - r2 = 0.032
*Sample size for no sibs vs full sibs in model 5 (no sibs=160; full=2,170)
esize twosample AGE_MENARCHE_YEARS_comp if (allsibs == 0 | allsibs == 2) & AGE_MENARCHE_YEARS_comp != . & c645a != . & d010 != ., by(allsibs) all
*t = 2.52 - n1 (no sibs) = 160 - n2 (only full sibs) = 2170 - cohen's D = 0.21 - r = 0.1-3 - r2 = 0.011