0

In STATA with stmh I can get stratified rate ratios between two groups in a survival analysis as well as get a 95% confidence interval, chi-square, and p-value for that ratio. Is there anything similar in R?

So far I've gotten this far. Using the lung dataset from the survival package

library(tidyverse)
library(survival)
head(lung)
#>   inst time status age sex ph.ecog ph.karno pat.karno meal.cal wt.loss
#> 1    3  306      2  74   1       1       90       100     1175      NA
#> 2    3  455      2  68   1       0       90        90     1225      15
#> 3    3 1010      1  56   1       0       90        90       NA      15
#> 4    5  210      2  57   1       1       90        60     1150      11
#> 5    1  883      2  60   1       0      100        90       NA       0
#> 6   12 1022      1  74   1       1       50        80      513       0

I've found survRate from biostat3 which can give stratified event rate information

library(biostat3)
survRate(Surv(time, status) ~ sex, data=lung)
#>       sex tstop event        rate       lower       upper
#> sex=1   1 39086   112 0.002865476 0.002359424 0.003447912
#> sex=2   2 30507    53 0.001737306 0.001301362 0.002272439

And can get the rate ratio by extracting the rate elements

#Get the rate for grade of 1
sex_1 <- survRate(Surv(time, status) ~ sex, data=lung) %>%
    filter(sex == 1) %>%
    purrr::pluck("rate")

#Get the rate for grade of 2
sex_2 <- survRate(Surv(time, status) ~ sex, data=lung) %>%
    filter(sex == 2) %>%
    purrr::pluck("rate")

#Get the ratio
sex_2 / sex_1
#> [1] 0.6062888

This is a good start, but in STATA with stmh I can also get a 95% confidence interval, chi-square, and p-value for that ratio. Is there anything similar in R?

pgcudahy
  • 1,542
  • 13
  • 36

0 Answers0