https://github.com/cran/fields
Raw File
Tip revision: 56c6d241a6642cc8bd7ee1b4b209bf9888daa74c authored by Doug Nychka on 20 October 2008, 00:00:00 UTC
version 5.01
Tip revision: 56c6d24
Krig.Amatrix.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.Amatrix<- function (object, x0 = object$x, lambda=NULL,
                          eval.correlation.model = FALSE,...)
{

  if( is.null( lambda)){ lambda<- object$lambda}

  M<- nrow(object$xM)
  N<- nrow( x0)

# create output matrix 
  out<- matrix( NA,N,M)

#
# loop through unique data locations predicting response 
# using unit vector
# NOTE that the y vector has already been collapsed onto means. 
#

    for( k in 1: M){
     ytemp<- rep( 0,M)
     ytemp[k] <- 1
     out[,k] <- predict(object, x= x0, yM= ytemp, lambda=lambda,
                 eval.correlation.model = eval.correlation.model,...)
    } 

    return(out)
}
 

back to top