b_maxvarK: Maximum Variance of Gaussian Kernel Matrix

View source: R/functions.R

b_maxvarKR Documentation

Maximum Variance of Gaussian Kernel Matrix

Description

Searches for the argmax of the variance of the Kernel matrix

Usage

b_maxvarK(data, useasbases, cat_data = TRUE, maxsearch_b = 2000)

Arguments

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 one_hot() to produce) with cat_data argument true.

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

maxsearch_b

the maximum value of b, the denominator of the Gaussian, in searched during maximization.

Value

b_maxvar

numeric b value, the denominator of the Gaussian, which produces the maximum variance of K kernel matrix

var_K

numeric maximum variance of K kernel matrix found with b as b_maxvar

Examples


#lalonde with only categorical data
data(lalonde)
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) 
 

chadhazlett/KBAL documentation built on Jan. 3, 2024, 9:57 p.m.