Krig(ozone$x,ozone$y, theta=50) ->fit
predict( fit) # gives predicted values at data points
# find the partial derivatives at observation locations
# returned object is a two column matrix.
# this does not make sense for the exponential covariance
# but can illustrate this with a thin plate spline.
#
fit0<- Tps( ozone$x, ozone$y, m=3)
look<- predict.derivative.Krig( fit0)
# only the fixed part of the model
predict( fit, just.fixed=TRUE)
# in this case the default is a linear spatial drift (m=2) and there
# are no additional covariates
grid<- make.surface.grid( list( seq( -40,40,,15), seq( -40,40,,15)))
look<- predict(fit,grid) # evaluate on a grid of points
# some useful graphing functions
out.p<- as.surface( grid, look) # reformat into $x $y $z image-type object
#NOTE: the above steps are the same as using the "wrapper" function
# predict.surface(fit, grid)-> out.p
contour( out.p)
# refit with 10 degrees of freedom in surface
look<- predict(fit,grid, df=15)
# refit with random data
look<- predict( fit, grid, y= rnorm( 20))
Run the code above in your browser using DataLab