Takes a data frame and return the lists required for muliclass_reg() to work

data_to_lists(data, class_var = "class", y_var = "y")

Arguments

data

data frame with (at least) all the variables in the formula as well as the class identifier variable

class_var

the name of the class variable in the data frame

y_var

the name of the dependent variable in the data frame

Value

A list with the following components

Y

list of size \(K\). Its kth entry is a vector of size \(n_k\)

X

list of size \(K\). Its kth entry is a matrix of size \(n_{k} \times p\)

Examples

p = 7
k = 2
n = 20
beta = c(1,2)
set.seed(1)
X = list(matrix(rnorm(p*n), ncol = p), matrix(rnorm(p*n), ncol = p))
Y = list(rnorm(n), rnorm(n))
df = lists_to_data(Y, X)
lst = data_to_lists(df)