| margination {truecluster} | R Documentation |
Functions to calculate the number of possible groupings given fixed group sizes (margins).
nlabelation(...) lnlabelation(...) ldlabelation(...) nmargination(...) lnmargination(...) ldmargination(...)
... |
one or more vectors of group sizes |
Function nmargination gives the number of possibles groupings (=cluster solutions) that have the input group sizes.
Function nlabelation gives the number of possibles assignents to predefined (=labelled) groups of the requires sizes (more possibilities).
The ln-versions give the log instead, the ld-versions the logarithm dualis.
scalar
Jens Oehlschlägel
clusteration, permutation, combination, choose, lgamma, absolute.entropy, exact.margin.info
cat("There are 25 possibilities to make 3 clusters from 5 cases\n")
nclusteration(5,3)
cat(" 10 of sizes 3,1,1\n")
nmargination(3,1,1)
cat(" and 15 of sizes 2,2,1\n")
nmargination(2,2,1)
cat("By contrast there are 30 possibilities to assign 5 cases to 3 labelled groups a=2,b=2,c=1\n")
nlabelation(2,2,1)
n <- 250
k <- 5
i <- 1:(n/k)
matplot(k*i, cbind(
k^(i*k)
, sapply(i, function(i){nclusteration(k*i, k)})
, sapply(i, function(i){nmargination(rep(i, k))})
)
, log="y", type="l"
, lty=1:3, xlab="n"
, ylab = "combinations"
, main = "number of possible groupings"
)
legend(n,1
, c(substitute(k^n, list(k=k)), expression("no restriction"), expression("equal sizes"))
, lty=1:3, col=1:3, xjust=1, yjust=0
)