# multiply 2-d isotropic exponential with theta=4 by a random vector
junk<- matrix(rnorm(100*100), 100,100)
cov.obj<- exp.image.cov( setup=TRUE, grid=list(x=1:100,y=1:100), theta=8)
result<- exp.image.cov(Y=junk,cov.obj=cov.obj)
image( matrix( result, 100,100))
# do it again, no setup needed
# junk2<- matrix(rnorm(100**2, 100,10))
# result2<- exp.image.cov(Y=junk2, cov.obj=cov.obj)
# generate a grid and set of indices based on discretizing the locations
# in the precip dataset
data(RMprecip)
out<-as.image( RMprecip$y, x= RMprecip$x)
ind1<- out$ind
grid<- list( x= out$x, y=out$y)
# there are 750 gridded locations
# setup to create cov.obj for exponential covariance with range= 1.25
# p=1 is the default
cov.obj<- exp.image.cov( setup=TRUE, grid=grid, theta=1.25)
# multiply covariance matrix by an arbitrary vector
junk<- rnorm(750)
result<- exp.image.cov( ind1, ind1, Y= junk,cov.obj=cov.obj)
# The brute force way would be
# result<- exp.cov( RMprecip$x, RMprecip$x,theta=1.25, C=junk)
# evaluate the covariance between all grid points and the center grid point
Y<- matrix(0,cov.obj$m, cov.obj$n)
Y[32,32]<- 1
result<- exp.image.cov( Y= Y,cov.obj=cov.obj)
# covariance surface with respect to the grid point at (32,32)
#
# reshape "vector" as an image
temp<- matrix( result, cov.obj$m,cov.obj$n)
image.plot(cov.obj$grid$x,cov.obj$grid$y, temp)
# or persp( cov.obj$grid$x,cov.obj$grid$y, temp)
# check out the Matern.
cov.obj<- matern.image.cov( setup=TRUE, grid=grid, theta=1.25,
smoothness=2)
Y<- matrix(0,64,64)
Y[16,16]<- 1
result<- matern.image.cov( Y= Y,cov.obj=cov.obj)
temp<- matrix( result, cov.obj$m,cov.obj$n)
image.plot( cov.obj$grid$x,cov.obj$grid$y, temp)
# Note we have centered at the location (16,16) for this case
Run the code above in your browser using DataLab