trend: Trend Component from a 'km' Object

View source: R/trend.R

trendR Documentation

Trend Component from a km Object

Description

Evaluate the trend component of a km object on the given design X.

Usage

trend(object, X, deriv = 0, diagOnly = FALSE)

Arguments

object

A km object.

X

A "design": a numeric matrix or data frame wih numeric columns compatible with object.

deriv

Logical. If TRUE the derivative will be returned as the "deriv" attribute of the result. This will be an array with dimension either c(n, p, n, d) or c(n, p, d) depending on the value of diagOnly.

diagOnly

Logical. If TRUE the structure of the result takes into account the fact that the row i of the trend matrix F depends only on the row i of the design matrix X so some elements in the Jacobian array are structural zeroes and can be omitted. See Details.

Details

The derivatives are stored in a "Jacobian array" say J. Let n be the number of rows in X,

  • If diagOnly is FALSE; The array is four-dimensional with dimension (n * p) * (n * d) where the first parenthese encloses the dimension of the "trend" matrix F and the second one encloses the dimension of the "design" matrix X. The general element is

    J[i, j, k, l] = dF[i, j] / dX[k, l].

    Note that this value is zero when i != k.

  • If diagOnly is TRUE, the Jacobian array is 3-dimensional with dimension n * p * d and its element is

    J[i, j, l] = dF[i, j] / dX[i, l].

    So the structural zeroes of the previous array are omitted. This is especially useful if n is large.

Value

The trend matrix, possibly with the Jacobian array attached as an attribute named "deriv".

Examples

library(DiceKriging)
# a 16-points factorial design, and the corresponding response
d <- 2; n <- 16
design.fact <- expand.grid(x1 = seq(0, 1, length = 4),
                           x2 = seq(0, 1, length = 4))
y <- apply(design.fact, 1, branin)

## kriging model 1 : matern5_2 covariance structure, no trend, no
## nugget effect
fit <- km(~ x1 + x2, design = design.fact, response = y)
X <- matrix(runif(n = 40), ncol = 2,
            dimnames = list(NULL, c("x1", "x2")))
fitTrend <- trend(fit, X = X, deriv = 1)
fitTrend <- trend(fit, X = X[1, ], deriv = 1)

libKriging/dolka documentation built on April 14, 2022, 7:17 a.m.