This very simple helper generates combinations with replacement.
generate_combinations_with_replacement(x, k)
A m x k matrix, where m is the number of combinations.
vector of elements to choose from.
number of elements to choose.
This is replicating the functionality from arrangements::combinations
with
replace = TRUE
. Note that base R function utils::combn
only returns
combinations without replacement, thus pairs like (0, 0) are not in the
output.
Note that this function is extremely inefficient and only intended to be used with small use cases, i.e. small k. This is typically the case in the context of MFP, but a warning is given if this is not the case since the algorithm may take a while to compute the combinations, and even longer to do model selection.