r - How to calculate Somer's D / C-index for an external validation dataset given a ordinal response -
i have fit proportional odds regression model using lrm
function within harrell's 'rms' package. wondering how can calculate c-index / somer's d external validation dataset applied fitted model. these statistics can calculated fitted model directly using fitted.model$stats, unsure how them external validation dataset.
there appear built in function doing binary or survival responses in 'rms' package, val.prob
& val.surv
, can't find method ordinal response.
you should re-read documentation lrm
. ordinal responses handled in function. run code using first example ?lrm generates "fit"-object:
pred.logit <- predict(fit) phat <- 1/(1+exp(-pred.logit)) > str(pred.logit) named num [1:1000] na na na 0.234 0.577 ... - attr(*, "names")= chr [1:1000] "1" "2" "3" "4" ... > str(fit$y) named num [1:997] 0 1 0 1 1 0 0 0 0 0 ... - attr(*, "names")= chr [1:997] "4" "5" "6" "7" ... val.prob(phat[-(1:3)], y=fit$y, m=20, cex=.5) dxy c (roc) r2 d d:chi-sq d:p 2.836172e-01 6.418086e-01 8.959553e-02 6.840647e-02 6.920125e+01 1.110223e-16 u u:chi-sq u:p q brier intercept -2.006018e-03 -1.591616e-12 1.000000e+00 7.041249e-02 2.315756e-01 5.977542e-14 slope emax s:z s:p eavg 1.000000e+00 1.956213e-13 -3.813108e-02 9.695832e-01 2.443947e-02 >
Comments
Post a Comment