10 Step 7: Association
10.0.1 Set outcome formula
<- as.formula(paste0("outcome", "~", "exposure"))
out.formula
out.formula#> outcome ~ exposure
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|)")]
<- confint(fit, level = 0.95)["exposure", ]
fit.ci <- c(fit.summary, fit.ci)
fit.summary_with_ci round(fit.summary_with_ci,2)
#> Estimate Std. Error Pr(>|z|) 2.5 % 97.5 %
#> 0.42 0.04 0.00 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 round(fit.summary, 2)
#> Estimate Std. Error Pr(>|t|) 2.5 % 97.5 %
#> 0.08 0.01 0.00 0.06 0.10