Learn R Programming

kergp (version 0.5.7)

parseCovFormula: Parse a Formula or Expression Describing a Composite Covariance Kernel

Description

Parse a formula (or expression) describing a composite covariance kernel.

Usage

parseCovFormula(formula, where = .GlobalEnv, trace = 0)

Value

A list with the results of parsing. Although the results content is easy to understand, the function is not intended to be used by the final user, and the results may change in future versions.

Arguments

formula

A formula or expression describing a covariance kernel. See Examples.

where

An environment where kernel objects and top parameters are searched for.

trace

Integer level of verbosity.

Caution

Only relatively simple formulas are correctly parsed. So use only formulas having a structure similar to one of those given in the examples. In case of problems, error messages are likely to be difficult to understand.

Author

Yves Deville

Details

The formula involves existing covariance kernel objects and must define a valid kernel composition rule. For instance the sum and the product of kernels, the convex combination of kernels are classically used. The kernels objects are used in the formula with parentheses as is they where functions calls with no formal arguments e.g. obj( ). Non-kernel objects used in the formula must be numeric scalar parameters and are called top parameters. The covariance objects must exist in the environment defined by where because their slots will be used to identify the inputs and the parameters of the composite kernel defined by the formula.

Examples

Run this code
## =========================================================================
## build some kernels (with their inputNames) in the global environment
## =========================================================================

myCovExp3 <- kMatern(d = 3, nu = "1/2")
inputNames(myCovExp3) <- c("x", "y", "z")

myCovGauss2 <- kGauss(d = 2)
inputNames(myCovGauss2) <- c("temp1", "temp2")

k <- kMatern(d = 1)
inputNames(k) <- "x"

ell <- kMatern(d = 1)
inputNames(ell) <- "y"

## =========================================================================
## Parse a formula. This formula is stupid because 'myCovGauss2'
## and 'myCovExp3' should be CORRELATION kernels and not
## covariance kernels to produce an identifiable model.
## =========================================================================

cov <- ~ tau2 * myCovGauss2() * myCovExp3() + sigma2 * k()
pf <- parseCovFormula(cov, trace = 1)

## =========================================================================
## Parse a formula with ANOVA composition
## =========================================================================

cov1 <- ~ tau2 * myCovGauss2() * myCovExp3() + sigma2 * (1 + k()) * (1 + ell())
pf1 <- parseCovFormula(cov1, trace = 1) 

Run the code above in your browser using DataLab