These functions are used to find all possible binary partitions. Finding all combinations require a classification vector with K > 1 strata.
1 2 3
a vector for
character, what to paste between levels.
numeric, number of levels (strata) in a given classification (K > 1).
kComb returns a contrast matrix corresponding to
all possible binary partitions of the factor with K levels.
Complements are not counted twice, i.e.
(0,0,1,1) is equivalent to (1,1,0,0).
The number of such possible combinations is M = 2^(K - 1) - 1.
allComb takes a classification vector with at least 2 levels
and returns a model matrix with binary partitions.
checkComb checks if combinations are unique and non-complementary
(misfits are returned as attributes). Returns a logical value.
Peter Solymos <[email protected]>
opticut for the user interface.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
kComb(k = 2) kComb(k = 3) kComb(k = 4) ## finding all combinations (f <- rep(LETTERS[1:4], each=2)) (mc <- allComb(f, collapse = "_")) ## checking for complementary entries checkComb(mc) # TRUE ## adding complementary entries to the matrix mc2 <- cbind(z = 1 - mc[,1], mc[,c(1:ncol(mc), 1)]) colnames(mc2) <- 1:ncol(mc2) mc2 checkComb(mc2) # FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.