thetaComb: Create all possible combinations of vector input

View source: R/utils.R

thetaCombR Documentation

Create all possible combinations of vector input

Description

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.

Usage

thetaComb(theta, nfact, intercept = FALSE)

Arguments

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 FALSE

Value

a matrix with all possible combinations

Author(s)

Phil Chalmers rphilip.chalmers@gmail.com

References

Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Environment. Journal of Statistical Software, 48(6), 1-29. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v048.i06")}

Examples


# 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)


mirt documentation built on Sept. 11, 2024, 7:14 p.m.