-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04ITT.Rmd
48 lines (36 loc) · 2.51 KB
/
04ITT.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
# Intention to Treat Estimation {-}
The first treatment effect is the Intention To Treat (ITT) effect estimate. This quantifies the causal effect of being randomized to the treatment arm vs. the control arm. In trials with perfect adherence, where all patients receive the treatment they are randomized to receive, this corresponds with the causal effect of receiving treatment.
To estimate the ITT effect, we use pooled logistic regression of the form:
$$logit(Y) = \gamma_{0} + \gamma_{Z} Z + \gamma_{t}t.$$
Which is estimated via the following code:
```{r, cache=TRUE}
ITTFit <- glm(Y ~ t0 + Z,
data = simulated.data,
family = binomial(link="logit"))
ITTFit
```
To calculate the appropriate standard error, p-values, and confidence intervals, extra consideration must be used to account for the clustering of observations in the dataset. As we are using pooled logistic regression, each observation corresponds to a single individual at a given follow-up. This means that observations are not all independent, as we'd expect observations from the same individual to be more alike other than observations from different individuals. We calculate the appropriate uncertainty for each estimate using clustered sandwich estimates of the standard error:
```{r, cache=TRUE}
cov.m1 <- vcovCL(ITTFit, type = "HC0", cluster= simulated.data$id)
co.test <- coeftest(ITTFit, vcov = cov.m1)
co.CI <- coefci(ITTFit, vcov = cov.m1, level = 0.95)
cat("ITT effect estimate:", "\n",
"log(OR)", round(coefficients(ITTFit)[["Z"]],3), "\n",
"95% CI:", round(co.CI["Z","2.5 %"],3), ",", round(co.CI["Z","97.5 %"],3), "\n",
"p-value", round(co.test["Z","Pr(>|z|)"],2), "\n",
"robust standard error", round(sqrt(diag(cov.m1))[["Z"]],3))
```
Our ITT estimate concludes that treatment does not have a statistically significant effect on the outcome. We have showed the calculation above in details to explain how exactly clustered sandwich estimates of the standard error are calculated to make proper inference.
Alternatively, we can use `summ()` function from `jtools` package to perform the above calculations for `log(OR)` in a straightforward manner by specifying appropriate arguments.
```{r, cache=TRUE}
require(jtools)
summ(ITTFit, robust = "HC0",
confint = TRUE, digits = 3, cluster="id",
model.info = FALSE, model.fit = FALSE)
```
We can also do the same for `OR`:
```{r, cache=TRUE}
summ(ITTFit, robust = "HC0", exp = TRUE,
confint = TRUE, digits = 3, cluster="id",
model.info = FALSE, model.fit = FALSE)
```