Title: | Kriging Models using the 'libKriging' Library |
---|---|
Description: | Interface to 'libKriging' 'C++' library <https://github.com/libKriging> that should provide most standard Kriging / Gaussian process regression features (like in 'DiceKriging', 'kergp' or 'RobustGaSP' packages). 'libKriging' relies on Armadillo linear algebra library (Apache 2 license) by Conrad Sanderson, 'lbfgsb_cpp' is a 'C++' port around 'lbfgsb' library (BSD-3 license) by Ciyou Zhu, Richard Byrd, Jorge Nocedal and Jose Luis Morales used for hyperparameters optimization. |
Authors: | Yann Richet [aut, cre] , Pascal Havé [aut], Yves Deville [aut], Conrad Sanderson [ctb], Ciyou Zhu [ctb], Richard Byrd [ctb], Jorge Nocedal [ctb], Jose Luis Morales [ctb], Mike Smith [ctb] |
Maintainer: | Yann Richet <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.9-0 |
Built: | 2024-08-24 07:04:38 UTC |
Source: | CRAN |
km
ObjectCoerce an object into an object with S4 class "km"
from the
DiceKriging package.
as.km(x, ...)
as.km(x, ...)
x |
Object to be coerced. |
... |
Further arguments for methods. |
Such a coercion is typically used to compare the performance of the methods implemented in the current rlibkriging package to those which are available in the DiceKriging package.
An object with S4 class "km"
.
Kriging
object into the "km"
class of the
DiceKriging package.Coerce a Kriging
object into the "km"
class of the
DiceKriging package.
## S3 method for class 'Kriging' as.km(x, .call = NULL, ...)
## S3 method for class 'Kriging' as.km(x, .call = NULL, ...)
x |
An object with S3 class |
.call |
Force the |
... |
Not used. |
An object of having the S4 class "KM"
which extends
the "km"
class of the DiceKriging package and
contains an extra Kriging
slot.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, "matern3_2") print(k) k_km <- as.km(k) print(k_km)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, "matern3_2") print(k) k_km <- as.km(k) print(k_km)
NoiseKriging
object into the "km"
class of the
DiceKriging package.Coerce a NoiseKriging
object into the "km"
class of the
DiceKriging package.
## S3 method for class 'NoiseKriging' as.km(x, .call = NULL, ...)
## S3 method for class 'NoiseKriging' as.km(x, .call = NULL, ...)
x |
An object with S3 class |
.call |
Force the |
... |
Not used. |
An object of having the S4 class "KM"
which extends
the "km"
class of the DiceKriging package and
contains an extra NoiseKriging
slot.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X ## fit and print k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") print(k) k_km <- as.km(k) print(k_km)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X ## fit and print k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") print(k) k_km <- as.km(k) print(k_km)
NuggetKriging
object into the "km"
class of the
DiceKriging package.Coerce a NuggetKriging
object into the "km"
class of the
DiceKriging package.
## S3 method for class 'NuggetKriging' as.km(x, .call = NULL, ...)
## S3 method for class 'NuggetKriging' as.km(x, .call = NULL, ...)
x |
An object with S3 class |
.call |
Force the |
... |
Not used. |
An object of having the S4 class "KM"
which extends
the "km"
class of the DiceKriging package and
contains an extra NuggetKriging
slot.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, "matern3_2") print(k) k_km <- as.km(k) print(k_km)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, "matern3_2") print(k) k_km <- as.km(k) print(k_km)
Kriging
Object into a ListCoerce a Kriging
Object into a List
## S3 method for class 'Kriging' as.list(x, ...)
## S3 method for class 'Kriging' as.list(x, ...)
x |
An object with class |
... |
Ignored |
A list with its elements copying the content of the
Kriging
object fields: kernel
, optim
,
objective
, theta
(vector of ranges),
sigma2
(variance), X
, centerX
,
scaleX
, y
, centerY
, scaleY
,
regmodel
, F
, T
, M
, z
,
beta
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x ) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2") l <- as.list(k) cat(paste0(names(l), " =" , l, collapse = "\n"))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x ) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2") l <- as.list(k) cat(paste0(names(l), " =" , l, collapse = "\n"))
NoiseKriging
Object into a ListCoerce a NoiseKriging
Object into a List
## S3 method for class 'NoiseKriging' as.list(x, ...)
## S3 method for class 'NoiseKriging' as.list(x, ...)
x |
An object with class |
... |
Ignored |
A list with its elements copying the content of the
NoiseKriging
object fields: kernel
, optim
,
objective
, theta
(vector of ranges),
sigma2
(variance), X
, centerX
,
scaleX
, y
, centerY
, scaleY
,
regmodel
, F
, T
, M
, z
,
beta
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") l <- as.list(k) cat(paste0(names(l), " =" , l, collapse = "\n"))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") l <- as.list(k) cat(paste0(names(l), " =" , l, collapse = "\n"))
NuggetKriging
Object into a ListCoerce a NuggetKriging
Object into a List
## S3 method for class 'NuggetKriging' as.list(x, ...)
## S3 method for class 'NuggetKriging' as.list(x, ...)
x |
An object with class |
... |
Ignored |
A list with its elements copying the content of the
NuggetKriging
object fields: kernel
, optim
,
objective
, theta
(vector of ranges),
sigma2
(variance), X
, centerX
,
scaleX
, y
, centerY
, scaleY
,
regmodel
, F
, T
, M
, z
,
beta
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2") l <- as.list(k) cat(paste0(names(l), " =" , l, collapse = "\n"))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2") l <- as.list(k) cat(paste0(names(l), " =" , l, collapse = "\n"))
Shortcut to provide functions to the S3 class "Kriging"
classKriging(nk)
classKriging(nk)
nk |
A pointer to a C++ object of class "Kriging" |
An object of class "Kriging" with methods to access and manipulate the data
Shortcut to provide functions to the S3 class "NoiseKriging"
classNoiseKriging(nk)
classNoiseKriging(nk)
nk |
A pointer to a C++ object of class "NoiseKriging" |
An object of class "NoiseKriging" with methods to access and manipulate the data
Shortcut to provide functions to the S3 class "NuggetKriging"
classNuggetKriging(nk)
classNuggetKriging(nk)
nk |
A pointer to a C++ object of class "NuggetKriging" |
An object of class "NuggetKriging" with methods to access and manipulate the data
Duplicate a model given in
object
.
copy(object, ...)
copy(object, ...)
object |
An object representing a fitted model. |
... |
Ignored. |
The copied object.
Duplicate a Kriging Model
## S3 method for class 'Kriging' copy(object, ...)
## S3 method for class 'Kriging' copy(object, ...)
object |
An S3 Kriging object. |
... |
Not used. |
The copy of object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) print(copy(k))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) print(copy(k))
Duplicate a NoiseKriging Model
## S3 method for class 'NoiseKriging' copy(object, ...)
## S3 method for class 'NoiseKriging' copy(object, ...)
object |
An S3 NoiseKriging object. |
... |
Not used. |
The copy of object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2", objective="LL") print(k) print(copy(k))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2", objective="LL") print(k) print(copy(k))
Duplicate a NuggetKriging Model
## S3 method for class 'NuggetKriging' copy(object, ...)
## S3 method for class 'NuggetKriging' copy(object, ...)
object |
An S3 NuggetKriging object. |
... |
Not used. |
The copy of object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2", objective="LMP") print(k) print(copy(k))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2", objective="LMP") print(k) print(copy(k))
Compute the covariance matrix of a model given in object
,
between given set of points.
covMat(object, ...)
covMat(object, ...)
object |
An object representing a fitted model. |
... |
Further arguments of function (eg. points, range). |
The covariance matrix.
Compute Covariance Matrix of Kriging Model
## S3 method for class 'Kriging' covMat(object, x1, x2, ...)
## S3 method for class 'Kriging' covMat(object, x1, x2, ...)
object |
An S3 Kriging object. |
x1 |
Numeric matrix of input points. |
x2 |
Numeric matrix of input points. |
... |
Not used. |
A matrix of the covariance matrix of the Kriging model.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "gauss") x1 = runif(10) x2 = runif(10) covMat(k, x1, x2)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "gauss") x1 = runif(10) x2 = runif(10) covMat(k, x1, x2)
Compute Covariance Matrix of NoiseKriging Model
## S3 method for class 'NoiseKriging' covMat(object, x1, x2, ...)
## S3 method for class 'NoiseKriging' covMat(object, x1, x2, ...)
object |
An S3 NoiseKriging object. |
x1 |
Numeric matrix of input points. |
x2 |
Numeric matrix of input points. |
... |
Not used. |
A matrix of the covariance matrix of the NoiseKriging model.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x1 = runif(10) x2 = runif(10) covMat(k, x1, x2)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x1 = runif(10) x2 = runif(10) covMat(k, x1, x2)
Compute Covariance Matrix of NuggetKriging Model
## S3 method for class 'NuggetKriging' covMat(object, x1, x2, ...)
## S3 method for class 'NuggetKriging' covMat(object, x1, x2, ...)
object |
An S3 NuggetKriging object. |
x1 |
Numeric matrix of input points. |
x2 |
Numeric matrix of input points. |
... |
Not used. |
A matrix of the covariance matrix of the NuggetKriging model.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- NuggetKriging(y, X, kernel = "gauss") x1 = runif(10) x2 = runif(10) covMat(k, x1, x2)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- NuggetKriging(y, X, kernel = "gauss") x1 = runif(10) x2 = runif(10) covMat(k, x1, x2)
Fit a model given in
object
.
fit(object, ...)
fit(object, ...)
object |
An object representing a fitted model. |
... |
Further arguments of function |
No return value. Kriging object argument is modified.
Kriging
object on given data.The hyper-parameters (variance and vector of correlation ranges)
are estimated thanks to the optimization of a criterion given by
objective
, using the method given in optim
.
## S3 method for class 'Kriging' fit( object, y, X, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "Newton", "none"), objective = c("LL", "LOO", "LMP"), parameters = NULL, ... )
## S3 method for class 'Kriging' fit( object, y, X, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "Newton", "none"), objective = c("LL", "LOO", "LMP"), parameters = NULL, ... )
object |
S3 Kriging object. |
y |
Numeric vector of response values. |
X |
Numeric matrix of input design. |
regmodel |
Universal Kriging linear trend: |
normalize |
Logical. If |
optim |
Character giving the Optimization method used to fit
hyper-parameters. Possible values are: |
objective |
Character giving the objective function to
optimize. Possible values are: |
parameters |
Initial values for the hyper-parameters. When
provided this must be named list with elements |
... |
Ignored. |
No return value. Kriging object argument is modified.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue", pch = 16) k <- Kriging("matern3_2") print(k) fit(k,y,X) print(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue", pch = 16) k <- Kriging("matern3_2") print(k) fit(k,y,X) print(k)
NoiseKriging
object on given data.The hyper-parameters (variance and vector of correlation ranges)
are estimated thanks to the optimization of a criterion given by
objective
, using the method given in optim
.
## S3 method for class 'NoiseKriging' fit( object, y, noise, X, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL"), parameters = NULL, ... )
## S3 method for class 'NoiseKriging' fit( object, y, noise, X, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL"), parameters = NULL, ... )
object |
S3 NoiseKriging object. |
y |
Numeric vector of response values. |
noise |
Numeric vector of response variances. |
X |
Numeric matrix of input design. |
regmodel |
Universal NoiseKriging
|
normalize |
Logical. If |
optim |
Character giving the Optimization method used to fit
hyper-parameters. Possible values are: |
objective |
Character giving the objective function to
optimize. Possible values are: |
parameters |
Initial values for the hyper-parameters. When
provided this must be named list with elements |
... |
Ignored. |
No return value. NoiseKriging object argument is modified.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X points(X, y, col = "blue", pch = 16) k <- NoiseKriging("matern3_2") print(k) fit(k,y,noise=(X/10)^2,X) print(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X points(X, y, col = "blue", pch = 16) k <- NoiseKriging("matern3_2") print(k) fit(k,y,noise=(X/10)^2,X) print(k)
NuggetKriging
object on given data.The hyper-parameters (variance and vector of correlation ranges)
are estimated thanks to the optimization of a criterion given by
objective
, using the method given in optim
.
## S3 method for class 'NuggetKriging' fit( object, y, X, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL", "LMP"), parameters = NULL, ... )
## S3 method for class 'NuggetKriging' fit( object, y, X, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL", "LMP"), parameters = NULL, ... )
object |
S3 NuggetKriging object. |
y |
Numeric vector of response values. |
X |
Numeric matrix of input design. |
regmodel |
Universal NuggetKriging
|
normalize |
Logical. If |
optim |
Character giving the Optimization method used to fit
hyper-parameters. Possible values are: |
objective |
Character giving the objective function to
optimize. Possible values are: |
parameters |
Initial values for the hyper-parameters. When provided this
must be named list with some elements |
... |
Ignored. |
No return value. NuggetKriging object argument is modified.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue", pch = 16) k <- NuggetKriging("matern3_2") print(k) fit(k,y,X) print(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue", pch = 16) k <- NuggetKriging("matern3_2") print(k) fit(k,y,X) print(k)
KM
ObjectCreate an object of S4 class "KM"
similar to a
km
object in the DiceKriging package.
KM( formula = ~1, design, response, covtype = c("matern5_2", "gauss", "matern3_2", "exp"), coef.trend = NULL, coef.cov = NULL, coef.var = NULL, nugget = NULL, nugget.estim = FALSE, noise.var = NULL, estim.method = c("MLE", "LOO"), penalty = NULL, optim.method = "BFGS", lower = NULL, upper = NULL, parinit = NULL, multistart = 1, control = NULL, gr = TRUE, iso = FALSE, scaling = FALSE, knots = NULL, kernel = NULL, ... )
KM( formula = ~1, design, response, covtype = c("matern5_2", "gauss", "matern3_2", "exp"), coef.trend = NULL, coef.cov = NULL, coef.var = NULL, nugget = NULL, nugget.estim = FALSE, noise.var = NULL, estim.method = c("MLE", "LOO"), penalty = NULL, optim.method = "BFGS", lower = NULL, upper = NULL, parinit = NULL, multistart = 1, control = NULL, gr = TRUE, iso = FALSE, scaling = FALSE, knots = NULL, kernel = NULL, ... )
formula |
R formula object to setup the linear trend in
Universal Kriging. Supports |
design |
Data frame. The design of experiments. |
response |
Vector of output values. |
covtype |
Covariance structure. For now all the kernels are tensor product kernels. |
coef.trend |
Optional value for a fixed vector of trend coefficients. If given, no optimization is done. |
coef.cov |
Optional value for a fixed correlation range value. If given, no optimization is done. |
coef.var |
Optional value for a fixed variance. If given, no optimization is done. |
nugget , nugget.estim , noise.var
|
Not implemented yet. |
estim.method |
Estimation criterion. |
penalty |
Not implemented yet. |
optim.method |
Optimization algorithm used in the
optimization of the objective given in
|
lower , upper
|
Not implemented yet. |
parinit |
Initial values for the correlation ranges which
will be optimized using |
multistart , control , gr , iso
|
Not implemented yet. |
scaling , knots , kernel
|
Not implemented yet. |
... |
Ignored. |
The class "KM"
extends the "km"
class of the
DiceKriging package, hence has all slots of "km"
. It
also has an extra slot "Kriging"
slot which contains a copy
of the original object.
A KM object. See Details.
Yann Richet [email protected]
km
in the DiceKriging
package for more details on the slots.
# a 16-points factorial design, and the corresponding response d <- 2; n <- 16 design.fact <- as.matrix(expand.grid(x1 = seq(0, 1, length = 4), x2 = seq(0, 1, length = 4))) y <- apply(design.fact, 1, DiceKriging::branin) # Using `km` from DiceKriging and a similar `KM` object # kriging model 1 : matern5_2 covariance structure, no trend, no nugget effect km1 <- DiceKriging::km(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- KM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1))
# a 16-points factorial design, and the corresponding response d <- 2; n <- 16 design.fact <- as.matrix(expand.grid(x1 = seq(0, 1, length = 4), x2 = seq(0, 1, length = 4))) y <- apply(design.fact, 1, DiceKriging::branin) # Using `km` from DiceKriging and a similar `KM` object # kriging model 1 : matern5_2 covariance structure, no trend, no nugget effect km1 <- DiceKriging::km(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- KM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1))
"km"
ClassThis class is intended to be used either by using its
own dedicated S4 methods or by using the S4 methods inherited
from the "km"
class of the libKriging package.
d,n,X,y,p,F
Number of (numeric) inputs, number of observations, design matrix, response vector, number of trend variables, trend matrix.
trend.formula,trend.coef
Formula used for the trend, vector
of estimated (or fixed)
trend coefficients with length
.
covariance
A S4 object with class "covTensorProduct"
representing a covariance kernel.
noise.flag,noise.var
Logical flag and numeric value for an optional noise term.
known.param
A character code indicating what parameters are known.
lower,upper
Bounds on the correlation range parameters.
method,penalty,optim.method,control,gr,parinit
Objects defining the estimation criterion, the optimization.
T,M,z
Auxiliary variables (matrices and vectors) that can be used in several computations.
case
The possible concentration (a.k.a. profiling) of the likelihood.
param.estim
Logical. Is an estimation used?
Kriging
A copy of the Kriging
object used to create
the current KM
object.
Yann Richet [email protected]
km-class
in the
DiceKriging package. The creator KM
.
"Kriging"
using
the libKriging library.The hyper-parameters (variance and vector of correlation ranges)
are estimated thanks to the optimization of a criterion given by
objective
, using the method given in optim
.
Kriging( y = NULL, X = NULL, kernel = NULL, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "Newton", "none"), objective = c("LL", "LOO", "LMP"), parameters = NULL )
Kriging( y = NULL, X = NULL, kernel = NULL, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "Newton", "none"), objective = c("LL", "LOO", "LMP"), parameters = NULL )
y |
Numeric vector of response values. |
X |
Numeric matrix of input design. |
kernel |
Character defining the covariance model:
|
regmodel |
Universal Kriging linear trend: |
normalize |
Logical. If |
optim |
Character giving the Optimization method used to fit
hyper-parameters. Possible values are: |
objective |
Character giving the objective function to
optimize. Possible values are: |
parameters |
Initial values for the hyper-parameters. When
provided this must be named list with elements |
An object with S3 class "Kriging"
. Should be used
with its predict
, simulate
, update
methods.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) ## fit and print k <- Kriging(y, X, kernel = "matern3_2") print(k) x <- as.matrix(seq(from = 0, to = 1, length.out = 101)) p <- predict(k, x = x, return_stdev = TRUE, return_cov = FALSE) plot(f) points(X, y) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) s <- simulate(k, nsim = 10, seed = 123, x = x) matlines(x, s, col = rgb(0, 0, 1, 0.2), type = "l", lty = 1)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) ## fit and print k <- Kriging(y, X, kernel = "matern3_2") print(k) x <- as.matrix(seq(from = 0, to = 1, length.out = 101)) p <- predict(k, x = x, return_stdev = TRUE, return_cov = FALSE) plot(f) points(X, y) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) s <- simulate(k, nsim = 10, seed = 123, x = x) matlines(x, s, col = rgb(0, 0, 1, 0.2), type = "l", lty = 1)
Compute the leave-One-Out error of a model given in object
.
leaveOneOut(object, ...)
leaveOneOut(object, ...)
object |
An object representing a fitted model. |
... |
Ignored. |
The Leave-One-Out sum of squares.
Get leaveOneOut of Kriging Model
## S3 method for class 'Kriging' leaveOneOut(object, ...)
## S3 method for class 'Kriging' leaveOneOut(object, ...)
object |
An S3 Kriging object. |
... |
Not used. |
The leaveOneOut computed for fitted
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LOO") print(k) leaveOneOut(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LOO") print(k) leaveOneOut(k)
Compute the leave-One-Out error of a model given in object
,
at a different value of the parameters.
leaveOneOutFun(object, ...)
leaveOneOutFun(object, ...)
object |
An object representing a fitted model. |
... |
Further arguments of function (eg. range). |
The Leave-One-Out sum of squares.
"Kriging"
representing a kriging model.The returned value is the sum of squares where
is the
prediction of
based on the the observations
with
.
## S3 method for class 'Kriging' leaveOneOutFun(object, theta, return_grad = FALSE, bench = FALSE, ...)
## S3 method for class 'Kriging' leaveOneOutFun(object, theta, return_grad = FALSE, bench = FALSE, ...)
object |
A |
theta |
A numeric vector of range parameters at which the LOO will be evaluated. |
return_grad |
Logical. Should the gradient (w.r.t. |
bench |
Logical. Should the function display benchmarking output |
... |
Not used. |
The leave-One-Out value computed for the given vector
of correlation ranges.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective = "LOO", optim="BFGS") print(k) loo <- function(theta) leaveOneOutFun(k, theta)$leaveOneOut t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, loo(t), type = "l") abline(v = k$theta(), col = "blue")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective = "LOO", optim="BFGS") print(k) loo <- function(theta) leaveOneOutFun(k, theta)$leaveOneOut t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, loo(t), type = "l") abline(v = k$theta(), col = "blue")
Compute the leave-One-Out vector error of a model given in object
,
at a different value of the parameters.
leaveOneOutVec(object, ...)
leaveOneOutVec(object, ...)
object |
An object representing a fitted model. |
... |
Further arguments of function (eg. range). |
The Leave-One-Out errors (mean and stdev) for each conditional point.
"Kriging"
representing a kriging model.The returned value is the mean and stdev of , the
prediction of
based on the the observations
with
.
## S3 method for class 'Kriging' leaveOneOutVec(object, theta, ...)
## S3 method for class 'Kriging' leaveOneOutVec(object, theta, ...)
object |
A |
theta |
A numeric vector of range parameters at which the LOO will be evaluated. |
... |
Not used. |
The leave-One-Out vector computed for the given vector
of correlation ranges.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(c(0.0, 0.25, 0.5, 0.75, 1.0)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2") print(k) x <- as.matrix(seq(0, 1, , 101)) p <- predict(k, x, TRUE, FALSE) plot(f) points(X, y) lines(x, p$mean, col = 'blue') polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) # Compute leave-one-out (no range re-estimate) on 2nd point X_no2 = X[-2,,drop=FALSE] y_no2 = f(X_no2) k_no2 = Kriging(y_no2, X_no2, "matern3_2", optim = "none", parameters = list(theta = k$theta())) print(k_no2) p_no2 <- predict(k_no2, x, TRUE, FALSE) lines(x, p_no2$mean, col = 'red') polygon(c(x, rev(x)), c(p_no2$mean - 2 * p_no2$stdev, rev(p_no2$mean + 2 * p_no2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2)) # Use leaveOneOutVec to get the same loov = k$leaveOneOutVec(matrix(k$theta())) points(X[2],loov$mean[2],col='red') lines(rep(X[2],2),loov$mean[2]+2*c(-loov$stdev[2],loov$stdev[2]),col='red')
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(c(0.0, 0.25, 0.5, 0.75, 1.0)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2") print(k) x <- as.matrix(seq(0, 1, , 101)) p <- predict(k, x, TRUE, FALSE) plot(f) points(X, y) lines(x, p$mean, col = 'blue') polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) # Compute leave-one-out (no range re-estimate) on 2nd point X_no2 = X[-2,,drop=FALSE] y_no2 = f(X_no2) k_no2 = Kriging(y_no2, X_no2, "matern3_2", optim = "none", parameters = list(theta = k$theta())) print(k_no2) p_no2 <- predict(k_no2, x, TRUE, FALSE) lines(x, p_no2$mean, col = 'red') polygon(c(x, rev(x)), c(p_no2$mean - 2 * p_no2$stdev, rev(p_no2$mean + 2 * p_no2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2)) # Use leaveOneOutVec to get the same loov = k$leaveOneOutVec(matrix(k$theta())) points(X[2],loov$mean[2],col='red') lines(rep(X[2],2),loov$mean[2]+2*c(-loov$stdev[2],loov$stdev[2]),col='red')
Load any Kriging Model from a file storage.
load(filename, ...)
load(filename, ...)
filename |
A file holding any Kriging object. |
... |
Not used. |
The loaded "*"Kriging object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) outfile = tempfile("k.json") save(k,outfile) print(load(outfile))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) outfile = tempfile("k.json") save(k,outfile) print(load(outfile))
Load a Kriging Model from a file storage
load.Kriging(filename, ...)
load.Kriging(filename, ...)
filename |
File name to load from. |
... |
Not used. |
The loaded Kriging object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) outfile = tempfile("k.json") save(k,outfile) print(load.Kriging(outfile))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) outfile = tempfile("k.json") save(k,outfile) print(load.Kriging(outfile))
Load a NoiseKriging Model from a file storage
load.NoiseKriging(filename, ...)
load.NoiseKriging(filename, ...)
filename |
File name to load from. |
... |
Not used. |
The loaded NoiseKriging object.
Yann Richet [email protected]
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile) print(load.NoiseKriging(outfile))
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile) print(load.NoiseKriging(outfile))
Load a NuggetKriging Model from a file storage
load.NuggetKriging(filename, ...)
load.NuggetKriging(filename, ...)
filename |
File name to load from. |
... |
Not used. |
The loaded NuggetKriging object.
Yann Richet [email protected]
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile) print(load.NuggetKriging(outfile))
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile) print(load.NuggetKriging(outfile))
Compute the log-Likelihood of a model given in object
.
logLikelihood(object, ...)
logLikelihood(object, ...)
object |
An object representing a fitted model. |
... |
Ignored. |
The log-likelihood.
Get Log-Likelihood of Kriging Model
## S3 method for class 'Kriging' logLikelihood(object, ...)
## S3 method for class 'Kriging' logLikelihood(object, ...)
object |
An S3 Kriging object. |
... |
Not used. |
The log-Likelihood computed for fitted
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LL") print(k) logLikelihood(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LL") print(k) logLikelihood(k)
Get logLikelihood of NoiseKriging Model
## S3 method for class 'NoiseKriging' logLikelihood(object, ...)
## S3 method for class 'NoiseKriging' logLikelihood(object, ...)
object |
An S3 NoiseKriging object. |
... |
Not used. |
The logLikelihood computed for fitted
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2", objective="LL") print(k) logLikelihood(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2", objective="LL") print(k) logLikelihood(k)
Get logLikelihood of NuggetKriging Model
## S3 method for class 'NuggetKriging' logLikelihood(object, ...)
## S3 method for class 'NuggetKriging' logLikelihood(object, ...)
object |
An S3 NuggetKriging object. |
... |
Not used. |
The logLikelihood computed for fitted
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2", objective="LL") print(k) logLikelihood(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2", objective="LL") print(k) logLikelihood(k)
Compute the log-Likelihood of a model given in object
,
at a different value of the parameters.
logLikelihoodFun(object, ...)
logLikelihoodFun(object, ...)
object |
An object representing a fitted model. |
... |
Further arguments of function (eg. range). |
The log-likelihood.
Compute Log-Likelihood of Kriging Model
## S3 method for class 'Kriging' logLikelihoodFun( object, theta, return_grad = FALSE, return_hess = FALSE, bench = FALSE, ... )
## S3 method for class 'Kriging' logLikelihoodFun( object, theta, return_grad = FALSE, return_hess = FALSE, bench = FALSE, ... )
object |
An S3 Kriging object. |
theta |
A numeric vector of (positive) range parameters at which the log-likelihood will be evaluated. |
return_grad |
Logical. Should the function return the gradient? |
return_hess |
Logical. Should the function return Hessian? |
bench |
Logical. Should the function display benchmarking output? |
... |
Not used. |
The log-Likelihood computed for given
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2") print(k) ll <- function(theta) logLikelihoodFun(k, theta)$logLikelihood t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, ll(t), type = 'l') abline(v = k$theta(), col = "blue")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2") print(k) ll <- function(theta) logLikelihoodFun(k, theta)$logLikelihood t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, ll(t), type = 'l') abline(v = k$theta(), col = "blue")
Compute Log-Likelihood of NoiseKriging Model
## S3 method for class 'NoiseKriging' logLikelihoodFun(object, theta_sigma2, return_grad = FALSE, bench = FALSE, ...)
## S3 method for class 'NoiseKriging' logLikelihoodFun(object, theta_sigma2, return_grad = FALSE, bench = FALSE, ...)
object |
An S3 NoiseKriging object. |
theta_sigma2 |
A numeric vector of (positive) range parameters and variance at which the log-likelihood will be evaluated. |
return_grad |
Logical. Should the function return the gradient? |
bench |
Logical. Should the function display benchmarking output |
... |
Not used. |
The log-Likelihood computed for given
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 *rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2") print(k) theta0 = k$theta() ll_sigma2 <- function(sigma2) logLikelihoodFun(k, cbind(theta0,sigma2))$logLikelihood s2 <- seq(from = 0.001, to = 1, length.out = 101) plot(s2, Vectorize(ll_sigma2)(s2), type = 'l') abline(v = k$sigma2(), col = "blue") sigma20 = k$sigma2() ll_theta <- function(theta) logLikelihoodFun(k, cbind(theta,sigma20))$logLikelihood t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, Vectorize(ll_theta)(t), type = 'l') abline(v = k$theta(), col = "blue") ll <- function(theta_sigma2) logLikelihoodFun(k, theta_sigma2)$logLikelihood s2 <- seq(from = 0.001, to = 1, length.out = 31) t <- seq(from = 0.001, to = 2, length.out = 31) contour(t,s2,matrix(ncol=length(s2),ll(expand.grid(t,s2))),xlab="theta",ylab="sigma2") points(k$theta(),k$sigma2(),col='blue')
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 *rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2") print(k) theta0 = k$theta() ll_sigma2 <- function(sigma2) logLikelihoodFun(k, cbind(theta0,sigma2))$logLikelihood s2 <- seq(from = 0.001, to = 1, length.out = 101) plot(s2, Vectorize(ll_sigma2)(s2), type = 'l') abline(v = k$sigma2(), col = "blue") sigma20 = k$sigma2() ll_theta <- function(theta) logLikelihoodFun(k, cbind(theta,sigma20))$logLikelihood t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, Vectorize(ll_theta)(t), type = 'l') abline(v = k$theta(), col = "blue") ll <- function(theta_sigma2) logLikelihoodFun(k, theta_sigma2)$logLikelihood s2 <- seq(from = 0.001, to = 1, length.out = 31) t <- seq(from = 0.001, to = 2, length.out = 31) contour(t,s2,matrix(ncol=length(s2),ll(expand.grid(t,s2))),xlab="theta",ylab="sigma2") points(k$theta(),k$sigma2(),col='blue')
Compute Log-Likelihood of NuggetKriging Model
## S3 method for class 'NuggetKriging' logLikelihoodFun(object, theta_alpha, return_grad = FALSE, bench = FALSE, ...)
## S3 method for class 'NuggetKriging' logLikelihoodFun(object, theta_alpha, return_grad = FALSE, bench = FALSE, ...)
object |
An S3 NuggetKriging object. |
theta_alpha |
A numeric vector of (positive) range parameters and variance over variance plus nugget at which the log-likelihood will be evaluated. |
return_grad |
Logical. Should the function return the gradient? |
bench |
Logical. Should the function display benchmarking output |
... |
Not used. |
The log-Likelihood computed for given
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2") print(k) theta0 = k$theta() ll_alpha <- function(alpha) logLikelihoodFun(k,cbind(theta0,alpha))$logLikelihood a <- seq(from = 0.9, to = 1.0, length.out = 101) plot(a, Vectorize(ll_alpha)(a), type = "l",xlim=c(0.9,1)) abline(v = k$sigma2()/(k$sigma2()+k$nugget()), col = "blue") alpha0 = k$sigma2()/(k$sigma2()+k$nugget()) ll_theta <- function(theta) logLikelihoodFun(k,cbind(theta,alpha0))$logLikelihood t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, Vectorize(ll_theta)(t), type = 'l') abline(v = k$theta(), col = "blue") ll <- function(theta_alpha) logLikelihoodFun(k,theta_alpha)$logLikelihood a <- seq(from = 0.9, to = 1.0, length.out = 31) t <- seq(from = 0.001, to = 2, length.out = 101) contour(t,a,matrix(ncol=length(a),ll(expand.grid(t,a))),xlab="theta",ylab="sigma2/(sigma2+nugget)") points(k$theta(),k$sigma2()/(k$sigma2()+k$nugget()),col='blue')
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2") print(k) theta0 = k$theta() ll_alpha <- function(alpha) logLikelihoodFun(k,cbind(theta0,alpha))$logLikelihood a <- seq(from = 0.9, to = 1.0, length.out = 101) plot(a, Vectorize(ll_alpha)(a), type = "l",xlim=c(0.9,1)) abline(v = k$sigma2()/(k$sigma2()+k$nugget()), col = "blue") alpha0 = k$sigma2()/(k$sigma2()+k$nugget()) ll_theta <- function(theta) logLikelihoodFun(k,cbind(theta,alpha0))$logLikelihood t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, Vectorize(ll_theta)(t), type = 'l') abline(v = k$theta(), col = "blue") ll <- function(theta_alpha) logLikelihoodFun(k,theta_alpha)$logLikelihood a <- seq(from = 0.9, to = 1.0, length.out = 31) t <- seq(from = 0.001, to = 2, length.out = 101) contour(t,a,matrix(ncol=length(a),ll(expand.grid(t,a))),xlab="theta",ylab="sigma2/(sigma2+nugget)") points(k$theta(),k$sigma2()/(k$sigma2()+k$nugget()),col='blue')
Compute the log-Marginal Posterior of a model given in
object
.
logMargPost(object, ...)
logMargPost(object, ...)
object |
An object representing a fitted model. |
... |
Ignored. |
The log-marginal posterior.
Get logMargPost of Kriging Model
## S3 method for class 'Kriging' logMargPost(object, ...)
## S3 method for class 'Kriging' logMargPost(object, ...)
object |
An S3 Kriging object. |
... |
Not used. |
The logMargPost computed for fitted
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) logMargPost(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) logMargPost(k)
Get logMargPost of NuggetKriging Model
## S3 method for class 'NuggetKriging' logMargPost(object, ...)
## S3 method for class 'NuggetKriging' logMargPost(object, ...)
object |
An S3 NuggetKriging object. |
... |
Not used. |
The logMargPost computed for fitted
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2", objective="LMP") print(k) logMargPost(k)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, kernel = "matern3_2", objective="LMP") print(k) logMargPost(k)
Compute the log-Marginal Posterior of a model given in
object
, at a different value of the parameters.
logMargPostFun(object, ...)
logMargPostFun(object, ...)
object |
An object representing a fitted model. |
... |
Further arguments of function (eg. range). |
The log-marginal posterior.
Compute the log-marginal posterior of a kriging model, using the prior XXXY.
## S3 method for class 'Kriging' logMargPostFun(object, theta, return_grad = FALSE, bench = FALSE, ...)
## S3 method for class 'Kriging' logMargPostFun(object, theta, return_grad = FALSE, bench = FALSE, ...)
object |
S3 Kriging object. |
theta |
Numeric vector of correlation range parameters at which the function is to be evaluated. |
return_grad |
Logical. Should the function return the gradient (w.r.t theta)? |
bench |
Logical. Should the function display benchmarking output? |
... |
Not used. |
The value of the log-marginal posterior computed for the given vector theta.
Yann Richet [email protected]
XXXY A reference describing the model (prior, ...)
rgasp
in the RobustGaSP package.
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, "matern3_2", objective="LMP") print(k) lmp <- function(theta) logMargPostFun(k, theta)$logMargPost t <- seq(from = 0.01, to = 2, length.out = 101) plot(t, lmp(t), type = "l") abline(v = k$theta(), col = "blue")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, "matern3_2", objective="LMP") print(k) lmp <- function(theta) logMargPostFun(k, theta)$logMargPost t <- seq(from = 0.01, to = 2, length.out = 101) plot(t, lmp(t), type = "l") abline(v = k$theta(), col = "blue")
Compute the log-marginal posterior of a kriging model, using the prior XXXY.
## S3 method for class 'NuggetKriging' logMargPostFun(object, theta_alpha, return_grad = FALSE, bench = FALSE, ...)
## S3 method for class 'NuggetKriging' logMargPostFun(object, theta_alpha, return_grad = FALSE, bench = FALSE, ...)
object |
S3 NuggetKriging object. |
theta_alpha |
Numeric vector of correlation range and variance over variance plus nugget parameters at which the function is to be evaluated. |
return_grad |
Logical. Should the function return the gradient (w.r.t theta_alpha)? |
bench |
Logical. Should the function display benchmarking output |
... |
Not used. |
The value of the log-marginal posterior computed for the
given vector .
Yann Richet [email protected]
XXXY A reference describing the model (prior, ...)
rgasp
in the RobustGaSP package.
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, "matern3_2", objective="LMP") print(k) theta0 = k$theta() lmp_alpha <- function(alpha) k$logMargPostFun(cbind(theta0,alpha))$logMargPost a <- seq(from = 0.9, to = 1.0, length.out = 101) plot(a, Vectorize(lmp_alpha)(a), type = "l",xlim=c(0.9,1)) abline(v = k$sigma2()/(k$sigma2()+k$nugget()), col = "blue") alpha0 = k$sigma2()/(k$sigma2()+k$nugget()) lmp_theta <- function(theta) k$logMargPostFun(cbind(theta,alpha0))$logMargPost t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, Vectorize(lmp_theta)(t), type = 'l') abline(v = k$theta(), col = "blue") lmp <- function(theta_alpha) k$logMargPostFun(theta_alpha)$logMargPost t <- seq(from = 0.4, to = 0.6, length.out = 51) a <- seq(from = 0.9, to = 1, length.out = 51) contour(t,a,matrix(ncol=length(t),lmp(expand.grid(t,a))), nlevels=50,xlab="theta",ylab="sigma2/(sigma2+nugget)") points(k$theta(),k$sigma2()/(k$sigma2()+k$nugget()),col='blue')
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, "matern3_2", objective="LMP") print(k) theta0 = k$theta() lmp_alpha <- function(alpha) k$logMargPostFun(cbind(theta0,alpha))$logMargPost a <- seq(from = 0.9, to = 1.0, length.out = 101) plot(a, Vectorize(lmp_alpha)(a), type = "l",xlim=c(0.9,1)) abline(v = k$sigma2()/(k$sigma2()+k$nugget()), col = "blue") alpha0 = k$sigma2()/(k$sigma2()+k$nugget()) lmp_theta <- function(theta) k$logMargPostFun(cbind(theta,alpha0))$logMargPost t <- seq(from = 0.001, to = 2, length.out = 101) plot(t, Vectorize(lmp_theta)(t), type = 'l') abline(v = k$theta(), col = "blue") lmp <- function(theta_alpha) k$logMargPostFun(theta_alpha)$logMargPost t <- seq(from = 0.4, to = 0.6, length.out = 51) a <- seq(from = 0.9, to = 1, length.out = 51) contour(t,a,matrix(ncol=length(t),lmp(expand.grid(t,a))), nlevels=50,xlab="theta",ylab="sigma2/(sigma2+nugget)") points(k$theta(),k$sigma2()/(k$sigma2()+k$nugget()),col='blue')
NoiseKM
ObjectCreate an object of S4 class "NoiseKM"
similar to a
km
object in the DiceKriging package.
NoiseKM( formula = ~1, design, response, covtype = c("matern5_2", "gauss", "matern3_2", "exp"), coef.trend = NULL, coef.cov = NULL, coef.var = NULL, nugget = NULL, nugget.estim = FALSE, noise.var, estim.method = c("MLE", "LOO"), penalty = NULL, optim.method = "BFGS", lower = NULL, upper = NULL, parinit = NULL, multistart = 1, control = NULL, gr = TRUE, iso = FALSE, scaling = FALSE, knots = NULL, kernel = NULL, ... )
NoiseKM( formula = ~1, design, response, covtype = c("matern5_2", "gauss", "matern3_2", "exp"), coef.trend = NULL, coef.cov = NULL, coef.var = NULL, nugget = NULL, nugget.estim = FALSE, noise.var, estim.method = c("MLE", "LOO"), penalty = NULL, optim.method = "BFGS", lower = NULL, upper = NULL, parinit = NULL, multistart = 1, control = NULL, gr = TRUE, iso = FALSE, scaling = FALSE, knots = NULL, kernel = NULL, ... )
formula |
R formula object to setup the linear trend in
Universal NoiseKriging. Supports |
design |
Data frame. The design of experiments. |
response |
Vector of output values. |
covtype |
Covariance structure. For now all the kernels are tensor product kernels. |
coef.trend |
Optional value for a fixed vector of trend coefficients. If given, no optimization is done. |
coef.cov |
Optional value for a fixed correlation range value. If given, no optimization is done. |
coef.var |
Optional value for a fixed variance. If given, no optimization is done. |
nugget , nugget.estim
|
Not implemented. |
noise.var |
Vector of output values variance. |
estim.method |
Estimation criterion. |
penalty |
Not implemented yet. |
optim.method |
Optimization algorithm used in the
optimization of the objective given in
|
lower , upper
|
Not implemented yet. |
parinit |
Initial values for the correlation ranges which
will be optimized using |
multistart , control , gr , iso
|
Not implemented yet. |
scaling , knots , kernel
|
Not implemented yet. |
... |
Ignored. |
The class "NoiseKM"
extends the "km"
class of the
DiceKriging package, hence has all slots of "km"
. It
also has an extra slot "NoiseKriging"
slot which contains a copy
of the original object.
A NoiseKM object. See Details.
Yann Richet [email protected]
km
in the DiceKriging
package for more details on the slots.
# a 16-points factorial design, and the corresponding response d <- 2; n <- 16 design.fact <- as.matrix(expand.grid(x1 = seq(0, 1, length = 4), x2 = seq(0, 1, length = 4))) y <- apply(design.fact, 1, DiceKriging::branin) + rnorm(nrow(design.fact)) # Using `km` from DiceKriging and a similar `NoiseKM` object # kriging model 1 : matern5_2 covariance structure, no trend, no nugget effect km1 <- DiceKriging::km(design = design.fact, response = y, covtype = "gauss", noise.var=rep(1,nrow(design.fact)), parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NoiseKM(design = design.fact, response = y, covtype = "gauss", noise=rep(1,nrow(design.fact)), parinit = c(.5, 1))
# a 16-points factorial design, and the corresponding response d <- 2; n <- 16 design.fact <- as.matrix(expand.grid(x1 = seq(0, 1, length = 4), x2 = seq(0, 1, length = 4))) y <- apply(design.fact, 1, DiceKriging::branin) + rnorm(nrow(design.fact)) # Using `km` from DiceKriging and a similar `NoiseKM` object # kriging model 1 : matern5_2 covariance structure, no trend, no nugget effect km1 <- DiceKriging::km(design = design.fact, response = y, covtype = "gauss", noise.var=rep(1,nrow(design.fact)), parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NoiseKM(design = design.fact, response = y, covtype = "gauss", noise=rep(1,nrow(design.fact)), parinit = c(.5, 1))
"km"
ClassThis class is intended to be used either by using its
own dedicated S4 methods or by using the S4 methods inherited
from the "km"
class of the libKriging package.
d,n,X,y,p,F
Number of (numeric) inputs, number of observations, design matrix, response vector, number of trend variables, trend matrix.
trend.formula,trend.coef
Formula used for the trend, vector
of estimated (or fixed)
trend coefficients with length
.
covariance
A S4 object with class "covTensorProduct"
representing a covariance kernel.
noise.flag,noise.var
Logical flag and numeric value for an optional noise term.
known.param
A character code indicating what parameters are known.
lower,upper
Bounds on the correlation range parameters.
method,penalty,optim.method,control,gr,parinit
Objects defining the estimation criterion, the optimization.
T,M,z
Auxiliary variables (matrices and vectors) that can be used in several computations.
case
The possible concentration (a.k.a. profiling) of the likelihood.
param.estim
Logical. Is an estimation used?
NoiseKriging
A copy of the NoiseKriging
object used to create
the current NoiseKM
object.
Yann Richet [email protected]
km-class
in the
DiceKriging package. The creator NoiseKM
.
"NoiseKriging"
using
the libKriging library.The hyper-parameters (variance and vector of correlation ranges)
are estimated thanks to the optimization of a criterion given by
objective
, using the method given in optim
.
NoiseKriging( y = NULL, noise = NULL, X = NULL, kernel = NULL, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL"), parameters = NULL )
NoiseKriging( y = NULL, noise = NULL, X = NULL, kernel = NULL, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL"), parameters = NULL )
y |
Numeric vector of response values. |
noise |
Numeric vector of response variances. |
X |
Numeric matrix of input design. |
kernel |
Character defining the covariance model:
|
regmodel |
Universal NoiseKriging
|
normalize |
Logical. If |
optim |
Character giving the Optimization method used to fit
hyper-parameters. Possible values are: |
objective |
Character giving the objective function to
optimize. Possible values are: |
parameters |
Initial values for the hyper-parameters. When
provided this must be named list with elements |
An object with S3 class "NoiseKriging"
. Should be used
with its predict
, simulate
, update
methods.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X ## fit and print k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") print(k) x <- as.matrix(seq(from = 0, to = 1, length.out = 101)) p <- predict(k,x = x, return_stdev = TRUE, return_cov = FALSE) plot(f) points(X, y) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) s <- simulate(k, nsim = 10, seed = 123, x = x) matlines(x, s, col = rgb(0, 0, 1, 0.2), type = "l", lty = 1)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X ## fit and print k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") print(k) x <- as.matrix(seq(from = 0, to = 1, length.out = 101)) p <- predict(k,x = x, return_stdev = TRUE, return_cov = FALSE) plot(f) points(X, y) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) s <- simulate(k, nsim = 10, seed = 123, x = x) matlines(x, s, col = rgb(0, 0, 1, 0.2), type = "l", lty = 1)
NuggetKM
ObjectCreate an object of S4 class "NuggetKM"
similar to a
km
object in the DiceKriging package.
NuggetKM( formula = ~1, design, response, covtype = c("matern5_2", "gauss", "matern3_2", "exp"), coef.trend = NULL, coef.cov = NULL, coef.var = NULL, nugget = NULL, nugget.estim = TRUE, noise.var = NULL, estim.method = c("MLE", "LOO"), penalty = NULL, optim.method = "BFGS", lower = NULL, upper = NULL, parinit = NULL, multistart = 1, control = NULL, gr = TRUE, iso = FALSE, scaling = FALSE, knots = NULL, kernel = NULL, ... )
NuggetKM( formula = ~1, design, response, covtype = c("matern5_2", "gauss", "matern3_2", "exp"), coef.trend = NULL, coef.cov = NULL, coef.var = NULL, nugget = NULL, nugget.estim = TRUE, noise.var = NULL, estim.method = c("MLE", "LOO"), penalty = NULL, optim.method = "BFGS", lower = NULL, upper = NULL, parinit = NULL, multistart = 1, control = NULL, gr = TRUE, iso = FALSE, scaling = FALSE, knots = NULL, kernel = NULL, ... )
formula |
R formula object to setup the linear trend in
Universal NuggetKriging. Supports |
design |
Data frame. The design of experiments. |
response |
Vector of output values. |
covtype |
Covariance structure. For now all the kernels are tensor product kernels. |
coef.trend |
Optional value for a fixed vector of trend coefficients. If given, no optimization is done. |
coef.cov |
Optional value for a fixed correlation range value. If given, no optimization is done. |
coef.var |
Optional value for a fixed variance. If given, no optimization is done. |
nugget.estim , nugget
|
Should nugget be estimated? (defaults TRUE) or given values. |
noise.var |
Not implemented. |
estim.method |
Estimation criterion. |
penalty |
Not implemented yet. |
optim.method |
Optimization algorithm used in the
optimization of the objective given in
|
lower , upper
|
Not implemented yet. |
parinit |
Initial values for the correlation ranges which
will be optimized using |
multistart , control , gr , iso
|
Not implemented yet. |
scaling , knots , kernel
|
Not implemented yet. |
... |
Ignored. |
The class "NuggetKM"
extends the "km"
class of the
DiceKriging package, hence has all slots of "km"
. It
also has an extra slot "NuggetKriging"
slot which contains a copy
of the original object.
A NuggetKM object. See Details.
Yann Richet [email protected]
km
in the DiceKriging
package for more details on the slots.
# a 16-points factorial design, and the corresponding response d <- 2; n <- 16 design.fact <- as.matrix(expand.grid(x1 = seq(0, 1, length = 4), x2 = seq(0, 1, length = 4))) y <- apply(design.fact, 1, DiceKriging::branin) + rnorm(nrow(design.fact)) # Using `km` from DiceKriging and a similar `NuggetKM` object # kriging model 1 : matern5_2 covariance structure, no trend, no nugget effect km1 <- DiceKriging::km(design = design.fact, response = y, covtype = "gauss", nugget.estim=TRUE, parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NuggetKM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1))
# a 16-points factorial design, and the corresponding response d <- 2; n <- 16 design.fact <- as.matrix(expand.grid(x1 = seq(0, 1, length = 4), x2 = seq(0, 1, length = 4))) y <- apply(design.fact, 1, DiceKriging::branin) + rnorm(nrow(design.fact)) # Using `km` from DiceKriging and a similar `NuggetKM` object # kriging model 1 : matern5_2 covariance structure, no trend, no nugget effect km1 <- DiceKriging::km(design = design.fact, response = y, covtype = "gauss", nugget.estim=TRUE, parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NuggetKM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1))
"km"
ClassThis class is intended to be used either by using its
own dedicated S4 methods or by using the S4 methods inherited
from the "km"
class of the libKriging package.
d,n,X,y,p,F
Number of (numeric) inputs, number of observations, design matrix, response vector, number of trend variables, trend matrix.
trend.formula,trend.coef
Formula used for the trend, vector
of estimated (or fixed)
trend coefficients with length
.
covariance
A S4 object with class "covTensorProduct"
representing a covariance kernel.
noise.flag,noise.var
Logical flag and numeric value for an optional noise term.
known.param
A character code indicating what parameters are known.
lower,upper
Bounds on the correlation range parameters.
method,penalty,optim.method,control,gr,parinit
Objects defining the estimation criterion, the optimization.
T,M,z
Auxiliary variables (matrices and vectors) that can be used in several computations.
case
The possible concentration (a.k.a. profiling) of the likelihood.
param.estim
Logical. Is an estimation used?
NuggetKriging
A copy of the NuggetKriging
object used to create
the current NuggetKM
object.
Yann Richet [email protected]
km-class
in the
DiceKriging package. The creator NuggetKM
.
"NuggetKriging"
using
the libKriging library.The hyper-parameters (variance and vector of correlation ranges)
are estimated thanks to the optimization of a criterion given by
objective
, using the method given in optim
.
NuggetKriging( y = NULL, X = NULL, kernel = NULL, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL", "LMP"), parameters = NULL )
NuggetKriging( y = NULL, X = NULL, kernel = NULL, regmodel = c("constant", "linear", "interactive", "none"), normalize = FALSE, optim = c("BFGS", "none"), objective = c("LL", "LMP"), parameters = NULL )
y |
Numeric vector of response values. |
X |
Numeric matrix of input design. |
kernel |
Character defining the covariance model:
|
regmodel |
Universal NuggetKriging
|
normalize |
Logical. If |
optim |
Character giving the Optimization method used to fit
hyper-parameters. Possible values are: |
objective |
Character giving the objective function to
optimize. Possible values are: |
parameters |
Initial values for the hyper-parameters. When provided this
must be named list with some elements |
An object with S3 class "NuggetKriging"
. Should be used
with its predict
, simulate
, update
methods.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) ## fit and print k <- NuggetKriging(y, X, kernel = "matern3_2") print(k) x <- sort(c(X,as.matrix(seq(from = 0, to = 1, length.out = 101)))) p <- predict(k, x = x, return_stdev = TRUE, return_cov = FALSE) plot(f) points(X, y) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) s <- simulate(k, nsim = 10, seed = 123, x = x) matlines(x, s, col = rgb(0, 0, 1, 0.2), type = "l", lty = 1)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) ## fit and print k <- NuggetKriging(y, X, kernel = "matern3_2") print(k) x <- sort(c(X,as.matrix(seq(from = 0, to = 1, length.out = 101)))) p <- predict(k, x = x, return_stdev = TRUE, return_cov = FALSE) plot(f) points(X, y) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) s <- simulate(k, nsim = 10, seed = 123, x = x) matlines(x, s, col = rgb(0, 0, 1, 0.2), type = "l", lty = 1)
KM
ObjectCompute predictions for the response at new given input points. These conditional mean, the conditional standard deviation and confidence limits at the 95% level. Optionnally the conditional covariance can be returned as well.
## S4 method for signature 'KM' predict( object, newdata, type = "UK", se.compute = TRUE, cov.compute = FALSE, light.return = TRUE, bias.correct = FALSE, checkNames = FALSE, ... )
## S4 method for signature 'KM' predict( object, newdata, type = "UK", se.compute = TRUE, cov.compute = FALSE, light.return = TRUE, bias.correct = FALSE, checkNames = FALSE, ... )
object |
|
newdata |
Matrix of "new" input points where to perform prediction. |
type |
character giving the kriging type. For now only
|
se.compute |
Logical. Should the standard error be computed? |
cov.compute |
Logical. Should the covariance matrix between newdata points be computed? |
light.return |
Logical. If |
bias.correct |
Logical. If |
checkNames |
Logical to check the consistency of the column
names between the design stored in |
... |
Ignored. |
Without a dedicated predict
method for the class
"KM"
, this method would have been inherited from the
"km"
class. The dedicated method is expected to run faster.
A comparison can be made by coercing a KM
object to a
km
object with as.km
before calling
predict
.
A named list. The elements are the conditional mean and
standard deviation (mean
and sd
), the predicted
trend (trend
) and the confidence limits (lower95
and upper95
). Optionnally, the conditional covariance matrix
is returned in cov
.
Yann Richet [email protected]
## 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, DiceKriging::branin) ## library(DiceKriging) ## kriging model 1 : matern5_2 covariance structure, no trend, no nugget ## m1 <- km(design = design.fact, response = y, covtype = "gauss", ## parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- KM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1)) Pred <- predict(KM1, newdata = matrix(.5,ncol = 2), type = "UK", checkNames = FALSE, light.return = TRUE)
## 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, DiceKriging::branin) ## library(DiceKriging) ## kriging model 1 : matern5_2 covariance structure, no trend, no nugget ## m1 <- km(design = design.fact, response = y, covtype = "gauss", ## parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- KM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1)) Pred <- predict(KM1, newdata = matrix(.5,ncol = 2), type = "UK", checkNames = FALSE, light.return = TRUE)
NoiseKM
ObjectCompute predictions for the response at new given input points. These conditional mean, the conditional standard deviation and confidence limits at the 95% level. Optionnally the conditional covariance can be returned as well.
## S4 method for signature 'NoiseKM' predict( object, newdata, type = "UK", se.compute = TRUE, cov.compute = FALSE, light.return = TRUE, bias.correct = FALSE, checkNames = FALSE, ... )
## S4 method for signature 'NoiseKM' predict( object, newdata, type = "UK", se.compute = TRUE, cov.compute = FALSE, light.return = TRUE, bias.correct = FALSE, checkNames = FALSE, ... )
object |
|
newdata |
Matrix of "new" input points where to perform prediction. |
type |
character giving the kriging type. For now only
|
se.compute |
Logical. Should the standard error be computed? |
cov.compute |
Logical. Should the covariance matrix between newdata points be computed? |
light.return |
Logical. If |
bias.correct |
Logical. If |
checkNames |
Logical to check the consistency of the column
names between the design stored in |
... |
Ignored. |
Without a dedicated predict
method for the class
"NoiseKM"
, this method would have been inherited from the
"km"
class. The dedicated method is expected to run faster.
A comparison can be made by coercing a NoiseKM
object to a
km
object with as.km
before calling
predict
.
A named list. The elements are the conditional mean and
standard deviation (mean
and sd
), the predicted
trend (trend
) and the confidence limits (lower95
and upper95
). Optionnally, the conditional covariance matrix
is returned in cov
.
Yann Richet [email protected]
## 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, DiceKriging::branin) + rnorm(nrow(design.fact)) ## library(DiceKriging) ## kriging model 1 : matern5_2 covariance structure, no trend, no nugget ## m1 <- km(design = design.fact, response = y, covtype = "gauss", ## noise.var=rep(1,nrow(design.fact)), ## parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NoiseKM(design = design.fact, response = y, covtype = "gauss", noise=rep(1,nrow(design.fact)), parinit = c(.5, 1)) Pred <- predict(KM1, newdata = matrix(.5,ncol = 2), type = "UK", checkNames = FALSE, light.return = TRUE)
## 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, DiceKriging::branin) + rnorm(nrow(design.fact)) ## library(DiceKriging) ## kriging model 1 : matern5_2 covariance structure, no trend, no nugget ## m1 <- km(design = design.fact, response = y, covtype = "gauss", ## noise.var=rep(1,nrow(design.fact)), ## parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NoiseKM(design = design.fact, response = y, covtype = "gauss", noise=rep(1,nrow(design.fact)), parinit = c(.5, 1)) Pred <- predict(KM1, newdata = matrix(.5,ncol = 2), type = "UK", checkNames = FALSE, light.return = TRUE)
NuggetKM
ObjectCompute predictions for the response at new given input points. These conditional mean, the conditional standard deviation and confidence limits at the 95% level. Optionnally the conditional covariance can be returned as well.
## S4 method for signature 'NuggetKM' predict( object, newdata, type = "UK", se.compute = TRUE, cov.compute = FALSE, light.return = TRUE, bias.correct = FALSE, checkNames = FALSE, ... )
## S4 method for signature 'NuggetKM' predict( object, newdata, type = "UK", se.compute = TRUE, cov.compute = FALSE, light.return = TRUE, bias.correct = FALSE, checkNames = FALSE, ... )
object |
|
newdata |
Matrix of "new" input points where to perform prediction. |
type |
character giving the kriging type. For now only
|
se.compute |
Logical. Should the standard error be computed? |
cov.compute |
Logical. Should the covariance matrix between newdata points be computed? |
light.return |
Logical. If |
bias.correct |
Logical. If |
checkNames |
Logical to check the consistency of the column
names between the design stored in |
... |
Ignored. |
Without a dedicated predict
method for the class
"NuggetKM"
, this method would have been inherited from the
"km"
class. The dedicated method is expected to run faster.
A comparison can be made by coercing a NuggetKM
object to a
km
object with as.km
before calling
predict
.
A named list. The elements are the conditional mean and
standard deviation (mean
and sd
), the predicted
trend (trend
) and the confidence limits (lower95
and upper95
). Optionnally, the conditional covariance matrix
is returned in cov
.
Yann Richet [email protected]
## 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, DiceKriging::branin) + rnorm(nrow(design.fact)) ## library(DiceKriging) ## kriging model 1 : matern5_2 covariance structure, no trend, no nugget ## m1 <- km(design = design.fact, response = y, covtype = "gauss", ## nugget.estim=TRUE, ## parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NuggetKM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1)) Pred <- predict(KM1, newdata = matrix(.5,ncol = 2), type = "UK", checkNames = FALSE, light.return = TRUE)
## 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, DiceKriging::branin) + rnorm(nrow(design.fact)) ## library(DiceKriging) ## kriging model 1 : matern5_2 covariance structure, no trend, no nugget ## m1 <- km(design = design.fact, response = y, covtype = "gauss", ## nugget.estim=TRUE, ## parinit = c(.5, 1), control = list(trace = FALSE)) KM1 <- NuggetKM(design = design.fact, response = y, covtype = "gauss", parinit = c(.5, 1)) Pred <- predict(KM1, newdata = matrix(.5,ncol = 2), type = "UK", checkNames = FALSE, light.return = TRUE)
Kriging
object.Given "new" input points, the method compute the expectation, variance and (optionnally) the covariance of the corresponding stochastic process, conditional on the values at the input points used when fitting the model.
## S3 method for class 'Kriging' predict( object, x, return_stdev = TRUE, return_cov = FALSE, return_deriv = FALSE, ... )
## S3 method for class 'Kriging' predict( object, x, return_stdev = TRUE, return_cov = FALSE, return_deriv = FALSE, ... )
object |
S3 Kriging object. |
x |
Input points where the prediction must be computed. |
return_stdev |
|
return_cov |
|
return_deriv |
|
... |
Ignored. |
A list containing the element mean
and possibly
stdev
and cov
.
The names of the formal arguments differ from those of the
predict
methods for the S4 classes "km"
and
"KM"
. The formal x
corresponds to
newdata
, stdev
corresponds to se.compute
and cov
to cov.compute
. These names are chosen
Python and Octave interfaces to libKriging.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue", pch = 16) k <- Kriging(y, X, "matern3_2") x <-seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue", pch = 16) k <- Kriging(y, X, "matern3_2") x <-seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2))
NoiseKriging
object.Given "new" input points, the method compute the expectation, variance and (optionnally) the covariance of the corresponding stochastic process, conditional on the values at the input points used when fitting the model.
## S3 method for class 'NoiseKriging' predict( object, x, return_stdev = TRUE, return_cov = FALSE, return_deriv = FALSE, ... )
## S3 method for class 'NoiseKriging' predict( object, x, return_stdev = TRUE, return_cov = FALSE, return_deriv = FALSE, ... )
object |
S3 NoiseKriging object. |
x |
Input points where the prediction must be computed. |
return_stdev |
|
return_cov |
|
return_deriv |
|
... |
Ignored. |
A list containing the element mean
and possibly
stdev
and cov
.
The names of the formal arguments differ from those of the
predict
methods for the S4 classes "km"
and
"KM"
. The formal x
corresponds to
newdata
, stdev
corresponds to se.compute
and cov
to cov.compute
. These names are chosen
Python and Octave interfaces to libKriging.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue", pch = 16) k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x <-seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue", pch = 16) k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x <-seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2))
NuggetKriging
object.Given "new" input points, the method compute the expectation, variance and (optionnally) the covariance of the corresponding stochastic process, conditional on the values at the input points used when fitting the model.
## S3 method for class 'NuggetKriging' predict( object, x, return_stdev = TRUE, return_cov = FALSE, return_deriv = FALSE, ... )
## S3 method for class 'NuggetKriging' predict( object, x, return_stdev = TRUE, return_cov = FALSE, return_deriv = FALSE, ... )
object |
S3 NuggetKriging object. |
x |
Input points where the prediction must be computed. |
return_stdev |
|
return_cov |
|
return_deriv |
|
... |
Ignored. |
A list containing the element mean
and possibly
stdev
and cov
.
The names of the formal arguments differ from those of the
predict
methods for the S4 classes "km"
and
"KM"
. The formal x
corresponds to
newdata
, stdev
corresponds to se.compute
and cov
to cov.compute
. These names are chosen
Python and Octave interfaces to libKriging.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue", pch = 16) k <- NuggetKriging(y, X, "matern3_2") ## include design points to see interpolation x <- sort(c(X,seq(from = 0, to = 1, length.out = 101))) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2))
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue", pch = 16) k <- NuggetKriging(y, X, "matern3_2") ## include design points to see interpolation x <- sort(c(X,seq(from = 0, to = 1, length.out = 101))) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2))
Kriging
object.Print the content of a Kriging
object.
## S3 method for class 'Kriging' print(x, ...)
## S3 method for class 'Kriging' print(x, ...)
x |
A (S3) |
... |
Ignored. |
String of printed object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, "matern3_2") print(k) ## same thing k
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, "matern3_2") print(k) ## same thing k
NoiseKriging
object.Print the content of a NoiseKriging
object.
## S3 method for class 'NoiseKriging' print(x, ...)
## S3 method for class 'NoiseKriging' print(x, ...)
x |
A (S3) |
... |
Ignored. |
String of printed object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") print(k) ## same thing k
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) # add noise dep. on X k <- NoiseKriging(y, noise=(X/10)^2, X, kernel = "matern3_2") print(k) ## same thing k
NuggetKriging
object.Print the content of a NuggetKriging
object.
## S3 method for class 'NuggetKriging' print(x, ...)
## S3 method for class 'NuggetKriging' print(x, ...)
x |
A (S3) |
... |
Ignored. |
String of printed object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, "matern3_2") print(k) ## same thing k
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) k <- NuggetKriging(y, X, "matern3_2") print(k) ## same thing k
Save a model given in
object
.
save(object, ...)
save(object, ...)
object |
An object representing a fitted model. |
... |
Ignored. |
The saved object.
Save a Kriging Model to a file storage
## S3 method for class 'Kriging' save(object, filename, ...)
## S3 method for class 'Kriging' save(object, filename, ...)
object |
An S3 Kriging object. |
filename |
File name to save in. |
... |
Not used. |
The loaded Kriging object.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) outfile = tempfile("k.json") save(k,outfile)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) k <- Kriging(y, X, kernel = "matern3_2", objective="LMP") print(k) outfile = tempfile("k.json") save(k,outfile)
Save a NoiseKriging Model to a file storage
## S3 method for class 'NoiseKriging' save(object, filename, ...)
## S3 method for class 'NoiseKriging' save(object, filename, ...)
object |
An S3 NoiseKriging object. |
filename |
File name to save in. |
... |
Not used. |
The loaded NoiseKriging object.
Yann Richet [email protected]
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile)
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile)
Save a NuggetKriging Model to a file storage
## S3 method for class 'NuggetKriging' save(object, filename, ...)
## S3 method for class 'NuggetKriging' save(object, filename, ...)
object |
An S3 NuggetKriging object. |
filename |
File name to save in. |
... |
Not used. |
The loaded NuggetKriging object.
Yann Richet [email protected]
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile)
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") print(k) outfile = tempfile("k.json") save(k,outfile)
KM
ObjectThe simulate
method is used to simulate paths from the
kriging model described in object
.
## S4 method for signature 'KM' simulate( object, nsim = 1, seed = NULL, newdata, cond = TRUE, nugget.sim = 0, checkNames = FALSE, ... )
## S4 method for signature 'KM' simulate( object, nsim = 1, seed = NULL, newdata, cond = TRUE, nugget.sim = 0, checkNames = FALSE, ... )
object |
A |
nsim |
Integer: number of response vectors to simulate. |
seed |
Random seed. |
newdata |
Numeric matrix with it rows giving the points where the simulation is to be performed. |
cond |
Logical telling wether the simulation is conditional
or not. Only |
nugget.sim |
Numeric. A postive nugget effect used to avoid numerical instability. |
checkNames |
Check consistency between the design data
|
... |
Ignored. |
Without a dedicated simulate
method for the class
"KM"
, this method would have been inherited from the
"km"
class. The dedicated method is expected to run faster.
A comparison can be made by coercing a KM
object to a
km
object with as.km
before calling
simulate
.
A numeric matrix with nrow(newdata)
rows and
nsim
columns containing as its columns the simulated
paths at the input points given in newdata
.
XXX method simulate KM
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) points(X, y, col = 'blue') k <- KM(design = X, response = y, covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) s_x <- simulate(k, nsim = 3, newdata = x) lines(x, s_x[ , 1], col = 'blue') lines(x, s_x[ , 2], col = 'blue') lines(x, s_x[ , 3], col = 'blue')
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) points(X, y, col = 'blue') k <- KM(design = X, response = y, covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) s_x <- simulate(k, nsim = 3, newdata = x) lines(x, s_x[ , 1], col = 'blue') lines(x, s_x[ , 2], col = 'blue') lines(x, s_x[ , 3], col = 'blue')
NoiseKM
ObjectThe simulate
method is used to simulate paths from the
kriging model described in object
.
## S4 method for signature 'NoiseKM' simulate( object, nsim = 1, seed = NULL, newdata, cond = TRUE, nugget.sim = 0, checkNames = FALSE, ... )
## S4 method for signature 'NoiseKM' simulate( object, nsim = 1, seed = NULL, newdata, cond = TRUE, nugget.sim = 0, checkNames = FALSE, ... )
object |
A |
nsim |
Integer: number of response vectors to simulate. |
seed |
Random seed. |
newdata |
Numeric matrix with it rows giving the points where the simulation is to be performed. |
cond |
Logical telling wether the simulation is conditional
or not. Only |
nugget.sim |
Numeric. A postive nugget effect used to avoid numerical instability. |
checkNames |
Check consistency between the design data
|
... |
Ignored. |
Without a dedicated simulate
method for the class
"NoiseKM"
, this method would have been inherited from the
"km"
class. The dedicated method is expected to run faster.
A comparison can be made by coercing a NoiseKM
object to a
km
object with as.km
before calling
simulate
.
A numeric matrix with nrow(newdata)
rows and
nsim
columns containing as its columns the simulated
paths at the input points given in newdata
.
XXX method simulate NoiseKM
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = 'blue') k <- NoiseKM(design = X, response = y, covtype = "gauss", noise=rep(0.01^2,nrow(X))) x <- seq(from = 0, to = 1, length.out = 101) s_x <- simulate(k, nsim = 3, newdata = x) lines(x, s_x[ , 1], col = 'blue') lines(x, s_x[ , 2], col = 'blue') lines(x, s_x[ , 3], col = 'blue')
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = 'blue') k <- NoiseKM(design = X, response = y, covtype = "gauss", noise=rep(0.01^2,nrow(X))) x <- seq(from = 0, to = 1, length.out = 101) s_x <- simulate(k, nsim = 3, newdata = x) lines(x, s_x[ , 1], col = 'blue') lines(x, s_x[ , 2], col = 'blue') lines(x, s_x[ , 3], col = 'blue')
NuggetKM
ObjectThe simulate
method is used to simulate paths from the
kriging model described in object
.
## S4 method for signature 'NuggetKM' simulate( object, nsim = 1, seed = NULL, newdata, cond = TRUE, nugget.sim = 0, checkNames = FALSE, ... )
## S4 method for signature 'NuggetKM' simulate( object, nsim = 1, seed = NULL, newdata, cond = TRUE, nugget.sim = 0, checkNames = FALSE, ... )
object |
A |
nsim |
Integer: number of response vectors to simulate. |
seed |
Random seed. |
newdata |
Numeric matrix with it rows giving the points where the simulation is to be performed. |
cond |
Logical telling wether the simulation is conditional
or not. Only |
nugget.sim |
Numeric. A postive nugget effect used to avoid numerical instability. |
checkNames |
Check consistency between the design data
|
... |
Ignored. |
Without a dedicated simulate
method for the class
"NuggetKM"
, this method would have been inherited from the
"km"
class. The dedicated method is expected to run faster.
A comparison can be made by coercing a NuggetKM
object to a
km
object with as.km
before calling
simulate
.
A numeric matrix with nrow(newdata)
rows and
nsim
columns containing as its columns the simulated
paths at the input points given in newdata
.
XXX method simulate NuggetKM
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = 'blue') k <- NuggetKM(design = X, response = y, covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) s_x <- simulate(k, nsim = 3, newdata = x) lines(x, s_x[ , 1], col = 'blue') lines(x, s_x[ , 2], col = 'blue') lines(x, s_x[ , 3], col = 'blue')
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = 'blue') k <- NuggetKM(design = X, response = y, covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) s_x <- simulate(k, nsim = 3, newdata = x) lines(x, s_x[ , 1], col = 'blue') lines(x, s_x[ , 2], col = 'blue') lines(x, s_x[ , 3], col = 'blue')
Kriging
model object.This method draws paths of the stochastic process at new input points conditional on the values at the input points used in the fit.
## S3 method for class 'Kriging' simulate(object, nsim = 1, seed = 123, x, will_update = FALSE, ...)
## S3 method for class 'Kriging' simulate(object, nsim = 1, seed = 123, x, will_update = FALSE, ...)
object |
S3 Kriging object. |
nsim |
Number of simulations to perform. |
seed |
Random seed used. |
x |
Points in model input space where to simulate. |
will_update |
Set to TRUE if wish to use update_simulate(...) later. |
... |
Ignored. |
a matrix with nrow(x)
rows and nsim
columns containing the simulated paths at the inputs points
given in x
.
The names of the formal arguments differ from those of the
simulate
methods for the S4 classes "km"
and
"KM"
. The formal x
corresponds to
newdata
. These names are chosen Python and
Octave interfaces to libKriging.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue") k <- Kriging(y, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- simulate(k, nsim = 3, x = x) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue") k <- Kriging(y, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- simulate(k, nsim = 3, x = x) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue")
NoiseKriging
model object.This method draws paths of the stochastic process at new input points conditional on the values at the input points used in the fit.
## S3 method for class 'NoiseKriging' simulate( object, nsim = 1, seed = 123, x, with_noise = NULL, will_update = FALSE, ... )
## S3 method for class 'NoiseKriging' simulate( object, nsim = 1, seed = 123, x, with_noise = NULL, will_update = FALSE, ... )
object |
S3 NoiseKriging object. |
nsim |
Number of simulations to perform. |
seed |
Random seed used. |
x |
Points in model input space where to simulate. |
with_noise |
Set to array of values if wish to add the noise in the simulation. |
will_update |
Set to TRUE if wish to use update_simulate(...) later. |
... |
Ignored. |
a matrix with nrow(x)
rows and nsim
columns containing the simulated paths at the inputs points
given in x
.
The names of the formal arguments differ from those of the
simulate
methods for the S4 classes "km"
and
"KM"
. The formal x
corresponds to
newdata
. These names are chosen Python and
Octave interfaces to libKriging.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- simulate(k, nsim = 3, x = x) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- simulate(k, nsim = 3, x = x) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue")
NuggetKriging
model object.This method draws paths of the stochastic process at new input points conditional on the values at the input points used in the fit.
## S3 method for class 'NuggetKriging' simulate( object, nsim = 1, seed = 123, x, with_nugget = TRUE, will_update = FALSE, ... )
## S3 method for class 'NuggetKriging' simulate( object, nsim = 1, seed = 123, x, with_nugget = TRUE, will_update = FALSE, ... )
object |
S3 NuggetKriging object. |
nsim |
Number of simulations to perform. |
seed |
Random seed used. |
x |
Points in model input space where to simulate. |
with_nugget |
Set to FALSE if wish to remove the nugget in the simulation. |
will_update |
Set to TRUE if wish to use update_simulate(...) later. |
... |
Ignored. |
a matrix with nrow(x)
rows and nsim
columns containing the simulated paths at the inputs points
given in x
.
The names of the formal arguments differ from those of the
simulate
methods for the S4 classes "km"
and
"KM"
. The formal x
corresponds to
newdata
. These names are chosen Python and
Octave interfaces to libKriging.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 *rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- simulate(k, nsim = 3, x = x) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 *rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- simulate(k, nsim = 3, x = x) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue")
Update previous simulate of a model given in
object
.
update_simulate(object, ...)
update_simulate(object, ...)
object |
An object representing a fitted model. |
... |
Further arguments of function |
Updated simulation of model output.
Kriging
model object.This method draws paths of the stochastic process conditional on the values at the input points used in the fit, plus the new input points and their values given as argument (knonw as 'update' points).
## S3 method for class 'Kriging' update_simulate(object, y_u, X_u, ...)
## S3 method for class 'Kriging' update_simulate(object, y_u, X_u, ...)
object |
S3 Kriging object. |
y_u |
Numeric vector of new responses (output). |
X_u |
Numeric matrix of new input points. |
... |
Ignored. |
a matrix with nrow(x)
rows and nsim
columns containing the simulated paths at the inputs points
given in x
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue") k <- Kriging(y, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- k$simulate(nsim = 3, x = x, will_update = TRUE) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue") X_u <- as.matrix(runif(3)) y_u <- f(X_u) points(X_u, y_u, col = "red") su <- k$update_simulate(y_u, X_u) lines(x, su[ , 1], col = "blue", lty=2) lines(x, su[ , 2], col = "blue", lty=2) lines(x, su[ , 3], col = "blue", lty=2)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue") k <- Kriging(y, X, kernel = "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- k$simulate(nsim = 3, x = x, will_update = TRUE) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue") X_u <- as.matrix(runif(3)) y_u <- f(X_u) points(X_u, y_u, col = "red") su <- k$update_simulate(y_u, X_u) lines(x, su[ , 1], col = "blue", lty=2) lines(x, su[ , 2], col = "blue", lty=2) lines(x, su[ , 3], col = "blue", lty=2)
NoiseKriging
model object.This method draws paths of the stochastic process conditional on the values at the input points used in the fit, plus the new input points and their values given as argument (knonw as 'update' points).
## S3 method for class 'NoiseKriging' update_simulate(object, y_u, noise_u, X_u, ...)
## S3 method for class 'NoiseKriging' update_simulate(object, y_u, noise_u, X_u, ...)
object |
S3 NoiseKriging object. |
y_u |
Numeric vector of new responses (output). |
noise_u |
Numeric vector of new noise variances (output). |
X_u |
Numeric matrix of new input points. |
... |
Ignored. |
a matrix with nrow(x)
rows and nsim
columns containing the simulated paths at the inputs points
given in x
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- k$simulate(nsim = 3, x = x, will_update = TRUE) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue") X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") su <- k$update_simulate(y_u, rep(0.1^2,3), X_u) lines(x, su[ , 1], col = "blue", lty=2) lines(x, su[ , 2], col = "blue", lty=2) lines(x, su[ , 3], col = "blue", lty=2)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- k$simulate(nsim = 3, x = x, will_update = TRUE) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue") X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") su <- k$update_simulate(y_u, rep(0.1^2,3), X_u) lines(x, su[ , 1], col = "blue", lty=2) lines(x, su[ , 2], col = "blue", lty=2) lines(x, su[ , 3], col = "blue", lty=2)
NuggetKriging
model object.This method draws paths of the stochastic process conditional on the values at the input points used in the fit, plus the new input points and their values given as argument (knonw as 'update' points).
## S3 method for class 'NuggetKriging' update_simulate(object, y_u, X_u, ...)
## S3 method for class 'NuggetKriging' update_simulate(object, y_u, X_u, ...)
object |
S3 NuggetKriging object. |
y_u |
Numeric vector of new responses (output). |
X_u |
Numeric matrix of new input points. |
... |
Ignored. |
a matrix with nrow(x)
rows and nsim
columns containing the simulated paths at the inputs points
given in x
.
Yann Richet [email protected]
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- k$simulate(nsim = 3, x = x, will_update = TRUE) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue") X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") su <- k$update_simulate(y_u, X_u) lines(x, su[ , 1], col = "blue", lty=2) lines(x, su[ , 2], col = "blue", lty=2) lines(x, su[ , 3], col = "blue", lty=2)
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) s <- k$simulate(nsim = 3, x = x, will_update = TRUE) lines(x, s[ , 1], col = "blue") lines(x, s[ , 2], col = "blue") lines(x, s[ , 3], col = "blue") X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") su <- k$update_simulate(y_u, X_u) lines(x, su[ , 1], col = "blue", lty=2) lines(x, su[ , 2], col = "blue", lty=2) lines(x, su[ , 3], col = "blue", lty=2)
KM
Object with New PointsThe update
method is used when new observations are added
to a fitted kriging model. Rather than fitting the model from
scratch with the updated observations added, the results of the
fit as stored in object
are used to achieve some savings.
## S4 method for signature 'KM' update( object, newX, newy, newX.alreadyExist = FALSE, cov.reestim = TRUE, trend.reestim = cov.reestim, nugget.reestim = FALSE, newnoise.var = NULL, kmcontrol = NULL, newF = NULL, ... )
## S4 method for signature 'KM' update( object, newX, newy, newX.alreadyExist = FALSE, cov.reestim = TRUE, trend.reestim = cov.reestim, nugget.reestim = FALSE, newnoise.var = NULL, kmcontrol = NULL, newF = NULL, ... )
object |
A KM object. |
newX |
A numeric matrix containing the new design points. It
must have |
newy |
A numeric vector of new response values, in
correspondence with the rows of |
newX.alreadyExist |
Logical. If TRUE, |
cov.reestim |
Logical. If |
trend.reestim |
Logical. If |
nugget.reestim |
Logical. If |
newnoise.var |
Optional variance of an additional noise on the new response. |
kmcontrol |
A list of options to tune the fit. Not available yet. |
newF |
New trend matrix. XXXY? |
... |
Ignored. |
Without a dedicated update
method for the class
"KM"
, this would have been inherited from the class
"km"
. The dedicated method is expected to run faster. A
comparison can be made by coercing a KM
object to a
km
object with as.km
before calling
update
.
The updated KM
object.
Yann Richet [email protected]
as.km
to coerce a KM
object to the
class "km"
.
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) points(X, y, col = "blue") KMobj <- KM(design = X, response = y,covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) p_x <- predict(KMobj, x) lines(x, p_x$mean, col = "blue") lines(x, p_x$lower95, col = "blue") lines(x, p_x$upper95, col = "blue") newX <- as.matrix(runif(3)) newy <- f(newX) points(newX, newy, col = "red") ## replace the object by its udated version KMobj <- update(KMobj, newX=newX, newy=newy) x <- seq(from = 0, to = 1, length.out = 101) p2_x <- predict(KMobj, x) lines(x, p2_x$mean, col = "red") lines(x, p2_x$lower95, col = "red") lines(x, p2_x$upper95, col = "red")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) points(X, y, col = "blue") KMobj <- KM(design = X, response = y,covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) p_x <- predict(KMobj, x) lines(x, p_x$mean, col = "blue") lines(x, p_x$lower95, col = "blue") lines(x, p_x$upper95, col = "blue") newX <- as.matrix(runif(3)) newy <- f(newX) points(newX, newy, col = "red") ## replace the object by its udated version KMobj <- update(KMobj, newX=newX, newy=newy) x <- seq(from = 0, to = 1, length.out = 101) p2_x <- predict(KMobj, x) lines(x, p2_x$mean, col = "red") lines(x, p2_x$lower95, col = "red") lines(x, p2_x$upper95, col = "red")
NoiseKM
Object with New PointsThe update
method is used when new observations are added
to a fitted kriging model. Rather than fitting the model from
scratch with the updated observations added, the results of the
fit as stored in object
are used to achieve some savings.
## S4 method for signature 'NoiseKM' update( object, newX, newy, newnoise.var, newX.alreadyExist = FALSE, cov.reestim = TRUE, trend.reestim = cov.reestim, nugget.reestim = FALSE, kmcontrol = NULL, newF = NULL, ... )
## S4 method for signature 'NoiseKM' update( object, newX, newy, newnoise.var, newX.alreadyExist = FALSE, cov.reestim = TRUE, trend.reestim = cov.reestim, nugget.reestim = FALSE, kmcontrol = NULL, newF = NULL, ... )
object |
A NoiseKM object. |
newX |
A numeric matrix containing the new design points. It
must have |
newy |
A numeric vector of new response values, in
correspondence with the rows of |
newnoise.var |
Variance of an additional noise on the new response. |
newX.alreadyExist |
Logical. If TRUE, |
cov.reestim |
Logical. If |
trend.reestim |
Logical. If |
nugget.reestim |
Logical. If |
kmcontrol |
A list of options to tune the fit. Not available yet. |
newF |
New trend matrix. XXXY? |
... |
Ignored. |
Without a dedicated update
method for the class
"NoiseKM"
, this would have been inherited from the class
"km"
. The dedicated method is expected to run faster. A
comparison can be made by coercing a NoiseKM
object to a
km
object with as.km
before calling
update
.
The updated NoiseKM
object.
Yann Richet [email protected]
as.km
to coerce a NoiseKM
object to the
class "km"
.
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = "blue") KMobj <- NoiseKM(design = X, response = y, noise=rep(0.01^2,5), covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) p_x <- predict(KMobj, x) lines(x, p_x$mean, col = "blue") lines(x, p_x$lower95, col = "blue") lines(x, p_x$upper95, col = "blue") newX <- as.matrix(runif(3)) newy <- f(newX) + 0.01*rnorm(nrow(newX)) points(newX, newy, col = "red") ## replace the object by its udated version KMobj <- update(KMobj, newX=newX, newy=newy, newnoise.var=rep(0.01^2,3)) x <- seq(from = 0, to = 1, length.out = 101) p2_x <- predict(KMobj, x) lines(x, p2_x$mean, col = "red") lines(x, p2_x$lower95, col = "red") lines(x, p2_x$upper95, col = "red")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = "blue") KMobj <- NoiseKM(design = X, response = y, noise=rep(0.01^2,5), covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) p_x <- predict(KMobj, x) lines(x, p_x$mean, col = "blue") lines(x, p_x$lower95, col = "blue") lines(x, p_x$upper95, col = "blue") newX <- as.matrix(runif(3)) newy <- f(newX) + 0.01*rnorm(nrow(newX)) points(newX, newy, col = "red") ## replace the object by its udated version KMobj <- update(KMobj, newX=newX, newy=newy, newnoise.var=rep(0.01^2,3)) x <- seq(from = 0, to = 1, length.out = 101) p2_x <- predict(KMobj, x) lines(x, p2_x$mean, col = "red") lines(x, p2_x$lower95, col = "red") lines(x, p2_x$upper95, col = "red")
NuggetKM
Object with New PointsThe update
method is used when new observations are added
to a fitted kriging model. Rather than fitting the model from
scratch with the updated observations added, the results of the
fit as stored in object
are used to achieve some savings.
## S4 method for signature 'NuggetKM' update( object, newX, newy, newX.alreadyExist = FALSE, cov.reestim = TRUE, trend.reestim = cov.reestim, nugget.reestim = FALSE, newnoise.var = NULL, kmcontrol = NULL, newF = NULL, ... )
## S4 method for signature 'NuggetKM' update( object, newX, newy, newX.alreadyExist = FALSE, cov.reestim = TRUE, trend.reestim = cov.reestim, nugget.reestim = FALSE, newnoise.var = NULL, kmcontrol = NULL, newF = NULL, ... )
object |
A NuggetKM object. |
newX |
A numeric matrix containing the new design points. It
must have |
newy |
A numeric vector of new response values, in
correspondence with the rows of |
newX.alreadyExist |
Logical. If TRUE, |
cov.reestim |
Logical. If |
trend.reestim |
Logical. If |
nugget.reestim |
Logical. If |
newnoise.var |
Optional variance of an additional noise on the new response. |
kmcontrol |
A list of options to tune the fit. Not available yet. |
newF |
New trend matrix. XXXY? |
... |
Ignored. |
Without a dedicated update
method for the class
"NuggetKM"
, this would have been inherited from the class
"km"
. The dedicated method is expected to run faster. A
comparison can be made by coercing a NuggetKM
object to a
km
object with as.km
before calling
update
.
The updated NuggetKM
object.
Yann Richet [email protected]
as.km
to coerce a NuggetKM
object to the
class "km"
.
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = "blue") KMobj <- NuggetKM(design = X, response = y,covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) p_x <- predict(KMobj, x) lines(x, p_x$mean, col = "blue") lines(x, p_x$lower95, col = "blue") lines(x, p_x$upper95, col = "blue") newX <- as.matrix(runif(3)) newy <- f(newX) + 0.01*rnorm(nrow(newX)) points(newX, newy, col = "red") ## replace the object by its udated version KMobj <- update(KMobj, newX=newX, newy=newy) x <- seq(from = 0, to = 1, length.out = 101) p2_x <- predict(KMobj, x) lines(x, p2_x$mean, col = "red") lines(x, p2_x$lower95, col = "red") lines(x, p2_x$upper95, col = "red")
f <- function(x) 1 - 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x) * x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(5)) y <- f(X) + 0.01*rnorm(nrow(X)) points(X, y, col = "blue") KMobj <- NuggetKM(design = X, response = y,covtype = "gauss") x <- seq(from = 0, to = 1, length.out = 101) p_x <- predict(KMobj, x) lines(x, p_x$mean, col = "blue") lines(x, p_x$lower95, col = "blue") lines(x, p_x$upper95, col = "blue") newX <- as.matrix(runif(3)) newy <- f(newX) + 0.01*rnorm(nrow(newX)) points(newX, newy, col = "red") ## replace the object by its udated version KMobj <- update(KMobj, newX=newX, newy=newy) x <- seq(from = 0, to = 1, length.out = 101) p2_x <- predict(KMobj, x) lines(x, p2_x$mean, col = "red") lines(x, p2_x$lower95, col = "red") lines(x, p2_x$upper95, col = "red")
Kriging
model object with new pointsUpdate a Kriging
model object with new points
## S3 method for class 'Kriging' update(object, y_u, X_u, refit = TRUE, ...)
## S3 method for class 'Kriging' update(object, y_u, X_u, refit = TRUE, ...)
object |
S3 Kriging object. |
y_u |
Numeric vector of new responses (output). |
X_u |
Numeric matrix of new input points. |
refit |
Logical. If |
... |
Ignored. |
No return value. Kriging object argument is modified.
The method does not return the updated
object, but instead changes the content of
object
. This behaviour is quite unusual in R and
differs from the behaviour of the methods
update.km
in DiceKriging and
update,KM-method
.
Yann Richet [email protected]
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue") k <- Kriging(y, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) X_u <- as.matrix(runif(3)) y_u <- f(X_u) points(X_u, y_u, col = "red") ## change the content of the object 'k' update(k, y_u, X_u) ## include design points to see interpolation x <- sort(c(X,X_u,seq(from = 0, to = 1, length.out = 101))) p2 <- predict(k, x) lines(x, p2$mean, col = "red") polygon(c(x, rev(x)), c(p2$mean - 2 * p2$stdev, rev(p2$mean + 2 * p2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2))
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) points(X, y, col = "blue") k <- Kriging(y, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) X_u <- as.matrix(runif(3)) y_u <- f(X_u) points(X_u, y_u, col = "red") ## change the content of the object 'k' update(k, y_u, X_u) ## include design points to see interpolation x <- sort(c(X,X_u,seq(from = 0, to = 1, length.out = 101))) p2 <- predict(k, x) lines(x, p2$mean, col = "red") polygon(c(x, rev(x)), c(p2$mean - 2 * p2$stdev, rev(p2$mean + 2 * p2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2))
NoiseKriging
model object with new pointsUpdate a NoiseKriging
model object with new points
## S3 method for class 'NoiseKriging' update(object, y_u, noise_u, X_u, refit = TRUE, ...)
## S3 method for class 'NoiseKriging' update(object, y_u, noise_u, X_u, refit = TRUE, ...)
object |
S3 NoiseKriging object. |
y_u |
Numeric vector of new responses (output). |
noise_u |
Numeric vector of new noise variances (output). |
X_u |
Numeric matrix of new input points. |
refit |
Logical. If |
... |
Ignored. |
No return value. NoiseKriging object argument is modified.
The method does not return the updated
object, but instead changes the content of
object
. This behaviour is quite unusual in R and
differs from the behaviour of the methods
update.km
in DiceKriging and
update,KM-method
.
Yann Richet [email protected]
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") ## change the content of the object 'k' update(k, y_u, rep(0.1^2,3), X_u) ## include design points to see interpolation x <- sort(c(X,X_u,seq(from = 0, to = 1, length.out = 101))) p2 <- predict(k, x) lines(x, p2$mean, col = "red") polygon(c(x, rev(x)), c(p2$mean - 2 * p2$stdev, rev(p2$mean + 2 * p2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2))
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + X/10 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NoiseKriging(y, (X/10)^2, X, "matern3_2") x <- seq(from = 0, to = 1, length.out = 101) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") ## change the content of the object 'k' update(k, y_u, rep(0.1^2,3), X_u) ## include design points to see interpolation x <- sort(c(X,X_u,seq(from = 0, to = 1, length.out = 101))) p2 <- predict(k, x) lines(x, p2$mean, col = "red") polygon(c(x, rev(x)), c(p2$mean - 2 * p2$stdev, rev(p2$mean + 2 * p2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2))
NuggetKriging
model object with new pointsUpdate a NuggetKriging
model object with new points
## S3 method for class 'NuggetKriging' update(object, y_u, X_u, refit = TRUE, ...)
## S3 method for class 'NuggetKriging' update(object, y_u, X_u, refit = TRUE, ...)
object |
S3 NuggetKriging object. |
y_u |
Numeric vector of new responses (output). |
X_u |
Numeric matrix of new input points. |
refit |
Logical. If |
... |
Ignored. |
No return value. NuggetKriging object argument is modified.
The method does not return the updated
object, but instead changes the content of
object
. This behaviour is quite unusual in R and
differs from the behaviour of the methods
update.km
in DiceKriging and
update,KM-method
.
Yann Richet [email protected]
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") ## include design points to see interpolation x <- sort(c(X,seq(from = 0, to = 1, length.out = 101))) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") ## change the content of the object 'k' update(k, y_u, X_u) ## include design points to see interpolation x <- sort(c(X,X_u,seq(from = 0, to = 1, length.out = 101))) p2 <- predict(k, x) lines(x, p2$mean, col = "red") polygon(c(x, rev(x)), c(p2$mean - 2 * p2$stdev, rev(p2$mean + 2 * p2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2))
f <- function(x) 1- 1 / 2 * (sin(12 * x) / (1 + x) + 2 * cos(7 * x)*x^5 + 0.7) plot(f) set.seed(123) X <- as.matrix(runif(10)) y <- f(X) + 0.1 * rnorm(nrow(X)) points(X, y, col = "blue") k <- NuggetKriging(y, X, "matern3_2") ## include design points to see interpolation x <- sort(c(X,seq(from = 0, to = 1, length.out = 101))) p <- predict(k, x) lines(x, p$mean, col = "blue") polygon(c(x, rev(x)), c(p$mean - 2 * p$stdev, rev(p$mean + 2 * p$stdev)), border = NA, col = rgb(0, 0, 1, 0.2)) X_u <- as.matrix(runif(3)) y_u <- f(X_u) + 0.1 * rnorm(nrow(X_u)) points(X_u, y_u, col = "red") ## change the content of the object 'k' update(k, y_u, X_u) ## include design points to see interpolation x <- sort(c(X,X_u,seq(from = 0, to = 1, length.out = 101))) p2 <- predict(k, x) lines(x, p2$mean, col = "red") polygon(c(x, rev(x)), c(p2$mean - 2 * p2$stdev, rev(p2$mean + 2 * p2$stdev)), border = NA, col = rgb(1, 0, 0, 0.2))