Preparation

data<-read.csv("/Users/samanthabouwmeester/Documents/CWTL/merged_data_all.csv")

data$SumAttendance<-rowSums(data[,which(substring(colnames(data),1,4)=="week")],na.rm = TRUE)
data$Attendance=1
data$Attendance[data$SumAttendance<21*5*.8]=0


# Missings values 

#baseline num
bas.num<-data[,c("total_nid","total_qds","total_mis","total_add","total_sub","total_prb","total_nu")]

#Are there any missings values?
any(is.na(rowSums(bas.num)))
## [1] FALSE
# FALSE, so no missing values

#baseline lit
bas.lit<-data[,c("total_lid","total_pho","total_muw","total_non","total_com","total_lis","total_wrt")]

# Are there any missings values?
any(is.na(rowSums(bas.lit)))
## [1] FALSE
# FALSE, so no missing values

#endline num
end.num<-data[,c("total_nid_end","total_qds_end","total_mis_end","total_add_end","total_sub_end","total_prb_end","total_nu_end")]

# Are there any missings values?
any(is.na(rowSums(end.num)))
## [1] TRUE
# TRUE, so missing values: multiple imputation

mis.number=rep(NA,7)
for(i in 1:ncol(end.num))
mis.number[i]=length(which(is.na(end.num[,i])))

mis.number
## [1] 69 69 69 69 69 69 69
# 69 participants miss the endline data for numericy all tasks. This is 69/1507=.046, 4.6%
# These endline scores were imputed.

scores.mice<-mice(end.num,print=FALSE)
end.num.MI<-complete(scores.mice)

data[,c("total_nid_end","total_qds_end","total_mis_end","total_add_end","total_sub_end","total_prb_end","total_nu_end")]=end.num.MI

#check
end.num<-data[,c("total_nid_end","total_qds_end","total_mis_end","total_add_end","total_sub_end","total_prb_end","total_nu_end")]
any(is.na(rowSums(end.num)))
## [1] FALSE
# no missings anymore


#endline lit
end.lit<-data[,c("total_lid_end","total_pho_end","total_muw_end","total_non_end","total_com_end","total_lis_end","total_wrt_end")]


# Are there any missings values?
any(is.na(rowSums(end.lit)))
## [1] TRUE
# TRUE, so missing values: multiple imputation

mis.lit=rep(NA,7)
for(i in 1:ncol(end.lit))
  mis.lit[i]=length(which(is.na(end.lit[,i])))

mis.lit
## [1]  69  69  69  69 416  69  69
# 69 participants miss the endline data for literacy all tasks. This is 69/1507=.046, 4.6%
# Task total_com has 416 missings values, this is 416/1507=.276, 27.6%
# These endline scores were imputed.

scores.mice<-mice(end.lit,print=FALSE)
end.lit.MI<-complete(scores.mice)

data[,c("total_lid_end","total_pho_end","total_muw_end","total_non_end","total_com_end","total_lis_end","total_wrt_end")]=end.lit.MI


#check
end.lit<-data[,c("total_lid_end","total_pho_end","total_muw_end","total_non_end","total_com_end","total_lis_end","total_wrt_end")]
any(is.na(rowSums(end.lit)))
## [1] FALSE
# no missings anymore

Long datafile

### Long datafile ###

baseline<-cbind(data[,c(2:5,616)],data[,c(colnames(bas.num),colnames(bas.lit))])
colnames(baseline)
##  [1] "participantID" "GenderChild"   "School"        "ppt_group"    
##  [5] "Attendance"    "total_nid"     "total_qds"     "total_mis"    
##  [9] "total_add"     "total_sub"     "total_prb"     "total_nu"     
## [13] "total_lid"     "total_pho"     "total_muw"     "total_non"    
## [17] "total_com"     "total_lis"     "total_wrt"
endline<-cbind(baseline[,1:5],data[,c(colnames(end.num),colnames(end.lit))])
colnames(endline)=colnames(baseline)

longdata<-rbind(baseline,endline)
longdata<-longdata[order(longdata$participantID),]
longdata$time<-rep(c("baseline","endline"),nrow(baseline))

longdata[c(1:5),]
##      participantID GenderChild                    School ppt_group Attendance
## 1209      16000650        Male Kyamusooni Primary School         B          0
## 2716      16000650        Male Kyamusooni Primary School         B          0
## 1163      16000674        Male Kyamusooni Primary School         B          1
## 2670      16000674        Male Kyamusooni Primary School         B          1
## 1115      16000681        Male Kyamusooni Primary School         B          0
##      total_nid total_qds total_mis total_add total_sub total_prb total_nu
## 1209        11         6         4         3         4         2       30
## 2716        14         9         5         4         4         4       40
## 1163        13        10         6         7         3         6       45
## 2670        15        10         7         7         6         6       51
## 1115        15        10        10         7         4         6       52
##      total_lid total_pho total_muw total_non total_com total_lis total_wrt
## 1209        21         1         3         1         0         1         0
## 2716        22         3         5         0         0         1         0
## 1163        23         0        13         3         0         0         1
## 2670        26         6        17         8         2         1         7
## 1115        24         4        19         9         2         1         3
##          time
## 1209 baseline
## 2716  endline
## 1163 baseline
## 2670  endline
## 1115 baseline

Descriptives

data.table(dl[-c(1,2),],keep.rownames=TRUE)
##                 rn Baseline A Endline A Baseline B Endline B
##  1: mean total_lid      41.47     53.03      38.93     48.05
##  2:   sd total_lid      12.61     10.77      12.32     11.69
##  3: mean total_pho      19.39     23.70      20.41     23.08
##  4:   sd total_pho       8.14      4.37       7.19      4.99
##  5: mean total_muw       3.71      6.73       2.16      2.88
##  6:   sd total_muw       3.51      3.05       2.83      3.13
##  7: mean total_non       8.37     13.77       7.46     12.07
##  8:   sd total_non       6.91      6.29       6.54      6.99
##  9: mean total_com       3.73      7.92       2.81      5.67
## 10:   sd total_com       4.72      5.31       4.15      5.26
## 11: mean total_lis       0.80      1.78       0.60      1.59
## 12:   sd total_lis       1.27      1.49       1.09      1.43
## 13: mean total_wrt       0.86      1.48       0.64      1.20
## 14:   sd total_wrt       1.26      1.42       1.04      1.32
dm<-t(descriptives_Num)
colnames(dm)<-c("Baseline A","Endline A","Baseline B","Endline B")
data.table(dm[-c(1,2),],keep.rownames=TRUE)
##                 rn Baseline A Endline A Baseline B Endline B
##  1: mean total_nid       0.18      0.18       0.25      0.25
##  2:   sd total_nid       0.39      0.39       0.43      0.43
##  3: mean total_qds      12.25     13.99      12.17     13.60
##  4:   sd total_qds       2.90      2.00       2.95      2.38
##  5: mean total_mis       8.29      9.40       8.25      9.01
##  6:   sd total_mis       2.05      1.23       2.14      1.61
##  7: mean total_add       5.82      7.72       5.27      7.05
##  8:   sd total_add       2.81      2.17       2.94      2.68
##  9: mean total_sub       6.97      9.92       5.83      8.47
## 10:   sd total_sub       4.10      4.29       3.70      4.40
## 11: mean total_prb       4.63      7.27       3.97      5.52
## 12:   sd total_prb       3.66      4.05       2.91      3.49
## 13:  mean total_nu       3.51      4.73       3.44      4.40
## 14:    sd total_nu       1.92      1.38       1.89      1.63

Analysis

nid

tab_model(fit_nid)
  total_nid
Predictors Estimates CI p
(Intercept) 12.04 11.74 – 12.33 <0.001
GenderChild [Male] 0.28 0.02 – 0.54 0.037
time [endline] 1.79 1.54 – 2.03 <0.001
Attendance 0.45 0.10 – 0.79 0.011
ppt group [B] -0.12 -0.49 – 0.25 0.515
GenderChild [Male] * time
[endline]
-0.15 -0.42 – 0.13 0.304
time [endline] *
Attendance
0.13 -0.20 – 0.47 0.441
time [endline] * ppt
group [B]
-0.31 -0.59 – -0.04 0.027
Random Effects
σ2 3.75
τ00 participantID:School 2.81
τ00 School 0.13
ICC 0.44
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.095 / 0.493
plot(colnames(dat)[9])

