# NOT RUN {
# Summarize example data
summary(ContrivedData)
# Empirical semivariance for variable y
semivariance(ContrivedData$y,coords = cbind(ContrivedData$s.1, ContrivedData$s.2))
# Initial OLS Model
contrived.ols<-lm(y~x.1+x.2,data=ContrivedData); summary(contrived.ols)
# Empirical semivariance for ols fit
(sv.ols <- semivariance(contrived.ols, coords = c("s.1","s.2"), bins=13))
plot(sv.ols)
# Estimation using metropolis.krige()
# Set seed
set.seed(1241060320)
M <- 100
contrived.run <- metropolis.krige(y ~ x.1 + x.2, coords = c("s.1","s.2"),
data = ContrivedData, n.iter = M, range.tol = 0.05)
# Parametric semivariance
(sv.krige <- semivariance(contrived.run, plot = TRUE))
# Convert to other format for further use
as.matrix(sv.krige)
as.data.frame(sv.krige)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab