Description Usage Arguments Details Value Author(s) See Also Examples
The fields are Gaussian and can be either simulated unconditionally or conditional on the field values and a set of irregular locations.
1 2 3 4 5 6 7 
grid.list 
Specifies a grid of spatial locations using the

just.coefficients 
If TRUE just simulates the coefficients from the Markov Random field. 
LKinfo 
A list with components that give the information
describing a multiresolution basis with a Markov random field used for
the covariance of the basis coefficients. This list is created in

M 
Number of independent simulated fields. 
nx 
Number of grid points in x coordinate for output grid. 
ny 
Number of grid points in y coordinate for output grid. 
LKrigObj 
An 
seed 
Seed to set random number generator. 
x1 
A two column matrix of 2dimension locations to evaluate
basis functions or the first set of locations to evaluate the
covariance function or the locations for the simulated process. Rows
index the different locations: to be precise 
x.grid 
Locations to evaluate conditional fields. This is in the form of a two column matrix where each row is a spatial location. 
Z.grid 
The covariates that are associated with the x.grid values. This is useful for conditional simulation where the fields are evaluated at x.grid locations and using covariate values Z.grid. Z.grid is matrix with columns indexing the different covariates and rows indexed by the x.grid locations. 
... 
Arguments to be passed to the LKrig function to specify the spatial estimate. These are components in addition to what is in the LKinfo list returned by LKrig. 
verbose 
If TRUE prints out debugging information. 
ghat 
The predicted surface at the grid. 
index 
The index for the random seed to use in the vector 
PHIGrid 
Basis function matrix at grid points. 
seeds 
A vector of random seeds. 
The simulation of the unconditional random field is done by generating a draw from the multiresolution coefficients using a Cholesky decomposition and then multiplying by the basis functions to evaluate the field at arbitrary points. Currently, there is no provision to exploit the case when one wants to simulate the field on a regular grid. The conditional distribution is a draw from the multivariate normal for the random fields conditioned on the observations and also conditioned on covariance model and covariance parameters. If the nugget/measurement error variance is zero then any draw from the conditional distribution will be equal to the observations at the observation locations. In the past conditional simulation was known to be notoriously compute intensive, but the major numerical problems are finessed here by exploiting sparsity of the coefficient precision matrix.
The conditional field is found using a simple trick based on the
linear statistics for the multivariate normal. One generates an
unconditional field that includes the field values at the
observations. From this realization one forms a synthetic data set
and uses LKrig to predict the remaining field based on the synthetic
observations. The difference between the predicted field and the
realization (i.e. the true field) is a draw from the conditional
distribution with the right covariance matrix. Adding the conditional
mean to this result one obtains a draw from the full conditional
distribution. This algorithm can also be interpreted as a variant on
the bootstrap to determine the estimator uncertainty. The fixed part
of the model is also handled correctly in this algorithm. See the
commented source for LKrig.sim.conditional
for the details of
this algorithm.
simConditionalDraw is low level function that is called to generate each ensemble member i.e. each draw from the conditional distribution. The large number of arguments is to avoid recomputing many common elements during the loop in generating these draws. In particular passing the basis function matrices avoid having to recompute the normalization at each step, often an intensive computation for a large grid.
LKrig.sim: A matrix with dimensions of nrow(x1)
by
M
of simulated values at the locations x1
.
LKrig.sim.conditional: A list with the components.
The locations where the simulated field(s) are evaluated.
The conditional mean at the xgrid locations.
A matrix with dimensions of nrow(x.grid)
by
M
with each column being an independent draw from the
conditional distribution.
Doug Nychka
LKrig, mKrig, Krig, fastTps, Wendland
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  # Load ozone data set
data(ozone2)
x<ozone2$lon.lat
y< ozone2$y[16,]
# Find location that are not 'NA'.
# (LKrig is not set up to handle missing observations.)
good < !is.na( y)
x< x[good,]
y< y[good]
LKinfo< LKrigSetup( x,NC=20,nlevel=1, alpha=1, lambda= .3 , a.wght=5)
# BTW lambda is close to MLE
# Simulating this LKrig process
# simulate 4 realizations of process and plot them
# (these have unit marginal variance)
xg< make.surface.grid(list( x=seq( 87,83,,40), y=seq(36.5, 44.5,,40)))
out< LKrig.sim(xg, LKinfo,M=4)
## Not run:
set.panel(2,2)
for( k in 1:4){
image.plot( as.surface( xg, out[,k]), axes=FALSE) }
## End(Not run)
obj< LKrig(x,y,LKinfo=LKinfo)
O3.cond.sim< LKrig.sim.conditional( obj, M=3,nx=40,ny=40)
## Not run:
set.panel( 2,2)
zr< range( c( O3.cond.sim$draw, O3.cond.sim$ghat), na.rm=TRUE)
coltab< tim.colors()
image.plot( as.surface( O3.cond.sim$x.grid, O3.cond.sim$ghat), zlim=zr)
title("Conditional mean")
US( add=TRUE)
for( k in 1:3){
image( as.surface( O3.cond.sim$x.grid, O3.cond.sim$g.draw[,k]),
zlim=zr, col=coltab)
points( obj$x, cex=.5)
US( add=TRUE)
}
set.panel()
## End(Not run)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs in the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.