This function takes a matrix with dummy outlier columns, where there are possibly multiple ones. We first merge these columns to one and then explode them to obtain one dummy variable per column.

explode_dummies(outlier_dummies)

Arguments

outlier_dummies

A matrix of outlier dummy variables in columns.

Value

A matrix with dummy variables in columns, each having one nonzero index. The columns are named outlier_x, with x being the 1-based row index of the position that this dummy variable is masking.

Examples

outlier_dummies <- matrix(NA, nrow = 5, ncol = 3, dimnames = list(NULL, c('rumination', 'happiness', 'activity'))) outlier_dummies[, 1] <- c(0, 0, 1, 0, 1) outlier_dummies[, 2] <- c(0, 1, 1, 0, 0) outlier_dummies[, 3] <- c(1, 0, 0, 0, 1) outlier_dummies
#> rumination happiness activity #> [1,] 0 0 1 #> [2,] 0 1 0 #> [3,] 1 1 0 #> [4,] 0 0 0 #> [5,] 1 0 1
autovarCore:::explode_dummies(outlier_dummies)
#> outlier_1 outlier_2 outlier_3 outlier_5 #> [1,] 1 0 0 0 #> [2,] 0 1 0 0 #> [3,] 0 0 1 0 #> [4,] 0 0 0 0 #> [5,] 0 0 0 1