[R] crr question‏ in library(cmprsk)

Berend Hasselman bhh at xs4all.nl
Fri Oct 18 15:10:32 CEST 2013


On 18-10-2013, at 14:06, Elan InP <englishinparis at aim.com> wrote:

> Hi all
> 
> I do not understand why I am getting the following error message. I am showing all my code this time. Can
> anybody help me with this? Thanks in advance.
> 
> 
> install.packages("cmprsk")
> library(cmprsk)
> 
> 
> ndim = 5
> 
> # two covariates standard normal variates
> z1 = rnorm(ndim)
> z2 = rnorm(ndim)
> 
> beta11 = beta12=0.5
> 
> p = 0.15
> 
> # baseline is modeled by modified logistic model
> b1 = 1
> c1 = 2
> b2 = 2
> c2 = 4
> 
> U = runif(ndim)
> V = runif(ndim)
> 
> tmp=(1-(1-U)^{exp(-z1*beta11-z2*beta12)})/p
> T = ifelse(tmp<1, c1+1/b1*log((tmp+exp(-b1*c1))/(1-tmp)), c2+1/b2*log((V+exp(-b2*c2))/(1-V)))
> epsilon = ifelse(tmp<1, 1, 2)
> C = runif(ndim, 4,5)    # around 20% censored data
> Y = ifelse(T<=C, T, C)
> eta = ifelse(T<=C, epsilon, 0)
> 
> time = Y
> event = eta
> 
> one.time = 3    # the time point that the predicted CIF is estimated
> one.z1 = -1
> one.z2 = 2        # the covariates values that the predicted CIF is estimated
> 
> ftime<-T
> fstatus<-eta
> cov1<-cbind(z1,z2)
> 
> result1 <-crr(ftime, fstatus, cov1, failcode=1, cencode=0 )
> one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2))
> 
> predict.crr(result1,cov1,X=cbind(1,one.z1,one.z2))
> Error: could not find function "predict.crr"
> 

Your example is not reproducible since you didn't do a set.seed(..) before running your script.
With set.seed(11) the error can be reproduced.

preidct.crr is the predict method for a crr object.
Just use

predict(result1,…)

as given in the example for predict.crr.

Berend



More information about the R-help mailing list