Create all possible combinations of vector input
This function constructs all possible k-way combinations of an input vector.
It is primarily useful when used in conjunction with the mdirt
function,
though users may have other uses for it as well. See expand.grid
for more
flexible combination formats.
thetaComb(theta, nfact, intercept = FALSE)
theta |
the vector from which all possible combinations should be obtained |
nfact |
the number of observations (and therefore the number of columns to return in the matrix of combinations) |
intercept |
logical; should a vector of 1's be appended to the first column of the
result to include an intercept design component? Default is |
a matrix with all possible combinations
Phil Chalmers rphilip.chalmers@gmail.com
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Environment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
# all possible joint combinations for the vector -4 to 4 thetaComb(-4:4, 2) # all possible binary combinations for four observations thetaComb(c(0,1), 4) # all possible binary combinations for four observations (with intercept) thetaComb(c(0,1), 4, intercept=TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.