Skip to contents

Computes the Gram Matrix for a user-specified kernel using the library kernlab. Note that this function automatically standardizes the columns of the data entered.

Usage

compute_gram_matrix(X, kernel_type, params = c())

Arguments

X

The design matrix with $n$ rows (one for each subject) and $p$ columns (one for each measurement on the subject). This is the design matrix you wish to search for a more optimal design.

kernel_type

One of the following: "vanilla", "rbf", "poly", "tanh", "bessel", "laplace", "anova" or "spline".

params

A vector of numeric parameters. Each kernel_type has different numbers of parameters required. For more information see documentation for the kernlab library.

Value

The n x n gram matrix for the given kernel on the given data.

Author

Adam Kapelner

Examples

if (FALSE) { # \dontrun{
set.seed(1)
X = matrix(rnorm(12), nrow = 6)
K = compute_gram_matrix(X, kernel_type = "rbf", params = 0.5)
dim(K)
} # }