require(RandomFields)
##Define the coordinates of each location
n.site <- 30
locations <- matrix(rnorm(2*n.site, sd = sqrt(.2)), ncol = 2)
colnames(locations) <- c("lon", "lat")
##Simulate a max-stable process - with unit Frechet margins
sigma <- matrix(c(100, 25, 25, 220),ncol = 2)
sigma.inv <- solve(sigma)
sqrtCinv <- t(chol(sigma.inv))
model <- list(list(model = "gauss", var = 1, aniso = sqrtCinv / 2))
ms0 <- MaxStableRF(locations[,1], locations[,2], grid=FALSE, model=model,
maxstable = "Bool", n = 50)
ms0 <- t(ms0)
##Fit three nested models
M0 <- fitmaxstab(ms0, locations, "gauss", fit.marge = FALSE)
M1 <- fitmaxstab(ms0, locations, "gauss", fit.marge = FALSE, cov11 =
100)
M2 <- fitmaxstab(ms0, locations, "gauss", fit.marge = FALSE, cov11 =
100, cov22 = 500, method = "BFGS")
anova(M0, M1) ## <- M1 seems better
anova(M0, M2) ## <- M0 is better
anova(M1, M2) ## <- M1 is clearly better
##To use the Chandler and Bate methodology:
anova(M0, M1, method = "CB")Run the code above in your browser using DataLab