kernL {iprior}R Documentation

Load the kernel matrices for I-prior models

Description

Load the kernel matrices for I-prior models

Usage

kernL(
  y,
  ...,
  kernel = "linear",
  interactions = NULL,
  est.lambda = TRUE,
  est.hurst = FALSE,
  est.lengthscale = FALSE,
  est.offset = FALSE,
  est.psi = TRUE,
  fixed.hyp = NULL,
  lambda = 1,
  psi = 1,
  nystrom = FALSE,
  nys.seed = NULL,
  model = list(),
  train.samp,
  test.samp,
  intercept
)

## S3 method for class 'formula'
kernL(
  formula,
  data,
  kernel = "linear",
  one.lam = FALSE,
  est.lambda = TRUE,
  est.hurst = FALSE,
  est.lengthscale = FALSE,
  est.offset = FALSE,
  est.psi = TRUE,
  fixed.hyp = NULL,
  lambda = 1,
  psi = 1,
  nystrom = FALSE,
  nys.seed = NULL,
  model = list(),
  train.samp,
  test.samp,
  intercept,
  ...
)

Arguments

y

Vector of response variables

...

Only used when fitting using non-formula, enter the variables (vectors or matrices) separated by commas.

kernel

Character vector indicating the type of kernel for the variables. Available choices are:

  • "linear" - (default) for the linear kernel

  • "canonical" - alternative name for "linear"

  • "fbm", "fbm,0.5" - for the fBm kernel with Hurst coefficient 0.5 (default)

  • "se", "se,1" - for the SE kernel with lengthscale 1 (default)

  • "poly", "poly2", "poly2,0" - for the polynomial kernel of degree 2 with offset 0 (default)

  • "pearson" - for the Pearson kernel

The kernel argument can also be a vector of length equal to the number of variables, therefore it is possible to specify different kernels for each variables. Note that factor type variables are assigned the Pearson kernel by default, and that non-factor types can be forced to use the Pearson kernel (not recommended).

interactions

Character vector to specify the interaction terms. When using formulas, this is specified automatically, so is not required. Syntax is "a:b" to indicate variable a interacts with variable b.

est.lambda

Logical. Estimate the scale parameters? Defaults to TRUE.

est.hurst

Logical. Estimate the Hurst coefficients for fBm kernels? Defaults to FALSE.

est.lengthscale

Logical. Estimate the lengthscales for SE kernels? Defaults to FALSE.

est.offset

Logical. Estimate the offsets for polynomial kernels? Defaults to FALSE.

est.psi

Logical. Estimate the error precision? Defaults to TRUE.

fixed.hyp

Logical. If TRUE, then no hyperparameters are estimated, i.e. all of the above est.x are set to FALSE, and vice versa. If NULL (default) then all of the est.x defaults are respected.

lambda

Initial/Default scale parameters. Relevant especially if est.lambda = FALSE.

psi

Initial/Default value for error precision. Relevant especially if est.psi = FALSE.

nystrom

Either logical or an integer indicating the number of Nystrom samples to take. Defaults to FALSE. If TRUE, then approximately 10% of the sample size is used for the Nystrom approximation.

nys.seed

The random seed for the Nystrom sampling. Defaults to NULL, which means the random seed is not fixed.

model

DEPRECATED.

train.samp

(Optional) A vector indicating which of the data points should be used for training, and the remaining used for testing.

test.samp

(Optional) Similar to train.samp, but on test samples instead.

intercept

(Optional) Intercept for response variables.

formula

The formula to fit when using formula interface.

data

Data frame containing variables when using formula interface.

one.lam

Logical. When using formula input, this is a convenient way of letting the function know to treat all variables as a single variable (i.e. shared scale parameter). Defaults to FALSE.

Value

An ipriorKernel object which contains the relevant material to be passed to the iprior function for model fitting.

See Also

iprior

Examples


str(ToothGrowth)
(mod <- kernL(y = ToothGrowth$len,
               supp = ToothGrowth$supp,
               dose = ToothGrowth$dose,
               interactions = "1:2"))
kernL(len ~ supp * dose, data = ToothGrowth)  # equivalent formula call

# Choosing different kernels
str(stackloss)
kernL(stack.loss ~ ., stackloss, kernel = "fbm")  # all fBm kernels
kernL(stack.loss ~ ., stackloss, kernel = "FBm")  # cApS dOn't MatTeR
kernL(stack.loss ~ ., stackloss,
       kernel = c("linear", "se", "poly3"))  # different kernels

# Sometimes the print output is too long, can use str() options here
print(mod, strict.width = "cut", width = 30)


[Package iprior version 0.7.4 Index]