generateKernelMatrix: Centralized Kernel Similarity Matrix

View source: R/internal.R View source: R/generateKernelMatrix.R

generateKernelMatrixR Documentation

Centralized Kernel Similarity Matrix

Description

Given a n \times p matrix of sample observations indexed by row and a choice of kernel function, returns an empirical estimate of the n \times n matrix whose (i,j)th entry is the centralized version of the kernel function evaluated at the pair of rows i and j of x.

Usage

generateKernelMatrix(x, kernel_function = "gau")

Arguments

x

a numeric matrix containing the sample data with observations indexed by row.

kernel_function

a character string identifying the kernel function to use. For a list of valid strings, use listAmkatKernelFunctions().

Details

If the kernel function is expressed as f(x_1, x_2) for two p-dimensional vectors x_1 and x_2, then generateKernelMatrix first computes the non-centralized empirical kernel matrix K whose (i,j)th entry is f(x_i, x_j), where x_i and x_i are the ith and jth rows of x, respectively. Letting K* denote a copy of K with zero entries along the main diagonal and J denote a n \times n matrix of ones, the empirical centralized kernel matrix is then computed as

K - (JK* + K*J - JK*J / n) / (n - 1)

.

Details on the available kernel functions can be found in the help topic for listAmkatKernelFunctions.

Value

A square numeric matrix with the same row dimension as x, whose (i,j)th entry is the empirically centralized value for kernel-based pairwise similarity between rows i and j of x.

Author(s)

Brian Neal

References

Neal, Brian and He, Tao. “An adaptive multivariate kernel-based test for association with multiple quantitative traits in high-dimensional data.” Genetic Epidemiology (not yet submitted).

Examples

x <- matrix(rnorm(50 * 25), nrow = 25, ncol = 50)
ker_mat_lin <- generateKernelMatrix(x, "lin")
ker_mat_quad <- generateKernelMatrix(x, "quad")
ker_mat_gau <- generateKernelMatrix(x, "gau")
ker_mat_exp <- generateKernelMatrix(x, "exp")

x <- matrix(rbinom(n = 50 * 25, size = 2, prob = 0.25),
            nrow = 25, ncol = 50)
ker_mat_ibs <- generateKernelMatrix(x, "IBS")

brianpatrickneal/AMKAT documentation built on June 15, 2022, 8:47 a.m.