[R] calibrate.cph plots
Hi! How can I exclude the legends from calibration plots generated by calibrate.cph regards, Salvo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plot.validate.cph
Hi all! I'm trying to plot validate.cph. I have a problem because I'm collating several plots but I can't reduce the size of the plots otherwise the labels below the plot overlap. If I remove the footnotes, I can add it in the main text. How can I remove the footnotes i.e. stuff like black:observed gray:optimism ... Salvo [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] val.surv
I've attached a sample of the data sets, this is my full code. #R 2.13 #library(survival) #library(Hmisc) #library(splines) library(rms) train<-as.data.frame( train<-read.csv("G:\\train.txt", header=T, sep="\t")) test<-as.data.frame( test<-read.table("G:\\test.txt", header=T, sep="\t")) f.1<-cph(Surv(time,event)~age, x=T, y=T,surv=T, data=train) val.surv(f.1, newdata=test, u=10) #plot(calibrate(f.1, u=30, B=20)) ________ From: David Winsemius To: Salvo Mac Cc: "r-help@R-project.org" Sent: Sunday, August 21, 2011 5:29 AM Subject: Re: [R] val.surv 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 > > Cc: "r-help@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 >> >> Cc: "r-help@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 Winsem
Re: [R] val.surv
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. So I extracted age, time and event. So test is data frame,(age, time, event). does that suffice? From: David Winsemius Cc: "r-help@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 > > Cc: "r-help@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 > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] val.surv
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 Salvo From: David Winsemius Cc: "r-help@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 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] val.surv
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? 2. In validate and calibrate cph functions. If it is frailty fit, does the the bootstrap resample clusters or just individuals regards, Salvo Mac [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.