Advertisement
venkmurthy

Example of use of marginalmeans with coxph

Aug 17th, 2023
2,074
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.31 KB | None | 1 0
  1. librarian::shelf("survival","tidyverse","marginaleffects")
  2.  
  3. head(lung)
  4. m <- coxph(Surv(time,status) ~ age + sex,data=lung %>% mutate(sex=factor(sex)))
  5. summary(m)
  6.  
  7. datagrid(sex=c(1,2),time=250,model=m)
  8. predictions(m,datagrid(sex=c(1,2),time=250,model=m))
  9. predictions(m,datagrid(sex=c(1,2),time=200,model=m))
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement