<- as.formula(paste0("outcome", "~", "exposure"))
out.formula
out.formula#> outcome ~ exposure
10 Step 7: Association
10.0.1 Set outcome formula
10.0.2 Obtain OR from unadjusted model
<- glm(out.formula,
fit data = hdps.data,
weights = W.out$weights,
family= binomial(link = "logit"))
<- summary(fit)$coef["exposure",
fit.summary c("Estimate",
"Std. Error",
"Pr(>|z|)")]
2] <- sqrt(sandwich::sandwich(fit)[2,2])
fit.summary[require(lmtest)
<- confint(fit, "exposure", level = 0.95, method = "hc1")
conf.int <- c(fit.summary, conf.int)
fit.summary_with_ci ::kable(t(round(fit.summary_with_ci,2))) knitr
Estimate | Std. Error | Pr(>|z|) | 2.5 % | 97.5 % |
---|---|---|---|---|
0.42 | 0.08 | 0 | 0.35 | 0.49 |
- We are using a crude outcome model here.
- Somewhat controversial to adjust for all (investigator-specified and all 100 proxies) covariates.
10.0.3 Obtain RD from unadjusted model
<- glm(out.formula,
fit data = hdps.data,
weights = W.out$weights,
family= gaussian(link = "identity"))
<- summary(fit)$coef["exposure",
fit.summary c("Estimate",
"Std. Error",
"Pr(>|t|)")]
2] <- sqrt(sandwich::sandwich(fit)[2,2])
fit.summary[require(lmtest)
<- confint(fit, "exposure", level = 0.95, method = "hc1")
conf.int <- c(fit.summary, conf.int)
fit.summary ::kable(t(round(fit.summary, 2))) knitr
Estimate | Std. Error | Pr(>|t|) | 2.5 % | 97.5 % |
---|---|---|---|---|
0.08 | 0.01 | 0 | 0.06 | 0.1 |