https://github.com/cran/fields
Raw File
Tip revision: b10307613a7bc4d85a17dfbf2c41e0935f6eb0fb authored by Doug Nychka on 20 November 2004, 17:32:00 UTC
version 1.7.2
Tip revision: b103076
predict.surface.se.R
"predict.surface.se" <-
function(out, grid.list = NA, extrap = FALSE, chull.mask, ...)
{
	if((length(grid.list) == 1) | (is.na(grid.list)[1])) {
		grid.list <- as.list(rep("c", ncol(out$x)))
		grid.list[[1]] <- "x"
		grid.list[[2]] <- "y"
		temp <- dimnames(out$x)[[2]]
		if(!(temp[1] == ""))
			names(grid.list) <- temp
	}
	if(is.null(out$x))
		xg <- make.surface.grid(grid.list)
	else xg <- make.surface.grid(grid.list, X = out$x)
	out2 <- as.surface(xg, predict.se(out, xg, ...))
	if(!extrap) {
		if(missing(chull.mask)) {
			ind <- c(attr(xg, "format")[, 1])
			chull.mask <- out$x[, ind]
		}
		#
		# find grid points that are outside convex hull
		# of 2-d projection of the observations
		# or the set of points passed in the call 
		# set these grid points to NA in the matrix of predictions
		#
		chull.mask <- chull.mask[chull(chull.mask),  ]
		out2$z[in.poly(xg, xp = chull.mask) == 0] <- NA
	}
	out2
}
back to top