# NOT RUN {
require(spdep)
data(boston)
samp <- sample( dim( boston.c )[ 1 ], 400)
d <- boston.c[ samp, ] ## Data at observed sites
y <- d[, "CMEDV"]
x <- d[,c("ZN","INDUS", "NOX","RM", "AGE", "DIS")]
coords <- d[,c("LAT","LON")]
d0 <- boston.c[-samp, ][1,] ## Data at unobserved sites
y0 <- d0[, "CMEDV"]
x0 <- d0[,c("ZN","INDUS", "NOX","RM", "AGE", "DIS")]
coords0 <- d0[,c("LAT","LON")]
############ Model estimation
meig <- meigen( coords = coords )
mod <- resf(y=y, x=x, meig=meig)
## or
# mod <- esf(y=y,x=x,meig=meig)
############ Spatial prediction
meig0 <- meigen0( meig = meig, coords0 = coords0 )
pred0 <- predict0( mod = mod, x0 = x0, meig0 = meig0 )
pred0$pred[1:10,]
######################## If NVCs are assumed
#mod2 <- resf(y=y, x=x, meig=meig, nvc=TRUE)
#pred02 <- predict0( mod = mod2, x0 = x0, meig0 = meig0 )
#pred02$pred[1:10,] # Predicted explained variables
#pred02$c_vc[1:10,] # Predicted NVCs
# }
Run the code above in your browser using DataLab