GaSPModel {GaSP} | R Documentation |
Create a GaSPModel
object.
Description
Return a template for a GaSPModel
object.
Usage
GaSPModel(
x,
y,
reg_model,
sp_model = NULL,
cor_family = c("PowerExponential", "Matern"),
cor_par,
random_error = c(FALSE, TRUE),
sp_var,
error_var = 0
)
Arguments
x |
A data frame containing the input (explanatory variable) training data. |
y |
A vector or a data frame with one column containing the output (response) training data. |
reg_model |
The regression model, specified as a formula, but note the left-hand side of the formula is unused; see example. |
sp_model |
An optional stochastic process model, specified as a formula,
but note the left-hand side of the formula and the intercept are unused.
The default |
cor_family |
A character string specifying the (product, anisoptropic) correlation-function family: "PowerExponential" for the power-exponential family or "Matern" for the Matern family. |
cor_par |
A data frame containing the correlation parameters
with one row per |
random_error |
A boolean for the presence or not of a random (measurement, white-noise) error term. |
sp_var |
The stochastic process variance. |
error_var |
The random error variance, with default 0. |
Details
The data frame cor_par
contains one row for each term
in the stochastic process model.
There are two columns. The first is named Theta
,
and the second is either Alpha
(power-exponential)
or Derivatives
(Matern).
Let h_j
be a distance between points for term j
in the stochastic-process model.
For power-exponential, the contribution to the product correlation
from term j
depends on
a distance-scale parameter \theta_j
from the Theta
column and
a smoothness parameter \alpha_j
from the Alpha
column;
the contribution is exp(-\theta_j h_j^{2 - \alpha_j})
.
For example, \alpha_j = 0
gives the squared-exponential (Gaussian) correlation.
The contribution to the product correlation for Matern also depends on \theta_j
,
and the second parameter is the number of derivatives \delta_j = 0, 1, 2, 3
from the Derivatives
column.
The contribution is
exp(-\theta_j h_j)
for \delta_j = 0
(the exponential correlation),
exp(-\theta_j h_j) (\theta_j h_j + 1)
for \delta_j = 1
,
exp(-\theta_j h_j) ((\theta_j h_j)^2 / 3 + \theta_j h_j + 1)
for \delta_j = 2
, and
exp(-\theta_j h_j^2)
for \delta_j = 3
(the squared-exponential correlation).
Note that \delta_j = 3
codes for a limiting infinite number of derivatives.
This is not the usual parameterization of the Matern, but it is
consistent with power-exponential for the exponential and squared-exponential
special cases common to both.
A value should be given to error_var
if the model
has a random-error term (random_error = TRUE
),
and a small "nugget" such as 10^{-9}
may be needed for improved
numerical conditioning.
Value
A GaSPModel
object, which is a list with the following components:
x |
The data frame containing the input training data. |
y |
The training output data, now as a vector. |
reg_model |
The regression model, now in the form of a data frame. |
sp_model |
The stochastic process model, now in the form of a data frame. |
cor_family |
The correlation family. |
cor_par |
The data frame containing the correlation parameters. |
random_error |
The boolean for the presence or not of a random error term. |
sp_var |
The stochastic process variance. |
error_var |
The random error variance. |
beta |
A placeholder for a data frame to hold the regression-model parameters. |
objective |
A placeholder for the maximum fit objective. |
cond_num |
A placeholder for the condition number. |
CVRMSE |
A placeholder for the model's cross-validated root mean squared error. |
Note
This function does not excecute Fit
and is intended
for CrossValidate
, Predict
and Visualize
with models trained otherwise by the user.
Placeholders do not need to be specified to excecute these further functions,
as they are always recomputed as needed.
References
Sacks, J., Welch, W.J., Mitchell, T.J., and Wynn, H.P. (1989) "Design and Analysis of Computer Experiments", Statistical Science, 4, pp. 409-423, doi:10.1214/ss/1177012413.
Examples
x <- borehole$x
y <- borehole$y
theta <- c(
5.767699e+01, 0.000000e+00, 0.000000e+00, 1.433571e-06,
0.000000e+00, 2.366557e-06, 1.695619e-07, 2.454376e-09
)
alpha <- c(
1.110223e-16, 0.000000e+00, 0.000000e+00, 0.000000e+00,
0.000000e+00, 0.000000e+00, 2.494862e-03, 0.000000e+00
)
cor_par <- data.frame(Theta = theta, Alpha = alpha)
rownames(cor_par) <- colnames(borehole$x)
sp_var <- 38783.7
borehole_gasp <- GaSPModel(
x = borehole$x, y = borehole$y,
reg_model = ~1, cor_family = "PowerExponential",
cor_par = cor_par, random_error = FALSE,
sp_var = sp_var
)