# NOT RUN {
n.site <- 30
n.obs <- 50
coord <- matrix(runif(2 * n.site, -10, 10), ncol = 2)
colnames(coord) <- c("lon", "lat")
## Generate data from a Gaussian copula model
data <- rcopula(n.obs, coord, "gaussian", "powexp", nugget = 0, range = 4, smooth = 1.2)
## Transform the margins to GEV
locs <- -5 + coord[,"lon"] / 10
scales <- 10 + coord[,"lat"] / 2
shapes <- rep(0.2, n.site)
for (i in 1:n.site)
data[,i] <- frech2gev(data[,i], locs[i], scales[i], shapes[i])
## Fit a Gaussian copula model
## 1. Define trend surfaces
loc.form <- y ~ lon
scale.form <- y ~ lat
shape.form <- y ~ 1
## 2. Fit
M0 <- fitcopula(data, coord, "gaussian", "powexp", loc.form, scale.form,
shape.form, nugget = 0)
# }
Run the code above in your browser using DataLab