# NOT RUN {
## The examples below will only be run if sufficient time is allowed
## You can change that by typing e.g. IsoriX.options(example_maxtime = XX)
## if you want to allow for examples taking up to ca. XX seconds to run
## (so don't write XX but put a number instead!)
if(IsoriX.getOption("example_maxtime") > 60) {
## We simulate data under default settings
simu <- isosim(simu.data = ElevRasterDE,
save.dataframe = TRUE, seed = 1)
simu
## We build the plots of the outcome using IsoriX
plot.mean.simu <- plot(x = simu, which = "mean")
plot.disp.simu <- plot(x = simu, which = "disp")
## We fit the simulated data by sampling 50 locations
set.seed(123)
newdat <- simu$data[sample(1:nrow(simu$data), 50), ]
isoscapemodel <- isofit(iso.data = newdat,
mean.model.fix = list(elev = TRUE, lat.abs = TRUE))
isoscape <- isoscape(ElevRasterDE, isoscapemodel)
plot.mean.fitted <- plot(x = isoscape, which = "mean", sources = list(draw = FALSE))
plot.disp.fitted <- plot(x = isoscape, which = "disp", sources = list(draw = FALSE))
## We compare simulated and fitted data visually
if(require(lattice)){
print(plot.mean.simu, split = c(1, 1, 2, 2), more = TRUE)
print(plot.disp.simu, split = c(2, 1, 2, 2), more = TRUE)
print(plot.mean.fitted, split = c(1, 2, 2, 2), more = TRUE)
print(plot.disp.fitted, split = c(2, 2, 2, 2), more = FALSE)
}
## We compare simulated and fitted data numerically
## Note that differences are expected, as the geographic
## area is small compared to the scale at which
## spatial auto-correlation occurs
round(cbind(
simulated = c(
intercept = 64,
lat.abs = -2.3,
elev = -0.01,
nu = 0.35,
rho = 5e-5,
rho_div_nu = 5e-5/0.35,
lambda.ID = 0,
lambda.matern = 899,
intercept.disp = 5.8,
nu.disp = 3.2e-01,
rho.disp = 1.5e-05,
lambda.matern.stationID = 0,
lambda.matern.disp = 5),
fitted = c(
intercept = isoscapemodel$mean.fit$fixef[1],
lat.abs = isoscapemodel$mean.fit$fixef[2],
elev = isoscapemodel$mean.fit$fixef[3],
nu = isoscapemodel$mean.fit$ranFix$nu,
rho = isoscapemodel$mean.fit$ranFix$rho,
rho_div_nu = with(isoscapemodel$mean.fit$ranFix,rho/nu),
lambda.matern = isoscapemodel$mean.fit$lambda,
intercept.disp = isoscapemodel$disp.fit$fixef[1],
nu.disp = isoscapemodel$disp.fit$ranFix$nu,
rho.disp = isoscapemodel$disp.fit$ranFix$rho,
lambda.matern.disp = isoscapemodel$disp.fit$lambda)), 4)
}
# }
Run the code above in your browser using DataLab