2
$\begingroup$

Given these data, reflecting individual data on 206 subjects, two treatment groups ("uc" and "texting") and race ("nonblack" and "black").

My goal is a calculate a risk ratio (with 95% CI) for each treatment group. The risk ratio of interest is defined as the proportion with outcome == 1 in the 'nonblack' category divided by the proportion with outcome == 1 in the 'black' category. How do I calcuate these in R using a logistic (or Poisson model)?

agg_dat <- structure(list(trt_grp = structure(c(2L, 2L, 2L, 2L, 1L, 1L, 
1L, 1L), levels = c("texting", "uc"), class = "factor"), race = structure(c(2L, 
2L, 1L, 1L, 2L, 2L, 1L, 1L), levels = c("black", "nonblack"), class = "factor"), 
    ascertained = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), levels = c("yes", 
    "no"), class = "factor"), counts = c(21, 9, 24, 49, 32, 3, 
    63, 5)), class = "data.frame", row.names = c(NA, -8L))

Converting to a row for each individual and setting factor levels:

dat <- uncount(agg_dat, counts) |> 
  mutate(outcome = ifelse(ascertained == "yes", 1, 0)) |> 
  mutate(race = factor(race, levels = c("black", "nonblack")),
  trt_grp = factor(trt_grp, levels = c("uc", "texting")))

It's straightforward to get predictions for each category of trt_grp and race:

    m0 <- glm(outcome ~ race*trt_grp, family = "binomial", data = dat)
    (newdata <-  agg_dat |> 
      select(trt_grp, race) |> 
      unique())
   predictions <- predict(m0, newdata, type = "response")

I'm stuck on how to use my R glm() model to estimate the confidence intervals for these risk ratios.

The point estimates for the risk ratios can be calculated from model predictions (on the "response" scale).

(rr_uc <- predicted[1]/predicted[2])
(rr_texting <- predicted[3]/predicted[4])

I wish to calculate 95% confidence intervals for 'rr_uc' and 'rr_texting'. It seems like the R margins package might be useful.

Finally, I'd like to estimate the ratio of risk ratios, i.e., rr_texting/rr_uc. The point estimate is straightforward. How do I calculate the confidence interval for the ratio of risk ratios?

$\endgroup$
3
  • 1
    $\begingroup$ You need something like the delta method. Or you could fit a log-link Poisson model and get risk ratios directly from exponentiated parameters. Or you could use something from the effectsize package to convert from CIs of odds ratios (which are available directly) to CIs of risk ratios. Or you could compute risk ratios directly from the 2x2 tables (again using effectsize) $\endgroup$
    – Ben Bolker
    Commented Mar 15, 2023 at 21:49
  • $\begingroup$ You can try profile likelihood, see stats.stackexchange.com/questions/289008/… $\endgroup$ Commented Mar 17, 2023 at 14:51
  • $\begingroup$ One recommended approach is to fit a Poisson glm: m1 <- glm(outcome = trt_grp*race, family = "poisson", data = dat) then use the 'sandwich and 'lmtest' packages ti estimate robust confidence intervals, i.e., exp(coefci(m1, vcov. = vcovHC(m1, type = "HCO"))). The ratio of risk ratios is the exponentiated coefficient for the interaction, i.e., exp(coef[4]). Estimates seem reasonable. I have not yet sorted out how to get robust estimates for linear combinations of coefficients, i.e., rr_texting which is exp( coef[3] + coef[4] ). $\endgroup$
    – user25494
    Commented Mar 26, 2023 at 15:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.