-
Notifications
You must be signed in to change notification settings - Fork 1
/
growth_prediction_example.Rmd
123 lines (72 loc) · 2.77 KB
/
growth_prediction_example.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
title: "Example HAL counterfactuals"
output: html_document
---
```{r setup, include=FALSE}
rm(list=ls())
source(paste0(here::here(), "/0-config.R"))
source(paste0(here::here(), "/functions/0_calc_empirical_IC.R"))
library(hal9001)
library(washb)
birthweight_shift <- readRDS(paste0(here::here(),"/figures/birthweight_shift_example.RDS"))
waz_shift <- readRDS(paste0(here::here(),"/figures/waz_shift_example.RDS"))
d <- readRDS(paste0(data_dir,"analysis_data.RDS"))
y_name = "whz_24"
x_names = c(covars, "arm", "waz_birth")
dfull <- d %>% ungroup() %>% select(all_of(c("studyid","country",y_name, x_names)))
#temp: complete cases
dim(dfull)
dfull <- dfull[complete.cases(dfull),]
dfull <- droplevels(dfull)
dim(dfull)
dfull$cohort <- paste0(dfull$studyid,"-",dfull$country)
```
## Data description
```{r}
#Number children:
nrow(dfull)
#cohort sizes:
table(dfull$cohort)
#predictors:
x_names
```
## HAL model
```{r, eval=FALSE}
fit_init <- fit_hal(X = X,
Y = Y,
smoothness_orders = 0,
return_x_basis = TRUE,
family = "gaussian",
num_knots = hal9001:::num_knots_generator(
max_degree = ifelse(ncol(X) >= 20, 2, 3),
smoothness_orders = 0,
base_num_knots_0 = max(100, ceiling(sqrt(n)))
))
```
## Counterfactual 1: Shifting all low birthweight babies to the low-birthweight threshold (2500g)
```{r, echo=F}
waz_shift$p
d <- waz_shift$plotdf
diff <- round( d$est[d$estimate=="counterfactual"& d$study=="Pooled"] - d$est[d$estimate=="observed" & d$study=="Pooled"], 3)
#mean(d$est[d$estimate=="counterfactual" & !grepl(d$study,"Pooled")] - d$est[d$estimate=="observed" & !grepl(d$study,"Pooled")])
```
WHZ increase at 6 months: `r diff``
## Counterfactual 2: LNS suppliments for all moms during pregnancy (40g birthweight gain based on RCT meta-analysis)
```{r, echo=FALSE}
birthweight_shift$p
d <- birthweight_shift$plotdf
diff <- round( d$est[d$estimate=="counterfactual"& d$study=="Pooled"] - d$est[d$estimate=="observed" & d$study=="Pooled"], 3)
```
WHZ increase at 6 months: `r diff``
## Next steps:
- Make shiny interface
- Estimate outcome difference directly
- Get prevalence difference of wasting/stunting
- Fit models for all growth exposures/outcomes
- Tune HAL models
- Add HAL model accuracy
- Add diagnostics (covariates used, N's for each study, percent of kids shifted)
- Ability to subset by subgroups (region, sex, children intervened on)
- Add maternal size shifting
- Add variable importance ranking of predictors
- Question? Should I be using the shift TMLE to be able to target the impact of shifting early growth, etc?