# The thin lines are the means of the schools, thick lines are the overall means.

qds

tab_model(fit_qds)
  total_qds
Predictors Estimates CI p
(Intercept) 8.25 8.04 – 8.45 <0.001
GenderChild [Male] -0.01 -0.19 – 0.17 0.940
time [endline] 1.13 0.94 – 1.31 <0.001
Attendance 0.22 -0.02 – 0.46 0.070
ppt group [B] -0.05 -0.30 – 0.21 0.727
GenderChild [Male] * time
[endline]
-0.08 -0.29 – 0.12 0.428
time [endline] *
Attendance
0.15 -0.11 – 0.40 0.253
time [endline] * ppt
group [B]
-0.36 -0.57 – -0.15 0.001
Random Effects
σ2 2.11
τ00 participantID:School 1.06
τ00 School 0.06
ICC 0.35
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.073 / 0.396
plot(colnames(dat)[10])

# The thin lines are the means of the schools, thick lines are the overall means.

mis

tab_model(fit_mis)
  total_mis
Predictors Estimates CI p
(Intercept) 5.63 5.30 – 5.96 <0.001
GenderChild [Male] 0.26 -0.01 – 0.53 0.056
time [endline] 2.04 1.80 – 2.28 <0.001
Attendance 0.35 -0.01 – 0.70 0.057
ppt group [B] -0.59 -1.00 – -0.17 0.006
GenderChild [Male] * time
[endline]
-0.34 -0.61 – -0.07 0.013
time [endline] *
Attendance
0.14 -0.19 – 0.46 0.415
time [endline] * ppt
group [B]
-0.12 -0.39 – 0.15 0.399
Random Effects
σ2 3.56
τ00 participantID:School 3.36
τ00 School 0.20
ICC 0.50
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.121 / 0.561
plot(colnames(dat)[11])

# The thin lines are the means of the schools, thick lines are the overall means.

add

tab_model(fit_add)
  total_add
Predictors Estimates CI p
(Intercept) 6.73 6.31 – 7.15 <0.001
GenderChild [Male] 0.23 -0.19 – 0.65 0.280
time [endline] 3.10 2.67 – 3.52 <0.001
Attendance 0.69 0.16 – 1.23 0.010
ppt group [B] -1.20 -1.70 – -0.70 <0.001
GenderChild [Male] * time
[endline]
-0.43 -0.91 – 0.05 0.082
time [endline] *
Attendance
0.31 -0.27 – 0.89 0.298
time [endline] * ppt
group [B]
-0.30 -0.79 – 0.18 0.215
Random Effects
σ2 11.24
τ00 participantID:School 5.57
τ00 School 0.15
ICC 0.34
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.129 / 0.423
plot(colnames(dat)[12])

# The thin lines are the means of the schools, thick lines are the overall means.

sub

tab_model(fit_sub)
  total_sub
Predictors Estimates CI p
(Intercept) 4.43 4.07 – 4.79 <0.001
GenderChild [Male] 0.24 -0.12 – 0.60 0.184
time [endline] 2.55 2.17 – 2.93 <0.001
Attendance 0.47 0.02 – 0.93 0.042
ppt group [B] -0.71 -1.14 – -0.28 0.001
GenderChild [Male] * time
[endline]
0.14 -0.29 – 0.56 0.521
time [endline] *
Attendance
0.13 -0.39 – 0.64 0.634
time [endline] * ppt
group [B]
-1.10 -1.53 – -0.67 <0.001
Random Effects
σ2 8.82
τ00 participantID:School 3.65
τ00 School 0.11
ICC 0.30
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.114 / 0.379
plot(colnames(dat)[13])

# The thin lines are the means of the schools, thick lines are the overall means.

prb

tab_model(fit_prb)
  total_prb
