#
data(ozone2)
sOzone<- ozone2$lon.lat
yOzone<- ozone2$y[16,]
# Matern smoothness =1.0 sigma2 and tau found by ML
fit0<- spatialProcess( sOzone,yOzone, aRange=10)
# prediction SEs at miss data locations
missingObs<- is.na(yOzone)
missingSE<- predictSE(fit0, sOzone[missingObs,])
# NOTE based on dispatching predictSE.mKrig is called.
# 95% CI for ozone surface
fHat<- predict(fit0, sOzone[missingObs,])
cbind(fHat - 1.96*missingSE, fHat + 1.96*missingSE )
# 95% CI for ozone _observation_
fHat<- predict(fit0, sOzone[missingObs,])
tau2<- fit0$summary["tau"]^2
cbind(fHat - 1.96*sqrt(missingSE + tau2) ,
fHat + 1.96*sqrt(missingSE + tau2) )
# SE on a grid of locations
xg<-make.surface.grid(
list(x=seq(-91,-83,,30),
y=seq( 37, 45,,30))
)
gridSE<- predictSE(fit0,xg) # std errors of predictions
#at the grid points out is a vector of length 900
#reshape the grid points into a 30X30 matrix etc.
out.p<-as.surface( xg, gridSE)
surface( out.p, type="C")
points( sOzone[!missingObs,], col="magenta", pch=16)
# this is equivalent to the higher level functions
# (We are lazy and the grid will be a bit different here. See the
# help file!)
out<- predictSurfaceSE( fit0, nx=30, ny=30, extra=TRUE)
imagePlot( out, col=viridis(256))
contour( out, add=TRUE, levels=c( 10,20, 20))
points( sOzone[!missingObs,], col="magenta", pch=16)
Run the code above in your browser using DataLab