model <- c(var=5, range=1,shape=0.5)
RandomFields::plot(modelRandomFields(model))
myraster = raster(nrows=60,ncols=60,xmn=0,ymn=0,xmx=10,ymx=10,
crs="+init=epsg:2081")
set.seed(0)
simu <- geostatsp::RFsimulate(model, x=myraster, n=3)
plot(simu[[2]])
data("swissRain")
swissRain$sqrtrain = sqrt(swissRain$rain)
# estimate parameters
swissRes = lgm(swissRain, locations=20, formula="sqrtrain",
covariates=swissAltitude,
shape=1, fixShape=TRUE,
aniso=FALSE, nugget=0, fixNugget=TRUE,
nuggetInPrediction=FALSE
)
# simulate from the random effect conditional on
# the observed data
swissSim = geostatsp::RFsimulate(model=swissRes$param,
data=swissRes$resid,
x=swissRes$predict,
n=3
)
# plot the simulated random effect
plot(swissSim[[1]])
plot(swissBorder, add=TRUE)
Run the code above in your browser using DataLab