0

I've fit a multivariate cox proportions model with significant covariates. After fitting test data, the predict function clearly returns hazard ratios (ranging from positive values to negative values). This clearly makes sense to me as the more negative it is the less likely they are to die.

res.cox <- coxph(Surv(wins, status) ~ out_degree +  ADJOE + ADJDE + Luck, data =  train_df)

test_df$pred <- predict(res.cox,test_df)
train_df = structure(list(year = c(2004, 2004, 2004, 2004, 2004, 2004), 
    TeamID = c("1448", "1338", "1386", "1462", "1163", "1305"
    ), out_degree = c(8, 7, 6, 7, 8, 5), in_degree = c(7, 4, 
    1, 4, 5, 3), ADJOE = c(121.6, 114.1, 118.9, 113.8, 117.8, 
    112.3), ADJDE = c(99.9, 88.2, 91.2, 93.6, 89.5, 92), Luck = c(-0.019, 
    -0.028, 0.06, -0.022, 0.012, -0.039), wins = c(2, 2, 3, 3, 
    6, 2), status = c(2, 2, 2, 2, 1, 2)), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -6L))

test_df = structure(list(year = c(2019, 2019, 2019, 2019, 2019, 2019), 
    TeamID = c("1113", "1120", "1138", "1181", "1199", "1211"
    ), out_degree = c(5, 7, 1, 13, 9, 5), in_degree = c(3, 7, 
    1, 5, 5, 3), ADJOE = c(109.4, 119.6, 115, 120.2, 113.1, 125.3
    ), ADJDE = c(97.8, 96.4, 94.7, 88.3, 90.6, 92.6), Luck = c(0.05, 
    0.003, 0.041, 0.018, 0.045, 0.008)), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -6L))

I was wondering how to calculate Hazard Rate(s) instead of ratios.

msubbaiah
  • 350
  • 2
  • 14
  • 1
    Hi, please try reading up on how to ask a question, that can be answered by others: https://stackoverflow.com/help/how-to-ask. There are several ways to provide data, probably adding the output of `dput()` or `dput(head())` to your question is sufficient. Avoid adding code or alphanumeric output as images. Consider how to make a good example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and see how you can change your question accordingly. – heck1 Mar 21 '19 at 13:23
  • 1
    `summary(res.cox)$coefficients` or `broom::tidy(res.cox)` . The second will extract coefficients into a df, then you can exponentiate them to get HRs – Mike Mar 21 '19 at 13:25
  • Gotcha, and using those HRs I could calculate the HRs for specific teams? – msubbaiah Mar 21 '19 at 14:13
  • Nevermind, I took exp(b1 * x1 + b2*x2 + b3*x3) to get the Hazard Rate for each team. – msubbaiah Mar 21 '19 at 14:52
  • 1
    @msubbaiah Unfortunately for you none of the commenters apparently knew the correct answer (or perhaps were waiting for you to supply a proper [MCVE]) and you assumed the incorrect answer. You should have used the `survfit` or `basehaz` function and then applied your linear combination to that. – IRTFM Mar 24 '19 at 03:04

0 Answers0