Predictors Estimates CI p
(Intercept) 3.33 3.08 – 3.57 <0.001
GenderChild [Male] 0.19 0.02 – 0.36 0.028
time [endline] 1.40 1.22 – 1.58 <0.001
Attendance 0.49 0.27 – 0.72 <0.001
ppt group [B] -0.11 -0.43 – 0.20 0.484
GenderChild [Male] * time
[endline]
-0.24 -0.44 – -0.04 0.020
time [endline] *
Attendance
-0.35 -0.59 – -0.10 0.005
time [endline] * ppt
group [B]
-0.22 -0.42 – -0.02 0.032
Random Effects
σ2 1.99
τ00 participantID:School 0.81
τ00 School 0.14
ICC 0.32
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.103 / 0.394
plot(colnames(dat)[14])

# The thin lines are the means of the schools, thick lines are the overall means.

nu

tab_model(fit_nu)
  total_nu
Predictors Estimates CI p
(Intercept) 40.38 39.02 – 41.75 <0.001
GenderChild [Male] 1.21 0.02 – 2.40 0.046
time [endline] 12.00 11.04 – 12.95 <0.001
Attendance 2.73 1.16 – 4.31 0.001
ppt group [B] -2.78 -4.49 – -1.08 0.001
GenderChild [Male] * time
[endline]
-1.10 -2.17 – -0.02 0.045
time [endline] *
Attendance
0.50 -0.80 – 1.80 0.450
time [endline] * ppt
group [B]
-2.42 -3.49 – -1.34 <0.001
Random Effects
σ2 56.14
τ00 participantID:School 81.10
τ00 School 2.91
ICC 0.60
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.187 / 0.674
plot(colnames(dat)[15])

# The thin lines are the means of the schools, thick lines are the overall means.

lid

tab_model(fit_lid)
  total_lid
Predictors Estimates CI p
(Intercept) 19.27 18.24 – 20.31 <0.001
GenderChild [Male] -0.18 -0.80 – 0.45 0.581
time [endline] 4.46 3.83 – 5.10 <0.001
Attendance 1.12 0.27 – 1.97 0.010
ppt group [B] 0.95 -0.43 – 2.33 0.177
GenderChild [Male] * time
[endline]
-0.17 -0.89 – 0.54 0.635
time [endline] *
Attendance
-0.38 -1.25 – 0.49 0.394
time [endline] * ppt
group [B]
-1.60 -2.32 – -0.88 <0.001
Random Effects
σ2 25.21
τ00 participantID:School 12.28
τ00 School 2.97
ICC 0.38
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.077 / 0.425
plot(colnames(dat)[16])

# The thin lines are the means of the schools, thick lines are the overall means.

pho

tab_model(fit_pho)
  total_pho
Predictors Estimates CI p
(Intercept) 3.86 3.20 – 4.51 <0.001
GenderChild [Male] -0.33 -0.63 – -0.04 0.027
time [endline] 2.81 2.46 – 3.17 <0.001
Attendance 0.07 -0.33 – 0.47 0.721
ppt group [B] -1.54 -2.44 – -0.64 0.001
GenderChild [Male] * time
[endline]
0.09 -0.30 – 0.49 0.647
time [endline] *
Attendance
0.90 0.42 – 1.38 <0.001
time [endline] * ppt
group [B]
-2.37 -2.77 – -1.97 <0.001
Random Effects
σ2 7.69
τ00 participantID:School 0.76
τ00 School 1.41
ICC 0.22
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.241 / 0.408
plot(colnames(dat)[17])

# The thin lines are the means of the schools, thick lines are the overall means.

muw

tab_model(fit_muw)
  total_muw
Predictors Estimates CI p
(Intercept) 8.21 7.18 – 9.23 <0.001
GenderChild [Male] -0.75 -1.40 – -0.11 0.023
time [endline] 5.25 4.83 – 5.67 <0.001
Attendance 2.93 2.03 – 3.83 <0.001
ppt group [B] -1.08 -2.43 – 0.28 0.121
GenderChild [Male] * time
[endline]
0.16 -0.31 – 0.64 0.498
time [endline] *
Attendance
0.36 -0.22 – 0.93 0.223
time [endline] * ppt
group [B]
-0.82 -1.29 – -0.34 0.001
Random Effects
σ2 10.90
τ00 participantID:School 29.36
τ00 School 2.79
ICC 0.75
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.165 / 0.789
plot(colnames(dat)[18])

