sample.eta | R Documentation |
This function samples from the log-posterior density of the smoothing parameter from the thin-plate splines based spatial prior using a ratio-of-uniform sampler.
sample.eta(N, ND, EV, Q, UL = 1000, log_prior)
N |
the number of samples desired. |
ND |
the rank of the precision matrix, the default value is n-3 for spatial data. |
EV |
eigenvalues of the precision matrix spatial prior from the function make.M(). |
Q |
the data vector from the cross-product of observed data, Y, and eigenvalues from the M matrix, V. |
UL |
the upper limit for the smoothing parameter value; used for the ratio-of-uniform sampler, default is 1000. |
log_prior |
a function of x evaluating the log of the prior density for eta |
N samples drawn from the posterior of eta given the data y π(eta | y).
## Use the Meuse River dataset from the package 'gstat' library(sp) library(gstat) data(meuse.all) coordinates(meuse.all) <- ~ x + y X <- scale(coordinates(meuse.all)) tmp <- make.M(X) EV <- tmp$M.eigen$values V <- tmp$M.eigen$vectors M <- tmp$M Y <- scale(log(meuse.all$zinc)) Q <- crossprod(Y, V) ND <- nrow(X) - 3 f <- function(x) -x ## log-prior for exponential distribution for the smoothing parameter ## Draw 100 samples from the posterior of eta given the data y. sample.eta(100, ND, EV, Q, UL = 1000, f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.