https://github.com/cran/fields
Tip revision: 493a3e14a7a05b0b78de44e0a2b1eec55d9783ac authored by Doug Nychka on 04 September 2009, 00:00:00 UTC
version 6.3
version 6.3
Tip revision: 493a3e1
Krig.parameters.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.parameters" <- function(obj, mle.calc = obj$mle.calc) {
# if nondiag W is supplied then use it.
# otherwise assume a diagonal set of weights.
#
# NOTE: calculation of shat involves full set of obs
# not those colllapsed to the mean.
if (obj$nondiag.W) {
shat.GCV <- sqrt(sum((obj$W2 %d*% obj$residuals)^2)/(length(obj$y) -
obj$eff.df))
}
else {
shat.GCV <- sqrt(sum((obj$weights * obj$residuals^2)/(length(obj$y) -
obj$eff.df)))
}
if (mle.calc) {
rhohat <- sum(obj$c * obj$yM)/(obj$N - obj$nt)
shat.MLE <- sqrt(rhohat * obj$lambda)
}
else {
rhohat <- shat.MLE <- NA
}
list(shat.GCV = shat.GCV, shat.MLE = shat.MLE, rhohat = rhohat)
}