[R] validate (package Design): error message "subscript out of bounds"
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Tue Aug 28 03:16:43 CEST 2007
Wentzel-Larsen, Tore wrote:
> Dear R users
>
> I use Windows XP, R2.5.1 (I have read the posting guide, I have
> contacted the package maintainer first, it is not homework).
>
> In a research project on renal cell carcinoma we want to compute
> Harrell's c index, with optimism correction, for a multivariate
> Cox regression and also for some univariate Cox models.
> For some of these univariate models I have encountered an error
> message (and no result produced) from the function validate i
> Frank Harrell's Design package:
>
> Error in Xb(x[, xcol, drop = FALSE], coef, non.slopes, non.slopes.in.x, :
> subscript out of bounds
>
> The following is an artificial example wherein I have been able to
> reproduce this error message (actual data has been changed to preserve
> confidentiality):
I could not reproduce the error on R 2.5.1 on linux using version 2.0-12
of Design (you did not provide this information).
Your code involved a good deal of extra typing. Here is a streamlined
version:
bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,
....
bc
library(Design)
dd <- with(bc, datadist(bc1, age, adjto.cat='first'))
options(datadist = 'dd')
f <- cph(Surv(time1,status1) ~ bc1,
data = bc, x=TRUE, y=TRUE, surv=TRUE)
anova(f)
f
summary(f)
val <- validate(f, B=200, dxy=TRUE)
I don't get much value of putting the type of an object as part of the
object's name, as information within objects defines the object type/class.
There is little reason to validate a one degree of freedom model.
Frank
>
> library(Design)
>
> # an example data frame:
> frame.bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
> 127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,
> 1,1,1,2,2,3,4,8,23,32,33,34,43,44,48,51,52,54,59,59,60,60,62,
> 65,65,68,70,72,73,74,81,84,88,98,99,106,107,115,115,117,119,
> 120,122,122,122,122,126,128,130,135,136,136,138,149,151,154,
> 157,159,161,164,164,164,166,172,172,176,179,180,183,183,184,
> 187,190,197,201,201,203,203,203,209,210,214,219,227,233,4,18,
> 49,113,147,1,1,2,2,2,2,2,3,4,6,6,6,6,6,6,6,6,9,9,9,9,9,10,10,
> 10,11,12,12,12,13,14,14,17,18,18,19,19,20,20,21,21,21,21,22,23,
> 23,24,28,28,29,29,32,34,35,38,38,48,48,52,52,54,54,56,64,67,67,
> 69,70,70,72,84,88,90,114,115,140,142,154,171,195),
> status1 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
> 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
> 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
> 1,1,1,1,1),
> bc1 = factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
> 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
> 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
> 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,
> 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
> 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2),
> labels=c('bc.1','bc.2')),
> age = c(58,68,23,20,50,43,41,69,20,48,19,27,39,20,65,49,70,59,31,43,25,
> 61,60,45,34,59,32,58,30,62,26,44,52,29,40,57,33,18,50,50,55,51,38,34,
> 69,56,67,38,66,21,48,39,62,62,29,68,66,19,60,39,55,42,24,29,56,61,40,
> 52,19,40,33,67,66,51,48,63,60,58,68,60,53,20,45,62,37,38,61,63,43,67,
> 49,39,43,67,49,69,32,37,32,63,33,47,66,39,23,57,26,61,20,49,69,30,40,
> 29,38,66,60,69,69,44,65,25,41,53,18,55,45,59,49,27,51,29,67,26,24,26,
> 47,23,50,27,35,45,32,26,45,45,63,39,39,22,38,27,31,27,49,65,66,49,39,
> 21,51,49,55,63,19,26,50,21,24,34,65,33,55,33,36,53,48,25,54,58,60,34,
> 47,23,34,60,39,34,22,30,41,55,64,48,34,54))
> frame.bc
>
> # preparing for a simple univariate Cox regression:
> dd.bc <- datadist(frame.bc[, c('bc1','age')], adjto.cat='first')
> options(datadist = 'dd.bc')
>
> # a univariate Cox regression:
> cph.bc <- cph(formula = Surv(time1,status1)~bc1,
> data = frame.bc, x=TRUE, y=TRUE, surv=TRUE)
> anova(cph.bc)
> cph.bc
> summary(cph.bc)
>
> # the validate command for the Cox model:
> val.cph.bc <- validate(cph.bc, B=200, dxy=TRUE , pr=TRUE)
>
> ----------------------
> Output from the validate command:
>
> training test
> Dxy -0.124360 -0.1423409
> R2 1.000000 1.0000000
> Slope 1.000000 0.7919584
> D 0.016791 0.0147536
> U -0.002395 0.0006448
> Q 0.019186 0.0141088
> training test
> Dxy -0.191875 -0.1423409
> R2 1.000000 1.0000000
> Slope 1.000000 0.8936724
> D 0.022397 0.0147536
> U -0.002339 0.0001367
> Q 0.024736 0.0146169
> training test
> Dxy -0.199514 -0.1423409
> R2 1.000000 1.0000000
> Slope 1.000000 0.8075246
> D 0.025717 0.0147536
> U -0.002447 0.0005348
> Q 0.028163 0.0142188
> Error in Xb(x[, xcol, drop = FALSE], coef, non.slopes, non.slopes.in.x, :
> subscript out of bounds
>
>
> Any help/suggestions will be highly appreciated.
>
>
> Sincerely,
> Tore Wentzel-Larsen
> statistician
> Centre for Clinical research
> Armauer Hansen house
> Haukeland University Hospital
> N-5021 Bergen
> tlf +47 55 97 55 39 (a)
> faks +47 55 97 60 88 (a)
> email tore.wentzel-larsen at helse-bergen.no
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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 E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help
mailing list