# an M by M grid
M<- 400
xGrid<- seq( -1, 1, length.out=M)
gridList<- list( x= xGrid,
y= xGrid
)
np<- 3
n<- 100
# sample n locations but avoid margins
set.seed(123)
s<- matrix( runif(n*2, xGrid[(np+1)],xGrid[(M-np)]),
n, 2 )
obj<- offGridWeights( s, gridList, np=3,
Covariance="Matern",
aRange = .1, sigma2= 1.0,
covArgs= list( smoothness=1.0)
)
# make the predictions by obj$B%*%c(y)
# where y is the matrix of values on the grid
# try it out on a simulated Matern field
CEobj<- circulantEmbeddingSetup( gridList,
cov.args=list(
Covariance="Matern",
aRange = .1,
smoothness=1.0)
)
set.seed( 333)
Z<- circulantEmbedding(CEobj)
#
# Note that grid values are "unrolled" as a vector
# for multiplication
# predOffGrid<- obj$B%*% c( Z)
predOffGrid<- obj$B%*% c( Z)
set.panel( 1,2)
zr<- range( c(Z))
image.plot(gridList$x, gridList$y, Z, zlim=zr)
bubblePlot( s[,1],s[,2], z= predOffGrid , size=.5,
highlight=FALSE, zlim=zr)
set.panel()
Run the code above in your browser using DataLab