Displaying 1 result from an estimated 1 matches for "vec12".
Did you mean:
vec1
2008 Aug 22
1
Retrieving sample points
...size, is there anyway I can maximize the memory.
Here is the syntax that I used.
> bestunits <- function(x){
+ n <- nrow(x)
+ p <- ncol(x)
+ h <- p+1
+ nchoosek <- function(n,h){
+ factorial(n)/(factorial(h+1)*factorial(n-h-1))}
+ vec11 <- matrix(nrow=nchoosek(n,h), ncol=p)
+ vec12 <- matrix(nrow=nchoosek(n,h), ncol=h)
+ for (i in 1:nchoosek(n,h)){
+ flag <- sample(1:n, h, replace=FALSE)
+ z <- x[flag,]
+ y <- eigen(var(z), only.values=TRUE)$values
+ vec11[i,] <- y
+ vec12[i,] <- flag
+ }
+ product <- apply(vec11,1,prod)
+ best <- which.min(product)
+...