Interact several factors. This function allows for binary \(\{0,1\}\) interaction between observable factors xi and xj. xi and xj should be of the same length. It creates a 1 if i and j belong to the same category (xi=xj) and zero otherwise. This function also allows several factors i.e. xi and xj as vectors

inter_xij(xi, xj, k = length(xi))

Arguments

xi

vector of first variable terms

xj

vector of second variable terms

k

a dummy input as length of xi; does not need to be specified.

Value

vector of binaries \(\{0,1\}\) the same length as xi

Examples

xi=c(0,1,0); xj=c(0,1,1); inter_xij(xi,xj,2)
#> [1] 1 1 0