0
$\begingroup$

How to obtain Risk score in R? Is the following approach correct?

library (survival)
coxph(Surv(time, status) ~ factor(ph.ecog)+factor(sex)+ factor(age>median(lung$age)), data=lung)
#Call:
#coxph(formula = Surv(time, status) ~ factor(ph.ecog) + factor(sex) + 
#    factor(age > median(lung$age)), data = lung)

#                                       coef exp(coef) se(coef)      z        p
#factor(ph.ecog)1                    0.40140   1.49391  0.20170  1.990  0.04658
#factor(ph.ecog)2                    0.91911   2.50705  0.23044  3.988 6.65e-05
#factor(ph.ecog)3                    1.98491   7.27840  1.03298  1.922  0.05466
#factor(sex)2                       -0.54989   0.57701  0.16838 -3.266  0.00109
#factor(age > median(lung$age))TRUE  0.08952   1.09365  0.16138  0.555  0.57910
risk = with(lung[,c('ph.ecog','sex','age')], 
			0.57910* (age > median(lung$age))
             - 0.54989* (sex==2)+ifelse (ph.ecog==1, 0.40140, ifelse(ph.ecog==2, 0.91911, 1.98491) )
            )
lung$group= risk> median(risk, na.rm=T)
plot (survfit(Surv(lung$time, lung$status)~lung$group), col= c(1,2))
```
$\endgroup$
2
  • 1
    $\begingroup$ Please tell us what you mean by "Risk score." Many different things have names like this. $\endgroup$
    – whuber
    Commented Aug 7, 2023 at 13:21
  • $\begingroup$ I am particularly asking about where the regression coefficients of Cox models and the values of covariates are used to dichotomize cases into high- and low-risk groups. $\endgroup$
    – biofan
    Commented Aug 7, 2023 at 15:21

0

Your Answer

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

Browse other questions tagged or ask your own question.