Skip to content
This repository was archived by the owner on Apr 1, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified R/SCAD.R
100755 → 100644
Empty file.
Empty file modified R/SCAD.derivative.R
100755 → 100644
Empty file.
Empty file modified R/branin.R
100755 → 100644
Empty file.
Empty file modified R/camelback.R
100755 → 100644
Empty file.
Empty file modified R/computeAuxVariables.R
100755 → 100644
Empty file.
Empty file modified R/covStruct.create.R
100755 → 100644
Empty file.
Empty file modified R/covStruct_XtraClass_Union.R
100755 → 100644
Empty file.
Empty file modified R/covStruct_XtraMethods.R
100755 → 100644
Empty file.
Empty file modified R/drop.reponse.R
100755 → 100644
Empty file.
Empty file modified R/goldsteinPrice.R
100755 → 100644
Empty file.
Empty file modified R/hartman3.R
100755 → 100644
Empty file.
Empty file modified R/hartman6.R
100755 → 100644
Empty file.
12 changes: 9 additions & 3 deletions R/km.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@
}

[email protected] <- TRUE
##
optim.method <- tolower(optim.method)
if(!(optim.method %in% c("bfgs", "gen"))) {
stop("'optim.method' must be either 'BFGS' or 'gen'. Currently it is '",
optim.method, "'")
}
[email protected] <- optim.method

##
if ((length(lower) == 0) || (length(upper) == 0)) {
bounds <- covParametersBounds(model@covariance, design)
if (length(lower) == 0) lower <- bounds$lower
Expand All @@ -129,7 +135,7 @@
model@upper <- as.numeric(upper)
model@parinit <- as.numeric(parinit)

if (optim.method == "BFGS") {
if (optim.method == "bfgs") {
if (length(control$pop.size) == 0) control$pop.size <- 20
control$pop.size <- max(control$pop.size, multistart)
if (identical(control$trace, FALSE)) control$trace <- 0
Expand Down Expand Up @@ -220,7 +226,7 @@
model@penalty$value <- lambda
model <- f(model, envir = envir.logLik)
} else {
model <- f(model, envir = envir.logLik)
model <- f(model, envir = envir.logLik)
}

return(model)
Expand Down
Empty file modified R/km1Nugget.init.R
100755 → 100644
Empty file.
Empty file modified R/kmData.R
100755 → 100644
Empty file.
32 changes: 15 additions & 17 deletions R/kmEstimate.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@
cat(" - variance bounds : ", c(lower[lp], upper[lp]), "\n")
}
cat(" - best initial criterion value(s) : ", initList$value, "\n")
if ([email protected]=="BFGS") cat("\n")
if ([email protected]=="bfgs") cat("\n")
} # end printing

# optimization

