Learn R Programming

krige (version 0.6.2)

as.mcmc.krige: Convert krige object to an mcmc object

Description

Convert MCMC matrix of posterior samples for use with the coda package

Usage

# S3 method for krige
as.mcmc(x, start = 1, end = x$n.iter, thin = 1, ...)

# S3 method for summary.krige as.mcmc(x, start = 1, end = x$n.iter, thin = 1, ...)

Arguments

x

An krige or summary.krige object.

start

The iteration number of the first observation.

end

The iteration number of the last observation.

thin

The thinning interval between consecutive observations.

Additional arguments to be passed to mcmc() methods of coda package.

Value

A mcmc object.

Details

The function converts a krige output object to a Markov Chain Monte Carlo (mcmc) object used in coda as well as a variety of MCMC packages. It extracts the MCMC matrix of posterior samples from the output of metropolis.krige for further use with other MCMC packages and functions.

See Also

coda::as.mcmc()

Examples

Run this code
# NOT RUN {
# Summarize Data
summary(ContrivedData)

# Set seed
set.seed(1241060320)

#For simple illustration, we set to few iterations.
#In this case, a 10,000-iteration run converges to the true parameters.
#If you have considerable time and hardware, delete the # on the next line.
#10,000 iterations took 39 min. with 8 GB RAM & a 1.5 GHz Quad-Core processor.
M <- 100
#M<-10000

contrived.run <- metropolis.krige(y ~ x.1 + x.2, coords = c("s.1","s.2"), 
                                  data = ContrivedData, n.iter = M, n.burnin = 20,
                                  range.tol = 0.05)
                                  
# Convert to mcmc object
mcmc.contrived.run <- as.mcmc(contrived.run)
#mcmc.contrived.run <- as.mcmc(summary(contrived.run))

# Diagnostics using MCMC packages
coda::raftery.diag(mcmc.contrived.run)
# superdiag::superdiag(mcmc.contrived.run) #NOT WORKING YET
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab