# NOT RUN {
set.seed(91179)
library(BayesX)
library(MASS)
# prior precision matrix to zambia data set
K <- read.gra(system.file("examples/zambia.gra", package="sdPrior"))
# generalised inverse of K
Kinv <- ginv(K)
# read data
dat <- read.table(system.file("examples/zambia_height92.raw", package="sdPrior"), header = TRUE)
# design matrix for spatial component
Z <- t(sapply(dat$district, FUN=function(x){1*(x==rownames(K))}))
# get scale parameter
theta <- get_theta(alpha = 0.01, method = "integrate", Z = Z,
c = 3, eps = .Machine$double.eps, Kinv = Kinv)$root
# }
# NOT RUN {
# }
Run the code above in your browser using DataCamp Workspace