Learn R Programming

RNAmf (version 1.0.1)

RNAmf_three_level: Fitting the model with three fidelity levels

Description

The function fits RNA models with designs of three fidelity levels. The estimation method is based on MLE. Possible kernel choices are squared exponential, Matern kernel with smoothness parameter 1.5 and 2.5. The function returns fitted model by RNAmf_two_level, fitted model at level 3, whether constant mean or not, and kernel choice.

Usage

RNAmf_three_level(X1, y1, X2, y2, X3, y3, kernel = "sqex", constant = TRUE, ...)

Value

  • fit.RNAmf_two_level: a class RNAmf object fitted by RNAmf_two_level. It contains a list of \(\begin{cases} & \text{\code{fit1} for } (X_1, y_1),\\ & \text{\code{fit2} for } ((X_2, f_1(X_2)), y_2), \end{cases}\). See RNAmf_two_level.

  • fit3: list of fitted model for \(((X_2, f_2(X_3, f_1(X_3))), y_3)\).

  • constant: copy of constant.

  • kernel: copy of kernel.

  • level: a level of the fidelity. It returns 3.

  • time: a scalar of the time for the computation.

Arguments

X1

vector or matrix of input locations for the low fidelity level.

y1

vector of response values for the low fidelity level.

X2

vector or matrix of input locations for the medium fidelity level.

y2

vector of response values for the medium fidelity level.

X3

vector or matrix of input locations for the high fidelity level.

y3

vector of response values for the high fidelity level.

kernel

character specifying kernel type to be used, to be chosen between "sqex"(squared exponential), "matern1.5", or "matern2.5". Default is "sqex".

constant

logical indicating for constant mean of GP (constant=TRUE) or zero mean (constant=FALSE). Default is TRUE.

...

for compatibility with optim.

Details

Consider the model \(\begin{cases} & f_1(\bm{x}) = W_1(\bm{x}),\\ & f_l(\bm{x}) = W_l(\bm{x}, f_{l-1}(\bm{x})) \quad\text{for}\quad l=2,3, \end{cases}\) where \(f_l\) is the simulation code at fidelity level \(l\), and \(W_l(\bm{x}) \sim GP(\alpha_l, \tau_l^2 K_l(\bm{x}, \bm{x}'))\) is GP model. Hyperparameters \((\alpha_l, \tau_l^2, \bm{\theta_l})\) are estimated by maximizing the log-likelihood via an optimization algorithm "L-BFGS-B". For constant=FALSE, \(\alpha_l=0\).

Covariance kernel is defined as: \(K_l(\bm{x}, \bm{x}')=\prod^d_{j=1}\phi(x_j,x'_j;\theta_{lj})\) with \(\phi(x, x';\theta) = \exp \left( -\frac{ \left( x - x' \right)^2}{\theta} \right)\) for squared exponential kernel; kernel="sqex", \(\phi(x,x';\theta) =\left( 1+\frac{\sqrt{3}|x- x'|}{\theta} \right) \exp \left( -\frac{\sqrt{3}|x- x'|}{\theta} \right)\) for Matern kernel with the smoothness parameter of 1.5; kernel="matern1.5" and \(\phi(x, x';\theta) = \left( 1+\frac{\sqrt{5}|x-x'|}{\theta} +\frac{5(x-x')^2}{3\theta^2} \right) \exp \left( -\frac{\sqrt{5}|x-x'|}{\theta} \right)\) for Matern kernel with the smoothness parameter of 2.5; kernel="matern2.5".

For details, see Heo and Sung (2024, <tools:::Rd_expr_doi("https://doi.org/10.1080/00401706.2024.2376173")>).

See Also

predict.RNAmf for prediction.

Examples

Run this code
# \donttest{
### three levels example ###
library(lhs)

### Branin function ###
branin <- function(xx, l){
  x1 <- xx[1]
  x2 <- xx[2]
  if(l == 1){
    10*sqrt((-1.275*(1.2*x1+0.4)^2/pi^2+5*(1.2*x1+0.4)/pi+(1.2*x2+0.4)-6)^2 +
    (10-5/(4*pi))*cos((1.2*x1+0.4))+ 10) + 2*(1.2*x1+1.9) - 3*(3*(1.2*x2+2.4)-1) - 1 - 3*x2 + 1
  }else if(l == 2){
    10*sqrt((-1.275*(x1+2)^2/pi^2+5*(x1+2)/pi+(x2+2)-6)^2 +
    (10-5/(4*pi))*cos((x1+2))+ 10) + 2*(x1-0.5) - 3*(3*x2-1) - 1
  }else if(l == 3){
    (-1.275*x1^2/pi^2+5*x1/pi+x2-6)^2 + (10-5/(4*pi))*cos(x1)+ 10
  }
}

output.branin <- function(x, l){
  factor_range <- list("x1" = c(-5, 10), "x2" = c(0, 15))

  for(i in 1:length(factor_range)) x[i] <- factor_range[[i]][1] + x[i] * diff(factor_range[[i]])
  branin(x[1:2], l)
}

### training data ###
n1 <- 20; n2 <- 15; n3 <- 10

### fix seed to reproduce the result ###
set.seed(1)

### generate initial nested design ###
X <- NestedX(c(n1, n2, n3), 2)
X1 <- X[[1]]
X2 <- X[[2]]
X3 <- X[[3]]

### n1, n2 and n3 might be changed from NestedX ###
### assign n1, n2 and n3 again ###
n1 <- nrow(X1)
n2 <- nrow(X2)
n3 <- nrow(X3)

y1 <- apply(X1,1,output.branin, l=1)
y2 <- apply(X2,1,output.branin, l=2)
y3 <- apply(X3,1,output.branin, l=3)

### fit an RNAmf ###
fit.RNAmf <- RNAmf_three_level(X1, y1, X2, y2, X3, y3, kernel = "sqex")
# }


Run the code above in your browser using DataLab