#' @title Make Object of Class \code{CCConfig}
#'
#' @description A \code{CCConfig} object contains the configurations for building
#' a \code{CCKriging} model, i.e., the methods and (fixed) parameters to be used.
#'
#' @param cat.type [\code{character(1)}]\cr
#' Which method should be used for the categorical inputs?
#' Possible choices:\cr
#' \tabular{ll}{
#' \dQuote{EC}: \tab Exchangeable Correlation (DEFAULT)\cr
#' \dQuote{MC}: \tab Multiplicative Correlation\cr
#' \dQuote{UC}: \tab Hypersphere Decomposition-Based Unrestrictive Correlation\cr
#' \dQuote{TMC}: \tab Toeplitz Matrix Multiplication-based Correlation\cr
#' \dQuote{GMC}: \tab General Matrix Multiplication-based Correlation
#' }
#' @param cat.interaction [\code{logical(1)}]\cr
#' Should interactions between categorical inputs be considered? Default is \code{TRUE}.
#' Note that for some methods and many level combinations of the categorical inputs,
#' this can lead to extraordinary high computational effort. See details.
#' @param cont.type [\code{character(1)}]\cr
#' Which correlation function should be used for the continuous inputs?
#' Possible choices:\cr
#' \dQuote{matern} : Matern correlation function (DEFAULT)
#' @param cont.par [\code{named list}]\cr
#' A named list of one or more fixed parameters of the correlation function. For the
#' Matern correlation function, this would be \dQuote{nu}, which defaults to \code{2.5}.
#' See the details for a list of parameters of different correlation functions.
#' @param info [\code{logical(1)}]\cr
#' Should extra information be printed to the console? Default is \code{TRUE}.
#'
#' @return [\code{CCKriging}]
#' @export
makeCCConfig = function(cat.type = "EC", cont.type = "matern",
cat.par = list(), cont.par = list(nu = 5/2), cat.interaction = TRUE, info = TRUE) {
checkmate::assertChoice(cat.type, choices = c("EC", "MC", "UC", "GK", "CD", "TMC", "GMC"))
checkmate::assertChoice(cont.type, choices = c("matern"))
checkmate::assertList(cat.par, any.missing = FALSE, names = "unique")
if (cat.type == "GMC") {
checkmate::assertSubset(names(cat.par), choices = c("perm"))
checkmate::assertCharacter(cat.par$perm, any.missing = FALSE)
}
checkmate::assertList(cont.par, any.missing = FALSE, names = "unique")
if (cont.type == "matern") {
checkmate::assertSubset(names(cont.par), choices = c("nu"))
checkmate::assertNumeric(cont.par$nu, len = 1L, lower = 0.5, finite = TRUE, any.missing = FALSE)
}
checkmate::assertFlag(cat.interaction)
checkmate::assertFlag(info)
## generate S3 object
config = list(
cat.type = cat.type,
cont.type = cont.type,
cat.par = cat.par,
cont.par = cont.par,
cat.interaction = cat.interaction,
info = info
)
class(config) = "CCConfig"
return(config)
}
#' @export
print.CCConfig = function(x, ...) {
cat('\n--- CCConfig Object ---\n')
cat.string = switch(x$cat.type,
"EC" = "EC - Exchangeable Correlation",
"MC" = "MC - Multiplicative Correlation",
"UC" = "UC - Hypersphere-based Unrestrictive Correlation",
"GK" = "GK - Gower Kriging",
"CD" = "CD - Categorical Distances",
"TMC" = "TMC - Toeplitz Matrix Multiplication-based Correlation",
"GMC" = "GMC - General Matrix Multiplication-based Correlation")
BBmisc::catf(' CATEGORICAL :: %s ', cat.string)
if (x$cat.type == "GMC") {
BBmisc::catf(
' perm :: %s', collapse(x$cat.par$perm, sep = " "))
}
BBmisc::catf(
' interaction :: %s', x$cat.interaction)
BBmisc::catf(' CONTINUOUS :: %s', x$cont.type)
if (x$cont.type == "matern") {
BBmisc::catf(
' nu :: %s', x$cont.par$nu)
}
BBmisc::catf(' INFO :: %s', ifelse(x$info, "yes", "no"))
}
## FIXME: add class CCPerm for permutations having a separate print method?
## print(matrix(as.numeric(config$cat.par$perm), byrow = TRUE, nrow = 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.