https://github.com/cran/fields
Tip revision: 8eab500c3dad2103092ff68706417414fe53e16b authored by Doug Nychka on 22 September 2009, 20:23:49 UTC
version 6.01
version 6.01
Tip revision: 8eab500
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)
}