Skip to content

bootstrapped cox regression (rms package)

11 messages · Eric Claus, Mark Lamias, Yihui Xie +1 more

#
Quite a few people have had this problem, but since I'm unable to
reproduce it, I'm not exactly sure how to fix it either. A few
references that might be helpful to you:

http://stackoverflow.com/q/12448507/559676
https://github.com/yihui/knitr/issues/413

It is very likely to be a pure LaTeX problem. Letting MikTeX install
the missing LaTeX packages on the fly might solve the problem.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Thu, Nov 29, 2012 at 10:53 AM, Mark Lamias <mlamias at yahoo.com> wrote:
#
That is very helpful! Just to continue debugging, can you save the two
versions of the tex files produced from LyX with different versions of
R and do a diff on them? It sounds like something has changed from R
2.15.0 to 2.15.2.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Thu, Nov 29, 2012 at 1:26 PM, Mark Lamias <mlamias at yahoo.com> wrote:
#
Eric, the output you showed for anova(out) is not correct.  anova.rms does
not produce such output.  Please give us the correct script that obtained
those results and let us know if you are overriding the anova command
somehow.

To your point, make sure that SPSS does not use the bootstrap to obtain a
new point estimate of beta but rather uses the original Cox  beta
coefficients in the test.

Frank

Eric Claus wrote

            
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651344.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi, Yihui,

Attached is an HTML Diff report of the two files.? The left pane contains the R-2.15.0 file. 

Thanks.

--Mark
#
Hi Frank,
Below is the actual output from the anova(out) command.  I had copied in the
p-values and from the previous output from anova(out) and the confidence
intervals from print(quantile(out$boot.Coef[,i], c(.025, .975))) to
illustrate that the confidence intervals were similar to SPSS while the
p-values were not.

Actual output from anova.rms(out):

 Wald Statistics          Response: Surv(months, recidivate) 

 Factor   Chi-Square d.f. P     
fac1  0.27       1    0.6055
fac2  0.20       1    0.6514
fac3  0.01       1    0.9338
fac4  0.05       1    0.8311
fac5  1.06       1    0.3036
fac6  0.33       1    0.5647
fac7  0.81       1    0.3670
fac8  0.30       1    0.5832
 TOTAL   1.48       8    0.9930

Regarding your second question, it looks like SPSS is using the original
estimate of Cox beta coefficients in the test (i.e. a new point estimate is
not generated for the statistical test)

Thanks again,
Eric




--
View this message in context: http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651363.html
Sent from the R help mailing list archive at Nabble.com.
#
Thanks Eric.  It would be good to show your entire script next time as stated
in the posting guidance.

Regarding matching with SPSS please describe the bootstrapping algorithm
used there.  In rms I do the unconditional bootstrap, i.e., I sample with
replacement from the rows of the raw data.  And also make sure that SPSS ran
a large number of bootstrap replications.

Frank


Eric Claus wrote
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651438.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi Frank,
My apologies for not posting the entire script - I have repasted it below.

library(rms)
library(foreign)
temp=read.spss('coxdata.sav', to.data.frame=T)

formula=Surv(months, recidivate) ~ fac1 + fac2 + fac3 + fac4 + fac5 + fac6 +
fac7 + fac8 
fit=cph(formula, data=temp, x=T, y=T) 
val.out=validate(fit, method="boot", B=9999, bw=F, type="residual",
sls=0.05, aics=0,force=NULL, estimates=TRUE, pr=FALSE) 
out=bootcov(fit, B=9999, pr=F, coef.reps=T, loglik=F) 
anova(out) 

 Factor   Chi-Square d.f. P     
fac1  0.27       1    0.6055 
fac2  0.20       1    0.6514 
fac3  0.01       1    0.9338 
fac4  0.05       1    0.8311 
fac5  1.06       1    0.3036 
fac6  0.33       1    0.5647 
fac7  0.81       1    0.3670 
fac8  0.30       1    0.5832 
 TOTAL   1.48       8    0.9930 

for (i in 1:8) {
print(quantile(out$boot.Coef[,i], c(.025, .975)))
}

    2.5%     97.5% 
-9.236751 20.772061 
     2.5%     97.5% 
-8.841030  3.094755 
     2.5%     97.5% 
-1.834436  2.161983 
      2.5%      97.5% 
-0.1800666  0.0871867 
      2.5%      97.5% 
-3.2129636  0.4783566 
       2.5%       97.5% 
-0.04157389  0.07130994 
      2.5%      97.5% 
-0.6415962  0.1001843 
       2.5%       97.5% 
-0.01529467  0.21055259 

Again, the SPSS output I am trying to match is here:
variable low CI high CI p-value 
fac1 -8.474 20.020 .456 
fac2 -8.206 3.093 .524 
fac3 -1.829 2.087 .900 
fac4 -.173 .083 .749 
fac5 -2.945 .450 .143 
fac6 -.035 .070 .306 
fac7 -.626 .092 .189 
fac8 -.017 .203 .247 

In looking through the SPSS syntax, my colleague is using SIMPLE resampling,
which is doing sampling with replacement from the original data set.  9999
bootstrap replications are being used, the same as what I have used in the
bootcov command.  The piece of the SPSS output that is not clear is the
generation of p-values from the distribution of parameter estimates; spss
appears to be testing the parameter estimate from the original cox
regression, but the method of testing that parameter is not clear.  

Eric





--
View this message in context: http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651474.html
Sent from the R help mailing list archive at Nabble.com.
#
It will be crucial to know the details of the test statistic and P-value
calculations from SPSS.  It's also running anova on both the bootcov and the
original fits to see if SPSS is ignoring the bootstrap when computing the
covariance matrix.
Frank

Eric Claus wrote
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/bootstrapped-cox-regression-rms-package-tp4651306p4651493.html
Sent from the R help mailing list archive at Nabble.com.