b_maxvarK | R Documentation |
Searches for the argmax of the variance of the Kernel matrix.
b_maxvarK(data, useasbases, cat_data = TRUE, maxsearch_b = 2000)
data |
a matrix of data where rows are all units and columns are covariates. Where all covariates are categorical, this matrix should be one-hot encoded (refer to |
useasbases |
binary vector specifying what observations are to be used in forming bases (columns) of the kernel matrix. Suggested default is: if the number of observations is under 4000, use all observations; when the number of observations is over 4000, use the sampled (control) units only. |
cat_data |
logical for whether kernel contains only categorical data or not. Default is |
maxsearch_b |
the maximum value of |
b_maxvar |
numeric |
var_K |
numeric maximum variance of |
#lalonde with only categorical data
set.seed(123)
data("lalonde")
# Select a random subset of 500 rows
lalonde_sample <- sample(1:nrow(lalonde), 500, replace = FALSE)
lalonde <- lalonde[lalonde_sample, ]
cat_vars <- c("black","hisp","married","nodegr","u74","u75")
#Convert to one-hot encoded data matrix:
onehot_lalonde = one_hot(lalonde[, cat_vars])
colnames(onehot_lalonde)
best_b <- b_maxvarK(data = onehot_lalonde,
useasbases = 1-lalonde$nsw)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.