LKrigInternal: Internal functions for LatticeKrig package.

Description Usage Arguments Details Value Author(s) References See Also


Some internal functions for LKrig that estimate the coefficients of the basis functions and compute the likelihood.


createLKrigObject(x, y, weights = NULL, Z, X, U, LKinfo, verbose = FALSE)
LKrigMakewU(object, verbose = FALSE)
LKrigMakewX(object, verbose = FALSE)
LKrig.coef( GCholesky, wX, wU, wy, lambda, verbose = FALSE)
LKrig.lnPlike( GCholesky, Q, quad.form, nObs, nReps, weights, LKinfo)
LKrig.lnPlikeOLD(Mc, Q, wy, residuals, weights, LKinfo)
LKrig.traceA(GCholesky, wX, wU, lambda, weights, NtrA, iseed = NA)
LKrigUnrollZGrid( grid.list, ZGrid=NULL)



The grid for evaluating surface


SPAM cholesky decomposition of the "G" matrix.


Random seed used to generate the Monte Carlo samples. Keep the same to compare results with mKrig and also for multiple values of lambda.


The ratio of the nugget variance (sigma squared) to the parameter controlling the marginal variance of the process (called rho in fields).


The LKinfo object. See help(LKinfo)


Cholesky decomposition of regression matrix.


Number of Monte Carlo samples to estimate trace. Default is 20 in LKrig.


Number of observations.


Number of replicate fields.


The LKrig object.


Precision matrix for coefficients.


The part of the log likelihood that is a quadratic form. (This is typically found in LKrig.coef.)


Residuals from fitting spatial process.


The matrix that maps the d.coef coefficients of the fixed component (typically a low order polynomial) part of the observation model.


If TRUE intermediate debugging information is printed.


A vector that is proportional to the reciprocal variances of the errors. I.e. errors are assumed to be uncorrelated with variances sigma^2/weights.


Weighted U matrix the fixed part of the model.


Weighted X matrix (in spam format) related to nonparametric (stochastic) part of model. Here weights refer to the sqrt(weights).

NOTE: predicted values are U%*%d.coef + X%*%c.coef


Weighted observations.


The matrix that maps the c.coef coefficients into the nonparametric component (spatial process) part of the observation model.


Matrix of spatial locations passed to LKrig.


Vector or matrix of observations passed to LKrig.


A matrix of covariates.


A list or array with the covariates on the same grid as that specified by the grid.list argument.


The LatticeKrig article can be used as a reference for the matrix computations and the G matrix from those formulas figures prominently. The GCholesky object in these functions is the cholesky decompoistion of this matrix. For compatibility with older version of this package this object may also be named as Mc ( Cholesky of the M matrix) but the user should not identify this M with that in the article. Ideally all coding using Mc should be changed to GCholesky.

createLKrigObject Based on the arguments passed into LKrig forms the prototype LKrig object. This object is added to as one computes additional steps in the LKrig function.

LKrigMakewU and LKrigMakewX construct the weighted U and X matrices from what is passed. In the case of observations that are point locations wU is found the weights and using the fixedFunction and wX is found from the weights and the multiresolution basis functions. Note that X and wX are assumed to be in spam sparse matrix format.

LKrig.coef and LKrig.lnPlike are two low level functions to find the basis function coefficients and to evaluate the likelihood. The coefficients (c.mKrig) are also found because they provide for shortcut formulas for the standard errors and MLE estimates. These coefficients are identical to the basis coefficients (c.coef) found for usual Kriging in the mKrig function. LKrig.lnPlike also finds the profile MLE of sigma and rho given a fixed value for lambda (and alpha and a.wght). See the source for LKrig and also MLE.LKrig to see how these functions are used.

LKrig.traceA finds an estimate of the effective degrees of freedom of the smoothing matrix based a simple Monte Carlo scheme. The smoothing matrix A is the matrix for fixed covariance parameters so that y.hat = A y, where y.hat are the predicted values at the data locations. trace(A) is the effective degrees of freedom. If e are iid N(0,1) then the expected value of t(e)% * % A % * % e is equal to the trace of A. This is the basis for estimating the trace and the standard error for this estimate is based on NtrA independent samples.

dfind2d is a fast FORTRAN subroutine to find nearest neighbors within a fixed distance and is called by Wendland.basis. The function dfind3d is currently not used but is intended for future use to determine chordal distance between points on a sphere or cylinder.

LKrigDefaultFixedFunction Is called to construct the fixed part of the spatial model. The default is a polynomial of degree (m-1).



a list with components d.coef the coefficients of the spatial dirft and for covariates (Z) and c.coef the basis function coefficients. The logical vector ind.drift from the LKrig object indicates with components of d.coef are associated with the polynomial spatial drift and which are other fixed spatial covariates.


has the components:


the log likelihood profiled for lambda, alpha and a.wght


the MLE of rho given lambda, alpha and a.wght


the MLE of sigma given lambda, alpha and a.wght


the quadratic form in the exponent of the multivariate normal likelihood


the log determinant of the covariance matrix in the likelihood


A matrix with dimension nrow(x) and columns of the number of polynomial terms and the number of columns of Z if given.


Doug Nychka


Nychka, D., Bandyopadhyay, S., Hammerling, D., Lindgren, F., & Sain, S. (2015). A multiresolution gaussian process model for the analysis of large spatial datasets.Journal of Computational and Graphical Statistics, 24(2), 579-599.

See Also

LKrig, LKrig.basis

Search within the LatticeKrig package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.