# NOT RUN {
# Summarize Data
summary(ContrivedData)
# Initial OLS model
contrived.ols<-lm(y~x.1+x.2,data=ContrivedData)
# summary(contrived.ols)
# Set seed
set.seed(1241060320)
M <- 100
#M<-10000
contrived.run <- metropolis.krige(y ~ x.1 + x.2, coords = c("s.1","s.2"),
data = ContrivedData, n.iter = M, range.tol = 0.05)
# Predict fitted values
predict(contrived.run)
# Predict new data
euler<-c(0.2,0.7)
archimedes<-c(0.3,0.1)
pythagoras<-c(0.1,0.4)
mathematicians<-rbind(euler,archimedes,pythagoras)
basel<-c(0.1,0.8)
sicily<-c(0.4,0.1)
samos<-c(0.1,0.4)
new.locations<-rbind(basel,sicily,samos)
newDf <- as.data.frame(cbind(mathematicians, new.locations))
colnames(newDf) <- c("x.1", "x.2", "s.1", "s.2")
# Make predictions from median parameter values:
(median.pred <- predict(contrived.run, newdata = newDf))
# Make predictions with 90\<!-- % credible intervals: -->
(cred.pred <- predict(contrived.run, newdata = newDf, credible=0.9))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab