ZiBFUS notebook

Kodi Arfer
Created 21 Aug 2016 • Last modified 22 Apr 2017

Death

(valcounts ($ feeding reported_dead))
I reported_dead
False 470

No mothers died.

(wc feeding (valcounts
  (np.where (>= $age 18) "Adult" "Adolescent")
  (np.where $kid_reported_dead "Death" "No deaths")))
row_0 Death No deaths
Adolescent 1 77
Adult 11 381

12 mothers had at least one child die.

Depression

Karl le Roux: "The way we set up the survey, we didn't ask any of the EPDS questions if the child's mother wasn't there at the time or if the child was being looked after by someone else. So the data we have refers specifically to MATERNAL depression rather than caregiver depression. (In retrospect, it may have been useful to get the depression data on the caregiver, but we didn't want to muddy the waters too much.)"

I use 12 as the threshold score for depression.

(setv x (.unstack (.apply (.groupby depress "months")
  (λ (valcounts ($ it class))))))
(setv x (.fillna x 0))
(setv ($ x "prop.") (.round (wc x (/ $Depressed (+ $Okay $Depressed))) 2))
(setv x (getl x : (qw Depressed Okay prop. N/A)))
(setv x.index.name "timepont")
(setv x (kwc .rename x :index (λ
  (if (= it 0) "antenatal" (.format "{} months" it)))))
x
timepont Depressed Okay prop. N/A
antenatal 117 361 0.24 0
3 months 83 281 0.23 26
6 months 64 297 0.18 58
9 months 58 281 0.17 62
12 months 68 245 0.22 98
24 months 29 233 0.11 134

"Okay" here means "not depressed". Notice that 24% of mothers were depressed antenatally, and 23% were depressed at 3 months after birth.

(setv x (.dropna (kwc .pivot (ss depress (.isin $months [0 3]))
  :index "s" :columns "months" :values "class")))
(setv x.columns (qw m0 m3))
(setv sad-both (.sum (wc x
  (& (= $m0 "Depressed") (= $m3 "Depressed")))))
[
  ["Count of mothers missing at neither timepoints 0 nor 3" (len x)]
  ["Count depressed at both timepoints" sad-both]
  ["Proportion" (rd 2 (/ sad-both (len x)))]]
Count of mothers missing at neither timepoints 0 nor 3 363.00
Count depressed at both timepoints 41.00
Proportion 0.11
(setv x (kwc .pivot depress
  :index "s" :columns "months" :values "class"))
(setv x.columns (amap (.format "m{}" it) x.columns))
(setv sad-never (sum (rmap [[_ row] (.iterrows x)]
  (.all (= (.dropna row) "Okay")))))
(setv sad-always (sum (rmap [[_ row] (.iterrows x)]
  (.all (= (.dropna row) "Depressed")))))
[
  ["Total count of mothers" (len x)]
  ["Count depressed at every non-missing timepoint" sad-always]
  ["Proportion" (rd 2 (/ sad-always (len x)))]
  ["Count not depressed at every non-missing timepoint" sad-never]
  ["Proportion" (rd 2 (/ sad-never (len x)))]]
Total count of mothers 480.00
Count depressed at every non-missing timepoint 26.00
Proportion 0.05
Count not depressed at every non-missing timepoint 254.00
Proportion 0.53
(setv x (.dropna (kwc .pivot depress
  :index "s" :columns "months" :values "class")))
(setv s (set x.index))
(setv cum-sad 0)
(setv d (pd.concat (rmap [timepoint x.columns]
  (setv v (getl x s timepoint))
  (setv vd (get v (= v "Depressed")))
  (global cum-sad)
  (+= cum-sad (len vd))
  (.difference-update s vd.index)
  (cbind
    :months timepoint
    :First_depressed (len vd)
    :Cumulative_first_depressed cum-sad
    :Prop. (rd 2 (/ cum-sad (len x)))))))
(.set-index d "months")
months First_depressed Cumulative_first_depressed Prop.
0 35 35 0.21
3 15 50 0.30
6 7 57 0.34
9 8 65 0.39
12 14 79 0.47
24 2 81 0.49

This table considers only mothers who were never missing for any of the timepoints. The last column is cumulative first depressed divided by total never-missing mothers.

Breastfeeding

I exclude all mothers from analysis for whom the death of a baby was reported. (No exclusions for mother deaths were necessary because no mothers died.)

Among mothers of twins, I consider only the primary baby.

I determine the mother's intervention condition (Mentor Mother or control) using the mother's answer to the question "Were you visited by a Mentor Mother during this pregnancy?"

I code the mothers as adults if they were 18 or older at the time of the antenatal interview, and as adolescents otherwise.

(setv breastfed-counts (cbind
  (pd.concat :axis 1 (rmap [grouper (qw condition agecat)]
    (setv gb (.groupby feeding-g grouper))
    (. (.apply gb (λ (valcounts ($ it months_breastfed)))) T)))
  :all (valcounts ($ feeding-g months_breastfed))))
breastfed-counts
months_breastfed Control MM Adolescent Adult all
0 78 39 21 96 117
3 62 23 13 71 85
6 29 10 3 36 39
9 24 9 7 26 33
12 76 52 25 103 128
21 17 12 6 23 29
24 21 6 1 26 27

This table has the count of mothers in each condition and age group who breastfed their child up to the given number of months.

How I've handled missing data and the irregular timepoints here is complicated. The basic idea is to score each mother with a number of months such that she breastfed her baby continuously, but not necessarily exclusively, for at least that number of months after birth. If a mother ever said she was no longer breastfeeding, she wasn't credited for resuming breastfeeding at any later timepoints.

(cut (.cumsum (cut breastfed-counts None None -1) :axis 0) None None -1)
months_breastfed Control MM Adolescent Adult all
0 307 151 76 381 458
3 229 112 55 285 341
6 167 89 42 214 256
9 138 79 39 178 217
12 114 70 32 152 184
21 38 18 7 49 56
24 21 6 1 26 27

This is a cumulative version of the previous table.

(defn f [df]
  (setv v ($ df months_breastfed))
  (pds-from-pairs (pairs
    :Mean (.mean v)
    :Median (.median v)
    :SD (kwc .std v :ddof 0))))
(rd (cbind
  (kwc pd.concat :axis 1 (rmap [grouper (qw condition agecat)]
    (setv gb (.groupby feeding-g grouper))
    (setv x (.apply gb f))
    x.T))
  :all (. (f feeding-g) T)))
I Control MM Adolescent Adult all
Mean 7.651 8.146 7.500 7.890 7.814
Median 6.000 9.000 9.000 6.000 6.000
SD 7.244 7.054 6.628 7.295 7.186

This table summarizes the number of months breastfed (as presented in detail in the previous table).

(kwc pd.concat :axis 1 (rmap [grouper (qw condition agecat)]
  (pd.crosstab
    (.map (.fillna ($ feeding-g breastfed_some_at_6mon) 2)
      {0 "No" 1 "Yes" 2 "missing"})
    (getl feeding-g : grouper))))
breastfed_some_at_6mon Control MM Adolescent Adult
No 140 63 34 168
Yes 151 77 41 187
missing 16 11 1 26

Here we see the number of subjects in each condition and age group who were still breastfeeding their babies at 6 months.

Exclusive breastfeeding and age

N.B. The significance tests below are with all missing values thrown out.

(setv d (wc feeding-g (valcounts
  (.map (.fillna $breastfed_exclusively_at_3mon 2)
    {0 "No" 1 "Yes" 2 "missing"})
  $agecat)))
d
breastfed_exclusively_at_3mon Adolescent Adult ~N/A
No 58 216 0
Yes 13 84 1
missing 5 81 0
["p from Fisher's exact test"
  (second (scist.fisher-exact (.as-matrix (geti d [0 1] [0 1]))))]
p from Fisher's exact test 0.100755523415
(setv d (wc feeding-g (valcounts
  (.map (.fillna $breastfed_exclusively_at_6mon 2)
    {0 "No" 1 "Yes" 2 "missing"})
  $agecat)))
d
breastfed_exclusively_at_6mon Adolescent Adult ~N/A
No 71 323 1
Yes 4 32 0
missing 1 26 0
["p from Fisher's exact test"
  (second (scist.fisher-exact (.as-matrix (geti d [0 1] [0 1]))))]
p from Fisher's exact test 0.365236988082