[R] val.surv

David Winsemius dwinsemius at comcast.net
Sun Aug 21 00:55:40 CEST 2011


On Aug 20, 2011, at 3:32 PM, Salvo Mac wrote:

>  Dear R-users,
>
> I  have two questions regarding validation and calibration of  
> Survival regression models.
>
> 1.  I am trying to calibrate and validate a cox model using val.surv.
> here is my code:
>  f.1<-cph(Surv(time,event)~age, x=T, y=T, data=train)
>  test1<-test[,"age"]
>  val.surv(f.1, newdata=data.frame(test1), u=10)
>
>  but I get an error message:
>
>  Error in val.surv(f.1, newdata = data.frame(testi), u = 10) :
>   dims [product 1797] do not match the length of object [2496]
>  In addition: Warning message:
> In est.surv + S[, 1] :
>   longer object length is not a multiple of shorter object length
>
>  I ran the example in the r-documentation but couldn't extract  dxy  
> from result.
>
>  What am I doing wrong?

The fundamental thing you are doing wrong for q1  is failing to  
unambiguously describe the test object. I would think that if test  
were a dataframe then wrapping data.frame around a vector might not  
get it named correctly as 'age'. You might try newdata= test['age'].  
Just a guess.

>
>  2.  In validate and calibrate cph functions. If it is frailty fit,  
> does the the bootstrap resample clusters or just individuals

The code above appears to be dependent on the rms package. The frailty  
function is part of the underlying survival package and I do not see  
it mentioned in the index for Harrell's RMS text. You will probably  
need to wait until Frank comes across this. He is generally very good  
about correction my errors and knowledge gaps.

>

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list