On 10/18/2013 9:10 AM, Berend Hasselman wrote:
> On 18-10-2013, at 14:06, Elan InP <englishinparis@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
>
Thanks for the help. I followed your advice and I got
one.pout1 = predict(result1,cov1,X=cbind(1,one.z1,one.z2))
one.pout1

  one.pout1
            [,1]        [,2]        [,3]         [,4]        [,5]         [,6]
  [1,] 0.0672579 0.006936151 0.003326599 0.0009959236 0.007996281 0.0009889172
  [2,] 0.1441758 0.014009989 0.006731732 0.0020177748 0.016142469 0.0020035868
  [3,] 0.2929463 0.021069135 0.010142511 0.0030437851 0.024262803 0.0030223937
  [4,] 0.3059505 0.028107259 0.013555921 0.0040730708 0.032350015 0.0040444603
  [5,] 0.4095256 0.035118500 0.016969127 0.0051047947 0.040397404 0.0050689555
  [6,] 0.5152613 0.042124866 0.020392900 0.0061422383 0.048430239 0.0060991379
  [7,] 0.8726494 0.049126430 0.023827393 0.0071854868 0.056448567 0.0071350922
  [8,] 1.0133216 0.056179627 0.027300567 0.0082431051 0.064516870 0.0081853236
  [9,] 1.0334864 0.063210676 0.030776328 0.0093041642 0.072550634 0.0092389798
[10,] 1.2680533 0.070303320 0.034296342 0.0103814549 0.080645407 0.0103087623
[11,] 1.6055339 0.077400843 0.037832819 0.0114665593 0.088736267 0.0113863124
[12,] 1.7464511 0.084506813 0.041387740 0.0125601442 0.096827194 0.0124722925
[13,] 1.7782220 0.091571634 0.044936363 0.0136546305 0.104861720 0.0135591761
[14,] 1.9742002 0.098601862 0.048481919 0.0147510215 0.112847392 0.0146479597
[15,] 2.0677276 0.105644330 0.052048131 0.0158566923 0.120837391 0.0157459673
[16,] 2.2108317 0.112675843 0.055623428 0.0169681109 0.128805334 0.0168496917
[17,] 2.2225729 0.119678623 0.059198824 0.0180825136 0.136731093 0.0179563883
[18,] 2.3729906 0.126684158 0.062790492 0.0192049813 0.144650296 0.0190711031
[19,] 2.4057781 0.133708632 0.066406981 0.0203382567 0.152581125 0.0201965601
[20,] 2.5933513 0.140693169 0.070018097 0.0214729229 0.160457086 0.0213234074
[21,] 2.6973637 0.147666993 0.073638971 0.0226137606 0.168311171 0.0224563930
[22,] 2.8931626 0.154770546 0.077343114 0.0237840729 0.176301228 0.0236186600
[23,] 2.9116188 0.161864506 0.081058485 0.0249612457 0.184270217 0.0247877503
[24,] 3.0040918 0.168978830 0.084801020 0.0261504033 0.192251694 0.0259687530
[25,] 3.1263208 0.176095000 0.088561272 0.0273486278 0.200224758 0.0271587708
[26,] 3.2354615 0.183175936 0.092319748 0.0285497542 0.208147865 0.0283516811
[27,] 3.3350847 0.190212416 0.096071490 0.0297522103 0.216010793 0.0295459223
[28,] 3.4160839 0.197286480 0.099860439 0.0309701478 0.223905158 0.0307555496
[29,] 3.6041724 0.204328881 0.103649758 0.0321918034 0.231753590 0.0319688806
attr(,"class")
[1] "predict.crr"


Now, I am very unsure about this prediction matrix. The first column is 
the failure time. The other 5 columns are presented as "estimated 
subdistribution function corresponding to the covariate combinations in the
rows of cov1 and cov2,". I do not understand what is meant by "the 
covariate combinations in the rows of cov1 and cov2". I had cov1 as an 
input of the predict statement, so I was expecting to get only one 
column vector for the predicted CIF.

Thanks in advance for your help.





	[[alternative HTML version deleted]]

