Taemyong Choi
2004-Jun-30 03:56 UTC
[R] gap() in SAGx package - How to handle this situation?
gap(data,cluster)
Arguments: data - The data matrix
cluster - a vector descibing the cluster memberships
When I use gap(),
Our data matrix 300 * 40 , it worked
But data matrix 40 * 300, it don't work
And next is error message.
- Error in data %*% t(veigen) : non-conformable arguments
Gap Function
function (data = swiss, class = g, B = 500)
{
library(mva)
if (min(table(class)) == 1)
stop("Singleton clusters not allowed")
data <- as.matrix(data)
temp1 <- log(sum(by(data, factor(class), intern <- function(x)
sum(dist(x)/ncol(x))/2)))
>>
veigen <- svd(data)$v
x1 <- data %*% t(veigen) <<- Error Message
...
Example;
In gap function, when we compute singular value decomposition, X, X = UDV,
here X is data matrix with dimension of 30*400,
we expect following results : U : 30*30 dimension, D: 30*400 dimenstion, V
:400*400 dimenstion
But gap function create U=30*30 D=30*400 V=400*30 .
How to handle this error message?
Thanks in advance.
Best regards.
[[alternative HTML version deleted]]