Aline T
Aline T

Reputation: 1

Prediction with coxphf

I am wondering if anyone implemented a "predict" function for cox regression with Firth correction (package coxphf) in R.

Would predictions with coxphf be computed in the same way those with coxph would?

Thanks!

Here is an example:

library(coxphf)
library(survival)
train <- data.frame(time=c(4,3,1,1,2,2,3), 
          status=c(1,1,1,0,1,1,0), 
          x=c(0,2,1,1,1,0,0)) 

test <- data.frame(x=c(0,2,1,1,1,0,0)) 
fit.coxph <- coxph(Surv(time, status) ~ x, train) 
fit.coxphf <- coxphf(Surv(time, status) ~ x, train) 

predict(fit.coxph, test)
predict(fit.coxphf, test)

Upvotes: 0

Views: 731

Answers (1)

IRTFM
IRTFM

Reputation: 263301

After searching for a package with a function named coxphf and finding it in a package by the same name, I installed the package and ran the first example from the help page ?coxphf. I then see that the results of the function is an object that inherits from coxph, so the predict.coxph function should deliver results and it does:

> library(coxphf); time<-c(1,2,3)
> cens<-c(1,1,1)
> x<-c(1,1,0)
> sim<-cbind(time,cens,x)
> sim<-data.frame(sim)
> myfit <- coxphf(sim, formula=Surv(time,cens)~x)
> class(myfit)
[1] "coxphf" "coxph" 
> predict(myfit)
[1]  0.7673587  0.7673587 -1.5347175

Presumably the author of pkg:coxphf thinks this is appropriate. Otherwise adding the class "coxph" would have been irresponsible.

Upvotes: 2

Related Questions