# The thin lines are the means of the schools, thick lines are the overall means.

non

tab_model(fit_non)
  total_non
Predictors Estimates CI p
(Intercept) 3.56 2.97 – 4.15 <0.001
GenderChild [Male] -0.00 -0.49 – 0.48 0.985
time [endline] 4.07 3.65 – 4.49 <0.001
Attendance 0.95 0.30 – 1.60 0.004
ppt group [B] -0.99 -1.73 – -0.25 0.009
GenderChild [Male] * time
[endline]
-0.17 -0.64 – 0.30 0.485
time [endline] *
Attendance
1.08 0.51 – 1.66 <0.001
time [endline] * ppt
group [B]
-1.38 -1.86 – -0.91 <0.001
Random Effects
σ2 10.91
τ00 participantID:School 12.09
τ00 School 0.61
ICC 0.54
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.153 / 0.609
plot(colnames(dat)[19])

# The thin lines are the means of the schools, thick lines are the overall means.

com

tab_model(fit_com)
  total_com
Predictors Estimates CI p
(Intercept) 0.76 0.57 – 0.94 <0.001
GenderChild [Male] -0.03 -0.16 – 0.10 0.679
time [endline] 0.95 0.82 – 1.08 <0.001
Attendance 0.32 0.15 – 0.50 <0.001
ppt group [B] -0.22 -0.46 – 0.02 0.072
GenderChild [Male] * time
[endline]
-0.11 -0.25 – 0.03 0.133
time [endline] *
Attendance
0.45 0.27 – 0.62 <0.001
time [endline] * ppt
group [B]
-0.02 -0.16 – 0.12 0.799
Random Effects
σ2 0.99
τ00 participantID:School 0.64
τ00 School 0.08
ICC 0.42
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.154 / 0.510
plot(colnames(dat)[20])

# The thin lines are the means of the schools, thick lines are the overall means.

lis

tab_model(fit_lis)
  total_lis
Predictors Estimates CI p
(Intercept) 0.87 0.68 – 1.07 <0.001
GenderChild [Male] -0.15 -0.27 – -0.02 0.019
time [endline] 0.56 0.44 – 0.68 <0.001
Attendance 0.31 0.14 – 0.48 <0.001
ppt group [B] -0.23 -0.49 – 0.03 0.082
GenderChild [Male] * time
[endline]
0.09 -0.05 – 0.22 0.216
time [endline] *
Attendance
0.13 -0.04 – 0.30 0.126
time [endline] * ppt
group [B]
-0.08 -0.21 – 0.06 0.282
Random Effects
σ2 0.92
τ00 participantID:School 0.56
τ00 School 0.10
ICC 0.42
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.077 / 0.462
plot(colnames(dat)[21])

# The thin lines are the means of the schools, thick lines are the overall means.

wrt

tab_model(fit_wrt)
  total_wrt
Predictors Estimates CI p
(Intercept) 3.06 2.60 – 3.52 <0.001
GenderChild [Male] -0.47 -0.77 – -0.17 0.002
time [endline] 1.61 1.41 – 1.82 <0.001
Attendance 1.26 0.85 – 1.67 <0.001
ppt group [B] -0.62 -1.23 – -0.01 0.045
GenderChild [Male] * time
[endline]
-0.03 -0.26 – 0.20 0.800
time [endline] *
Attendance
0.56 0.28 – 0.85 <0.001
time [endline] * ppt
group [B]
0.27 0.04 – 0.51 0.022
Random Effects
σ2 2.67
τ00 participantID:School 5.74
τ00 School 0.56
ICC 0.70
N participantID 1507
N School 30
Observations 3014
Marginal R2 / Conditional R2 0.134 / 0.742
plot(colnames(dat)[22])

# The thin lines are the means of the schools, thick lines are the overall means.

Wellbeing