if ([email protected]=="BFGS") {
BFGSargs <- c("trace", "parscale", "ndeps", "maxit", "abstol", "reltol", "REPORT", "lnm", "factr", "pgtol")
if ([email protected]=="bfgs") {
BFGSargs <- c("trace", "parscale", "ndeps", "maxit", "abstol", "reltol", "REPORT", "lnm", "factr", "pgtol")
commonNames <- intersect(BFGSargs, names(control))
controlChecked <- control[commonNames]
if (length(control$REPORT)==0) {
Expand All @@ -110,8 +110,7 @@

# multistart in parallel with foreach
multistart <- control$multistart

if (multistart==1){
if (multistart==1) {
model@parinit <- parinit <- as.numeric(parinit[, 1])
model@covariance <- initList$cov[[1]]
o <- optim(par = parinit, fn = fn, gr = gr,
Expand All @@ -120,16 +119,17 @@
model@control$convergence <- o$convergence
} else {
# multistart with foreach
if (requireNamespace("foreach", quietly = TRUE)){
olist <- foreach::"%dopar%"(foreach::foreach(i=1:multistart,
.errorhandling='remove'), {
model@covariance <- initList$cov[[i]]
optim(par = parinit[, i], fn = fn, gr = gr,
method = "L-BFGS-B", lower = lower, upper = upper,
control = controlChecked, hessian = FALSE, model, envir=envir)
if (requireNamespace("foreach", quietly = TRUE)) {
olist <- foreach::"%dopar%"(foreach::foreach(i=seq(length=multistart),
.errorhandling='stop'), {
model@covariance <- initList$cov[[i]]
optim(par = parinit[, i], fn = fn, gr = gr,
method = "L-BFGS-B", lower = lower, upper = upper,
control = controlChecked, hessian = FALSE, model, envir=envir)
})
## Note: if errorhandling drops the errors, the olist will be
## shorter. I find it useful to have errors displayed.
}

# get the best result
bestValue <- Inf
bestIndex <- NA
Expand All @@ -142,8 +142,7 @@
bestValue <- currentValue
bestIndex <- i
}
} # end multistart

} # end multistart
model@covariance <- initList$cov[[bestIndex]]
parinit <- parinit[, bestIndex]
model@parinit <- as.numeric(parinit)
Expand Down Expand Up @@ -195,11 +194,10 @@
lower = lower, upper = upper,
control = control, model=model, envir=envir)
}

model@logLik <- as.numeric(o$value)


if (model@method=="LOO"){
if (model@method=="LOO") {

model@covariance <- vect2covparam(model@covariance, o$par)

Expand Down
Empty file modified R/kmNoNugget.init.R
100755 → 100644
Empty file.
Empty file modified R/kmNuggets.init.R
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion R/kmStruct.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ update.km <- function(object,
if (is.null(kmcontrol$penalty)) kmcontrol$penalty <- object@penalty
if (length(object@penalty == 0)) kmcontrol$penalty <- NULL
if (is.null(kmcontrol$optim.method)) kmcontrol$optim.method <- [email protected]
if (length(kmcontrol$optim.method) == 0) kmcontrol$optim.method <- "BFGS"
if (length(kmcontrol$optim.method) == 0) kmcontrol$optim.method <- "bfgs"
if (is.null(kmcontrol$control)) kmcontrol$control <- object@control
if(length(object@gr) == 0) object@gr <- TRUE
knots <- NULL; if(TheClass == "covScaling") knots <- object@covariance@knots
Expand Down
Empty file modified R/leaveOneOut.km.R
100755 → 100644
Empty file.
Empty file modified R/logLik.km.R
100755 → 100644
Empty file.
8 changes: 2 additions & 6 deletions R/logLikFun.R
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
`logLikFun` <-
function(param, model, envir=NULL) {

if ([email protected]=="Trend") {
beta <- [email protected]
} else {
beta <- NULL
}

if (identical(model@case, "LLconcentration_beta_sigma2")) {

model@covariance <- vect2covparam(model@covariance, param)
Expand All @@ -31,13 +29,12 @@ function(param, model, envir=NULL) {
}

} else if (identical(model@case, "LLconcentration_beta")) {

nparam <- length(param)
if (class(model@covariance) != "covAdditive0") {
if (class(model@covariance) != "covAdditive0") {
model@covariance <- vect2covparam(model@covariance, param[1:(nparam-1)])
model@covariance@sd2 <- param[nparam]
} else {
model@covariance <- vect2covparam(model@covariance, param)
model@covariance <- vect2covparam(model@covariance, param)
}

# if (model@[email protected]) {
Expand All @@ -50,7 +47,6 @@ function(param, model, envir=NULL) {

C <- aux[[1]]
vn <- aux[[2]]

T <- chol(C)
x <- backsolve(t(T), model@y, upper.tri = FALSE)
M <- backsolve(t(T), model@F, upper.tri = FALSE)
Expand Down
Empty file modified R/logLikGrad.R
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions R/scalingFun.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ scalingFun <- function(X, knots, eta, plot = FALSE) {
transX <- matrix(NA, nrow = NROW(X), ncol = NCOL(X))
dimnames(transX) <- dimnames(X)
X <- as.matrix(X)

for (i in 1:d){
transX[ , i] <- scalingFun1d(x = X[ , i], knots = knots[[colnames(X)[i]]], eta = eta[[colnames(X)[i]]])
transX[ , i] <- scalingFun1d(x = X[ , i], knots = knots[[i]],
eta = eta[[i]])
}

if (plot) {
Expand Down
Empty file modified R/scalingGrad.R
100755 → 100644
Empty file.
Empty file modified R/show.km.R
100755 → 100644
Empty file.
Empty file modified R/trendMatrix.update.R
100755 → 100644
Empty file.
12 changes: 9 additions & 3 deletions man/km.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,21 @@ km(formula=~1, design, response, covtype="matern5_2",
\item{response}{ a vector (or 1-column matrix or data frame) containing the values of the 1-dimensional output given by the objective function at the \code{design} points. }
\item{covtype}{ an optional character string specifying the covariance structure to be used, to be chosen between \code{"gauss"}, \code{"matern5_2"}, \code{"matern3_2"}, \code{"exp"} or \code{"powexp"}. See a full description of available covariance kernels in \code{\link{covTensorProduct-class}}. Default is \code{"matern5_2"}. See also the argument \code{kernel} that allows the user to build its own covariance structure.}
\item{coef.trend,}{ (see below)}
\item{coef.cov,}{ (see below)}
\item{coef.cov}{ (see below)}
\item{coef.var}{ optional vectors containing the values for the trend, covariance and variance parameters. For estimation, 4 cases are implemented: 1. (All unknown) If all are missing, all are estimated. 2. (All known) If all are provided, no estimation is performed; 3. (Known trend) If \code{coef.trend} is provided but at least one of \code{coef.cov} or \code{coef.var} is missing, then BOTH \code{coef.cov} and \code{coef.var} are estimated; 4. (Unknown trend) If \code{coef.cov} and \code{coef.var} are provided but \code{coef.trend} is missing, then \code{coef.trend} is estimated (GLS formula).}
\item{nugget}{ an optional variance value standing for the homogeneous nugget effect.}
\item{nugget.estim}{ an optional boolean indicating whether the nugget effect should be estimated. Note that this option does not concern the case of heterogeneous noisy observations (see \code{noise.var} below). If \code{nugget} is given, it is used as an initial value. Default is \code{FALSE}.}
\item{noise.var}{ for noisy observations : an optional vector containing the noise variance at each observation. This is useful for stochastic simulators. Default is \code{NULL}.}
\item{estim.method}{ a character string specifying the method by which unknown parameters are estimated. Default is \code{"MLE"} (Maximum Likelihood). At this stage, a beta version of leave-One-Out estimation (\code{estim.method="LOO"}) is also implemented for noise-free observations.}
\item{penalty}{ (beta version) an optional list suitable for Penalized Maximum Likelihood Estimation. The list must contain the item \code{fun} indicating the penalty function, and the item \code{value} equal to the value of the penalty parameter. At this stage the only available \code{fun} is \code{"SCAD"}, and \code{covtype} must be \code{"gauss"}. Default is \code{NULL}, corresponding to (un-penalized) Maximum Likelihood Estimation.}
\item{optim.method}{ an optional character string indicating which optimization method is chosen for the likelihood maximization. \code{"BFGS"} is the \code{optim} quasi-Newton procedure of package \code{stats}, with the method "L-BFGS-B". \code{"gen"} is the \code{genoud} genetic algorithm (using derivatives) from package \code{rgenoud} (>= 5.3.3). }
\item{lower, }{ (see below) }
\item{optim.method}{ an optional character string indicating which
optimization method to choose for the likelihood
maximization. \code{"BFGS"} is the \code{optim} quasi-Newton
procedure of package \code{stats}, with the method
"L-BFGS-B". \code{"gen"} is the \code{genoud} genetic algorithm
(using derivatives) from package \code{rgenoud} (>= 5.3.3). Lower
case forms also supported.}
\item{lower}{ (see below) }
\item{upper}{ optional vectors containing the bounds of the correlation parameters for optimization. The default values are given by \code{\link{covParametersBounds}}. }
\item{parinit}{ an optional vector containing the initial values for the variables to be optimized over. If no vector is given, an initial point is generated as follows. For method \code{"gen"}, the initial point is generated uniformly inside the hyper-rectangle domain defined by \code{lower} and \code{upper}. For method \code{"BFGS"}, some points (see \code{control} below) are generated uniformly in the domain. Then the best point with respect to the likelihood (or penalized likelihood, see \code{penalty}) criterion is chosen. }
\item{multistart}{ an optional integer indicating the number of initial points from which running the BFGS optimizer. These points will be selected as the best \code{multistart} one(s) among those evaluated (see above \code{parinit}). The multiple optimizations will be performed in parallel provided that a parallel backend is registered (see package \code{foreach}).}
Expand Down
6 changes: 4 additions & 2 deletions man/scalingFun.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ scalingFun(X, knots, eta, plot=FALSE)
\arguments{
\item{X}{ an n*d matrix standing for a design of n experiments in d-dimensional space }
\item{knots}{ a list of knots parametrizing the transformation. }
\item{eta}{ a list of coefficients parametrizing the d marginal transformations. Each element stands for a set of marginal density values at the knots defined above.}
\item{plot}{ if TRUE plots the image of the columns of X according to the corresponding marginal transformations.}
\item{eta}{a list of coefficients parametrizing the d marginal
transformations. Each element stands for a set of marginal density
values at the knots defined above.}
\item{plot}{ if TRUE plots the image of the columns of X according to the corresponding marginal transformations.}
}

\value{
Expand Down
Empty file modified src/CovFuns.c
100755 → 100644
Empty file.
Empty file modified src/Scaling.c
100755 → 100644
Empty file.