# multiply 2-d isotropic exponential with aRange=4 by a random vector
junk<- matrix(rnorm(50*100), 50,100)
gridList<- list( x= seq(0,1,length.out=50),
y= seq(-1,1,length.out=100) )
covObject<- stationaryImageCov( setup=TRUE,
Covariance="Matern",
smoothness=1.0,
aRange=.08,
gridList=gridList)
result<- stationaryImageCov(Y=junk, covObject=covObject)
imagePlot(gridList$x,gridList$y, result ) # NOTE that is also a smoother!
# to do it again, no setup is needed
# e.g.
# junk2<- matrix(rnorm(100**2, 100,100))
# result2<- stationaryImageCov(Y=junk2, cov.obj=cov.obj)
# generate a grid and set of indices based on discretizing the locations
# in the precip dataset
out<-as.image( RMprecip$y, x= RMprecip$x)
ind1<- out$ind
gridList<- list( x= out$x, y=out$y)
#
# discretized x locations to use for comparison
xd<- cbind( out$x[ out$ind[,1]], out$y[ out$ind[,2]] )
# setup to create cov.obj for exponential covariance with range= 1.25
covObject<- stationaryImageCov( setup=TRUE, gridList=gridList, aRange=1.25)
# multiply covariance matrix by an arbitrary vector
junk<- rnorm(nrow( ind1))
result<- stationaryImageCov( ind1, ind1, Y= junk,covObject=covObject)
# The brute force way would be
# result<- stationary.cov( xd, xd, aRange=1.25, C=junk)
# or
# result<- stationary.cov( xd, xd, aRange=1.25) %*% junk
# both of these take much longer
# evaluate the covariance between all grid points and the center grid point
mGrid<- covObject$m
Y<- matrix(0,mGrid[1], mGrid[2])
Y[32,32]<- 1
result<- stationaryImageCov( Y= Y,covObject=covObject)
# covariance surface with respect to the grid point at (32,32)
#
# reshape "vector" as an image
temp<- matrix( result, mGrid[1],mGrid[2])
imagePlot( temp)
Run the code above in your browser using DataLab