[R] val.surv
David Winsemius
dwinsemius at comcast.net
Sun Aug 21 05:29:47 CEST 2011
On Aug 20, 2011, at 10:25 PM, Salvo Mac wrote:
> The test and train are like split data sets, contain similar
> variables but from different countries so the two sets are somehow
> independent. And yes it is a data frame.
What is a data.frame? test and train may be dataframes, but test[,
"age"] is not a dataframe.
> So I extracted age, time and event.
Code? The code you offered before would have created a newdata object
(yes, a data.frame) with a single column bearing the same name as the
vector argument ,,,,, "test1". Not named "age". Try it. do str on such
an object:
str(dataframe(test1))
> So test is data frame,(age, time, event). does that suffice?
It certainly does not allow me to reproduce the error you got (which I
still think is probably related to the structure of your argument to
newdata.)
That's all I can say without data and code.
--
David.
>
>
>
> ________________________________
> From: David Winsemius <dwinsemius at comcast.net>
>
> Cc: "r-help at R-project.org" <r-help at r-project.org>
> Sent: Sunday, August 21, 2011 3:19 AM
> Subject: Re: [R] val.surv
>
>
> On Aug 20, 2011, at 8:08 PM, Salvo Mac wrote:
>
>> Thanks David
>>
>> However, I tried your trick on val.surv with newdata=test['age']
>> but still didn't work.
>> Still gives the same error message:
>>
>> Error in val.surv(f.1, newdata = test1["age"], 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
>>
>
> As I said (and you did
> not act upon):
>
> The fundamental thing you are doing wrong for q1 is failing to
> unambiguously describe the test object.
>
> I said it was a guess. Now stop wasting our time and offer what is
> needed.
>
> --david.
>>
>> Salvo
>> ________________________________
>> From: David Winsemius <dwinsemius at comcast.net>
>>
>> Cc: "r-help at R-project.org" <r-help at r-project.org>
>> Sent: Sunday, August 21, 2011 12:55 AM
>> Subject: Re: [R] val.surv
>>
>>
>> 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