constrained_adjacency_covariance_function: Construct a constrained covariance matrix from the adjacency...

View source: R/constrained_covariance_functions.R

constrained_adjacency_covariance_functionR Documentation

Construct a constrained covariance matrix from the adjacency matrix

Description

This function constructs a covariance function from the graph's adjacency matrix. The covariance function may be squared exponential, rational quadratic, Matern or the matrix exponential. It includes a constraint, where a linear combination of the parameters can be fixed.

Usage

constrained_adjacency_covariance_function(
  adj.matrix,
  type,
  hyperparameters,
  linear.combination,
  linear.constraint = 0
)

Arguments

adj.matrix

The graph adjacency matrix

type

The type of covariance function used. One of "sqexp", "ratquad", "matern" or "matrix". Note: only matern with nu = 5/2 is supported.

hyperparameters

A vector containing the covariance function hyperparameters. For the squared exponential and matern, the vector should contain the variance and length scale, for the rational quadratic, the vector should contain the variance, length scale and scaling parameters

linear.combination

A matrix which defines the linear combination of the parameter vector lambda = (lambda_1, ..., lambda_N)^T. The linear combination is a vector of coefficients such that linear.combination %*% lambda = linear.constraint.

linear.constraint

The value the linear constraint takes. Defaults to 0.

Value

The mean vector and covariance matrix

See Also

For more information about covariance functions see https://www.cs.toronto.edu/~duvenaud/cookbook/ or http://gaussianprocess.org/gpml/chapters/RW4.pdf

Examples

#Construct covariance matrix of Dar es Salaam, Tanzania, using network metric
data(dar.adj.matrix, package = "BSBT") #load dar es salaam adjacency matrix
k <- constrained_adjacency_covariance_function(dar.adj.matrix, type = "sqexp",
       hyperparameters = c(1, 1), rep(1, dim(dar.adj.matrix)[1]), 0)
       #Covariance registered by sum of objects is 0 using rational quadratic function

BSBT documentation built on Aug. 9, 2022, 5:06 p.m.