Explained variation for settings with binary, survival and competing risk outcome
Index of Prediction Accuracy: General R^2 for binary outcome and right censored time to event (survival) outcome also with competing risks
rsquared(object,...) IPA(object,...) ## Default S3 method: rsquared(object,formula,newdata,times,cause,...) ## S3 method for class 'glm' rsquared(object,formula,newdata,...) ## S3 method for class 'coxph' rsquared(object,formula,newdata,times,...) ## S3 method for class 'CauseSpecificCox' rsquared(object,formula,newdata,times,cause,...) ## Default S3 method: IPA(object,formula,newdata,times,cause,...) ## S3 method for class 'glm' IPA(object,formula,newdata,...) ## S3 method for class 'coxph' IPA(object,formula,newdata,times,...) ## S3 method for class 'CauseSpecificCox' IPA(object,formula,newdata,times,cause,...)
object |
Model for which we want IPA. |
... |
passed to |
newdata |
Optional validation data set in which to compute IPA |
formula |
Formula passed to |
cause |
For competing risk models the event of interest |
times |
Vector of time points used as prediction horizon for the computation of Brier scores. |
IPA (R^2) is calculated based on the model's predicted risks. The Brier score of the model is compared to the Brier score of the null model.
Data frame with explained variation values for the full model.
Thomas A. Gerds <tag@biostat.ku.dk>
Score
library(prodlim) library(data.table) # binary outcome library(lava) set.seed(18) learndat <- sampleData(48,outcome="binary") lr1 = glm(Y~X1+X2+X7+X9,data=learndat,family=binomial) IPA(lr1) ## validation data valdat=sampleData(94,outcome="binary") IPA(lr1,newdata=valdat) ## predicted risks externally given p1=predictRisk(lr1,newdata=valdat) IPA(p1,formula=Y~1,valdat) # survival library(survival) data(pbc) pbc=na.omit(pbc) pbctest=(1:NROW(pbc)) %in% sample(1:NROW(pbc),size=.632*NROW(pbc)) pbclearn=pbc[pbctest,] cox1= coxph(Surv(time,status!=0)~age+sex+log(bili)+log(albumin)+log(protime), data=pbclearn,x=TRUE) ## same data IPA(cox1,formula=Surv(time,status!=0)~1,times=1000) ## validation data pbcval=pbc[!pbctest,] IPA(cox1,formula=Surv(time,status!=0)~1,newdata=pbcval,times=1000) ## predicted risks externally given p2=predictRisk(cox1,newdata=pbcval,times=1000) IPA(cox1,formula=Surv(time,status!=0)~1,newdata=pbcval,times=1000) # competing risks data(Melanoma) Melanomatest=(1:NROW(Melanoma)) %in% sample(1:NROW(Melanoma),size=.632*NROW(Melanoma)) Melanomalearn=Melanoma[Melanomatest,] fit1 <- CSC(list(Hist(time,status)~sex, Hist(time,status)~invasion+epicel+age), data=Melanoma) IPA(fit1,times=1000,cause=2) ## validation data Melanomaval=Melanoma[!Melanomatest,] IPA(fit1,formula=Hist(time,status)~1,newdata=Melanomaval,times=1000) ## predicted risks externally given p3= predictRisk(fit1,cause=1,newdata=Melanomaval,times=1000) IPA(p3,formula=Hist(time,status)~1,cause=1,newdata=Melanomaval,times=1000)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.