Re: [R] rcspline.problem
Dear Peter, This indeed resolves the problem. Many thanks. My apologies for not starting a new thread. I am a new R user and not yet fully integrated into the R community. Kind regards, Bart Ferket -- View this message in context: http://r.789695.n4.nabble.com/rcspline-problem-tp3501627p4637181.html Sent from the R help mailing list archive at Nabble.com. __ 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] rcspline.problem
On 2012-07-19 07:10, Bart Ferket wrote: Dear professor Harrell, I probably have the same problem as Haleh Ghaem Maralani. I am using the rms package and the rcspline.plot function to assess the relation of a continuous predictor to the log hazard function. I would like to use the "adj" statement, for example using this test dataset: http://r.789695.n4.nabble.com/file/n3058505/file.csv test <-read.csv("file.csv",header=TRUE) rcspline.plot(test$factor, test$Time,model="cox", adj=cbind(test$adj1, test$adj2), xrange=c(0,3),ylim=c(-1,2),event=test$event,nk=4,knots=c(0.8,1.0,1.5,2.0),showknots=TRUE,plotcl=FALSE,statloc="none",subset=test$SEX=="2",lty=2) Then I get the following Error. x -0.7860188 3.4871734 -4.6087226 -0.6761077 -0.9358280 [1] -3686.955 -3646.681 Error in pchisq(q, df, lower.tail, log.p) : Non-numeric argument to mathematical function Could you please help us understanding how to use the adj statement? Bart Ferket, MD, dept. Epidemiology, ErasmusMC Rotterdam [You're replying to a year-old post; it would probably have been better to start a new thread.] I think that there may be a bug in rcspline.plot that may be easily fixed. Grab the code of rcspline.plot() and edit it as follows: 1. Find the line with adj.df <- attr(v, "rank") and replace it with adj.df <- qr(v)[["rank"]] 2. Save the function as "myrcspline.plot". 3. Fix the evironment of your new function: environment(myrcspline.plot) <- environment(rcspline.plot) Now use myrcspline.plot in your analysis. Works for me, but I'm no expert in such models and don't what side effects this change might have. Peter Ehlers __ 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] rcspline.problem
Dear professor Harrell, I probably have the same problem as Haleh Ghaem Maralani. I am using the rms package and the rcspline.plot function to assess the relation of a continuous predictor to the log hazard function. I would like to use the "adj" statement, for example using this test dataset: http://r.789695.n4.nabble.com/file/n3058505/file.csv test <-read.csv("file.csv",header=TRUE) rcspline.plot(test$factor, test$Time,model="cox", adj=cbind(test$adj1, test$adj2), xrange=c(0,3),ylim=c(-1,2),event=test$event,nk=4,knots=c(0.8,1.0,1.5,2.0),showknots=TRUE,plotcl=FALSE,statloc="none",subset=test$SEX=="2",lty=2) Then I get the following Error. x -0.7860188 3.4871734 -4.6087226 -0.6761077 -0.9358280 [1] -3686.955 -3646.681 Error in pchisq(q, df, lower.tail, log.p) : Non-numeric argument to mathematical function Could you please help us understanding how to use the adj statement? Bart Ferket, MD, dept. Epidemiology, ErasmusMC Rotterdam -- View this message in context: http://r.789695.n4.nabble.com/rcspline-problem-tp3501627p4637039.html Sent from the R help mailing list archive at Nabble.com. __ 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] rcspline.problem
Please follow the posting guide. You didn't state which package you are using and didn't include a trivial self-reproducing example that causes the error. For your purpose the rms package is going to plot restricted cubic spline fits (and shaded confidence bands) more flexibly. Frank Haleh Ghaem Maralani wrote: > > Dear Dr ; > > >I am a PhD student at Epidemiology department of National University of >Singapore. I used R command (rcspline.plot) for plotting restricted > cubic >spline – the model is based on Cox. I managed to get a plot > without >adjustment for other covariates, but I have a problem regarding to >adjusting the confounders. > >I applied below command to generate the matrix for covariates. > >m=as.matrix(age,sex) or m1=matrix(age,sex) or m2=cbind(age,sex) > >But, when I input . adj=m, or adj=m1, or adj=m2.. in the > model, R >gives below error: > > >Error in pchisq(q, df, lower.tail, log.p) : > > Non-numeric argument to mathematical function > >In addition: Warning message: > >In coxph.fit(cbind(x, xx, adj), cbind(y, event), strata = NULL, : > >Loglik converged before variable 1,2,3,4 ; beta may be infinite. > > >I would be grateful if you take my issue into your consideration and > help me >on this case > > >Sincerely Yours > > >Haleh Ghaem > >PhD student, NUS > __ > 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. > - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/rcspline-problem-tp3501627p3502623.html Sent from the R help mailing list archive at Nabble.com. __ 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] rcspline.problem
Dear Dr ; I am a PhD student at Epidemiology department of National University of Singapore. I used R command (rcspline.plot) for plotting restricted cubic spline – the model is based on Cox. I managed to get a plot without adjustment for other covariates, but I have a problem regarding to adjusting the confounders. I applied below command to generate the matrix for covariates. m=as.matrix(age,sex) or m1=matrix(age,sex) or m2=cbind(age,sex) But, when I input . adj=m, or adj=m1, or adj=m2.. in the model, R gives below error: Error in pchisq(q, df, lower.tail, log.p) : Non-numeric argument to mathematical function In addition: Warning message: In coxph.fit(cbind(x, xx, adj), cbind(y, event), strata = NULL, : Loglik converged before variable 1,2,3,4 ; beta may be infinite. I would be grateful if you take my issue into your consideration and help me on this case Sincerely Yours Haleh Ghaem PhD student, NUS __ 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.