# NOT RUN {
## Generate realizations from the model
n.site <- 30
n.obs <- 50
coord <- cbind(lon = runif(n.site, -10, 10), lat = runif(n.site, -10 , 10))
gp.loc <- rgp(1, coord, "powexp", sill = 4, range = 20, smooth = 1)
gp.scale <- rgp(1, coord, "powexp", sill = 0.4, range = 5, smooth = 1)
gp.shape <- rgp(1, coord, "powexp", sill = 0.01, range = 10, smooth = 1)
locs <- 26 + 0.5 * coord[,"lon"] + gp.loc
scales <- 10 + 0.2 * coord[,"lat"] + gp.scale
shapes <- 0.15 + gp.shape
data <- matrix(NA, n.obs, n.site)
for (i in 1:n.site)
data[,i] <- rgev(n.obs, locs[i], scales[i], shapes[i])
loc.form <- y ~ lon
scale.form <- y ~ lat
shape.form <- y ~ 1
hyper <- list()
hyper$sills <- list(loc = c(1,8), scale = c(1,1), shape = c(1,0.02))
hyper$ranges <- list(loc = c(2,20), scale = c(1,5), shape = c(1, 10))
hyper$smooths <- list(loc = c(1,1/3), scale = c(1,1/3), shape = c(1, 1/3))
hyper$betaMeans <- list(loc = rep(0, 2), scale = c(9, 0), shape = 0)
hyper$betaIcov <- list(loc = solve(diag(c(400, 100))),
scale = solve(diag(c(400, 100))),
shape = solve(diag(c(10), 1, 1)))
## We will use an exponential covariance function so the jump sizes for
## the shape parameter of the covariance function are null.
prop <- list(gev = c(2.5, 1.5, 0.2), ranges = c(0.7, 0.75, 0.9), smooths = c(0,0,0))
start <- list(sills = c(4, .36, 0.009), ranges = c(24, 17, 16), smooths
= c(1, 1, 1), beta = list(loc = c(26, 0.5), scale = c(10, 0.2),
shape = c(0.15)))
## Generate a Markov chain
mc <- latent(data, coord, loc.form = loc.form, scale.form = scale.form,
shape.form = shape.form, hyper = hyper, prop = prop, start = start,
n = 100)
x.grid <- y.grid <- seq(-10, 10, length = 50)
map.latent(mc, x.grid, y.grid, param = "shape")
# }
Run the code above in your browser using DataLab