https://github.com/cran/fields
Tip revision: e6e2dec9c9cc857b2226614aaf6c6642000af53c authored by Doug Nychka on 06 February 2009, 00:00:00 UTC
version 5.02
version 5.02
Tip revision: e6e2dec
Krig.find.REML.R
# fields, Tools for spatial data
# Copyright 2004-2007, Institute for Mathematics Applied Geosciences
# University Corporation for Atmospheric Research
# Licensed under the GPL -- www.gpl.org/licenses/gpl.html
"Krig.find.REML" <-
function (info, lambda.grid, llike, llike.fun, tol, verbose = TRUE,
give.warnings = FALSE)
{
#
# NOTE give.warnings set to FALSE to avoid numerous messages for
# the standard fields examples.
#
ind <- !is.na(llike)
lambda.grid <- lambda.grid[ind]
llike <- llike[ind]
nstep.cv <- length(lambda.grid)
il <- order(llike)[1]
lambda.llike <- lambda.grid[il]
llike.raw <- min(llike)
if (verbose) {
cat("Results of coarse search lambda and restricted Log Likelihood:",
lambda.llike[il],
llike.raw, fill = TRUE)
}
if ((il > 1) & (il < nstep.cv)) {
out <- golden.section.search(lambda.grid[il - 1], lambda.grid[il],
lambda.grid[il + 1], llike.fun, f.extra = info, tol = tol *
llike.raw)
return(out$x)
}
else {
if (give.warnings) {
warning("Search for REML estimate of smoothing paramter gives a
maximum at the endpoints of the grid search")
}
return(lambda.llike)
}
}