CovarianceUpper.Rd
Evaluates the covariance over the upper triangle of a distance matrix
rather than over the entire matrix to reduce computation time. Note
that the chol
function only requires the upper triangle of
the covariance matrix to perform the Cholesky decomposition.
ExponentialUpper(distMat, range = 1, alpha = 1/range, theta = NULL)
The distance matrix to evaluate the covariance over.
Range parameter default is one. Note that the scale can also be specified through the "aRange" scaling argument used in fields covariance functions)
1/range
Also the range parameter.
The covariance matrix, where only the upper triangle is calculated.
set.seed(123)
#a distance matrix
coords = matrix(runif(10), ncol=2)
distMat = rdist(coords)
#compute covariance matrix, but only over the upper triangle
upperCov = ExponentialUpper(distMat, range=.1)
print(distMat)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.0000000 0.69540037 0.8555197 0.78132050 0.7715140
#> [2,] 0.6954004 0.00000000 0.5259413 0.09754322 0.1681197
#> [3,] 0.8555197 0.52594131 0.0000000 0.58393877 0.6873190
#> [4,] 0.7813205 0.09754322 0.5839388 0.00000000 0.1108665
#> [5,] 0.7715140 0.16811974 0.6873190 0.11086647 0.0000000
print(upperCov)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1 0.0009548048 0.0001925418 0.000404360 0.0004460228
#> [2,] 0 1.0000000000 0.0051983548 0.377029350 0.1861509438
#> [3,] 0 0.0000000000 1.0000000000 0.002910624 0.0010351697
#> [4,] 0 0.0000000000 0.0000000000 1.000000000 0.3299993164
#> [5,] 0 0.0000000000 0.0000000000 0.000000000 1.0000000000