sk_corr_mat | R Documentation |
The i,jth value of the returned correlation matrix is the marginal correlation between
the ith and jth points in a regularly spaced sequence of n
1-dimensional (1D) points,
given the correlation model with parameters defined in list pars
.
sk_corr_mat(pars, n, gres = 1, i = seq(n), j = seq(n))
pars |
list of kernel parameters 'k' and 'kp' (see |
n |
positive integer, the number of points on the 1D line |
gres |
positive numeric, the distance between adjacent grid lines |
i |
vector, a subset of |
j |
vector, a subset of |
This matrix is symmetric and Toeplitz as a result of the assumption of stationarity of the random field and regularity of the grid.
The distance between adjacent points is specified by gres
. Subsets of
the correlation matrix can be requested by specifying i
and/or j
(default
behaviour is to include all).
Like sk_corr
, this function is for computing 1D components of a 2D process.
The product of two matrices returned by sk_corr_mat
is the correlation
matrix for a spatially separable process (see examples).
the n x n correlation matrix, or its subset as specified in i
, j
Other internal variance-related functions:
sk_corr()
,
sk_toep_mult()
,
sk_var_mult()
# define test distances, grid, and example kernel
n_test = 10
g_example = sk(n_test)
pars = sk_pars(g_example, c('mat', 'gau'))
# compute the correlation matrices and their kronecker product
cx = sk_corr_mat(pars[['x']], n=n_test)
cy = sk_corr_mat(pars[['y']], n=n_test)
cxy = kronecker(cx, cy)
# sk_var can return these two matrices in a list
cxy_list = sk_var(g_example, pars, sep=TRUE)
max(abs( cxy_list[['y']] - cy ))
max(abs( cxy_list[['x']] - cx ))
# ... or it can compute the full covariance matrix for model pars (default)
var_matrix = sk_var(g_example, pars, sep=FALSE)
var_matrix_compare = (pars$psill*cxy) + diag(pars$eps, n_test^2)
max(abs( var_matrix - var_matrix_compare ))
# extract a subgrid without computing the whole thing
cx_sub = sk_corr_mat(pars[['x']], n=n_test, i=2:4, j=2:4)
cx_sub - cx[2:4, 2:4]
# gres scales distances. Increasing gres causes correlations to decrease
cx_long = sk_corr_mat(pars[['x']], n=n_test, gres=2*g_example$gres)
cx_long < cx
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.