Learn R Programming

mirt (version 1.42)

thetaComb: 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)

Value

a matrix with all possible combinations

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

Author

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. tools:::Rd_expr_doi("10.18637/jss.v048.i06")

Examples

Run this code

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

Run the code above in your browser using DataLab