Full_Name: Dominique Soudant
Version: 2.4.1
OS: Winbdows
Submission from: (NULL) (134.246.54.61)
R 2.4.1
boot 1.2-27
Let us consider the following example with 8 strata, one observation for each :
[,1]
[1,] 0.2
[2,] 0.5
[3,] 0.8
[4,] 0.2
[5,] 0.2
[6,] 1.0
[7,] 0.5
[8,] 1.0
[9,] 0.8
[10,] 1.0
Results are differents, they should be equal. I guess that the issue is coming
from the function ordinary.array() from the boot package :
ordinary.array <- function (n, R, strata)
{
output <- matrix(0, R, n)
inds <- as.integer(names(table(strata)))
for (is in inds) {
gp <- c(1:n)[strata == is]
output[, gp] <- matrix(sample(gp, R * length(gp), replace = TRUE),
nrow = R)
}
output
}
ordinary.array(8,10,1:8)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 1 1 2 2 1 1 5 2
[2,] 1 1 2 2 3 3 2 5
[3,] 1 2 1 4 2 1 1 7
[4,] 1 1 3 2 5 5 3 6
[5,] 1 1 2 4 5 3 7 1
[6,] 1 2 2 4 4 6 1 8
[7,] 1 1 2 2 4 2 7 5
[8,] 1 2 3 2 3 4 1 7
[9,] 1 2 2 1 1 3 1 2
[10,] 1 1 2 4 5 1 1 5
In ordinary.array(), the issue is coming from sample() :
[quote]If x has length 1 and x >= 1, sampling takes place from 1:x[/quote]
Note that when only one strata has only one observation, the problem is
identical
ordinary.array(7,10,c(rep(1:3,each=2),4))
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 1 2 3 3 6 5 6
[2,] 2 2 3 4 5 5 7
[3,] 2 2 4 4 6 5 5
[4,] 1 1 4 4 6 5 1
[5,] 2 2 3 3 6 5 7
[6,] 1 2 3 4 5 5 1
[7,] 1 2 4 3 6 6 5
[8,] 2 1 3 4 5 6 2
[9,] 2 2 3 4 6 6 4
[10,] 2 2 4 3 6 5 2
but less detectable in the results.
The same results are obtained with :
R 2.8.1
boot 1.2-35
Best regards.
______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel