Learn R Programming

geostatsp (version 0.4.4)

grfConditional: Conditional simulation of a Gaussian Random Field

Description

Simulates a Gaussian random field conditional on observed values.

Usage

grfConditional(data,  model.fit, locations, Nsim, 
	covariates, rasterMethod = "ngb", fun, nugget.in.prediction=T)

Arguments

data
A SpatialPointsDataFrame object containing the data to be conditioned upon.
model.fit
A fitted model produced by likfit
locations
A raster on which the field will be simulated.
Nsim
Number of samples to simulate.
covariates
The spatial covariates used in prediction, either a raster stack or list of rasters.
rasterMethod
Method for reprojecting or resampling rasters, either "bilinear" or "ngb".
fun
A function applied to each realised surface and only the result saved.
nugget.in.prediction
If TRUE, predict new observations by adding the nugget effect. Otherwise predict fitted values. Only relevant for Box-Cox or log transformed data.

Value

  • randomthe predictions and conditional variance of the random effects, on the same raster as locations

See Also

krige.conv

Examples

Run this code
data(swissRain)


swissRain$elevation = extract(swissAltitude, swissRain)
swissRain$sqrtrain = sqrt(swissRain$rain)
swissFit =  likfit(swissRain, sqrtrain ~ elevation, 
	cov.model="matern", kappa = 2, fix.kappa=TRUE, 
	fix.psiA=FALSE, fix.psiR=FALSE,
	ini.cov.pars= c(0.6, 7000))

swissRaster = raster(extent(swissRain@bbox), ncols=20, nrows=20, 
	crs=swissRain@proj4string)	


swissSim = grfConditional(data=swissRain,  model.fit=swissFit, 
locations=swissRaster, Nsim=2, 
covariates=swissAltitude, nugget.in.prediction=FALSE) 

plot(swissSim[[2]]) 

# proportion the realisation above 200
swissSim2 = grfConditional(data=swissRain,  model.fit=swissFit, 
locations=swissRaster, Nsim=4, covariates=swissAltitude, 
fun = function(x) mean(x^2>200)  )

unlist(swissSim2) 
load(url("http://www.filefactory.com/file/frd1mhownd9/n/CHE_adm0_RData"))
plot(spTransform(gadm, swissRain@proj4string), add=TRUE)

Run the code above in your browser using DataLab