# CovMat: Covariance Matrix for Spatial Models In RcppCensSpatial: Spatial Estimation and Prediction for Censored/Missing Responses

## Description

This function computes the spatial variance-covariance matrix considering exponential, gaussian, matern, or power exponential correlation functions.

## Usage

 `1` ```CovMat(phi, tau2, sigma2, dist, type = "exponential", kappa = 0) ```

## Arguments

 `phi` spatial scaling parameter. `tau2` nugget effect parameter. `sigma2` partial sill parameter. `dist` n x n distance matrix. `type` type of spatial correlation function: '`exponential`', '`gaussian`', '`matern`', and '`pow.exp`' for exponential, gaussian, matern, and power exponential, respectively. `kappa` parameter for all spatial correlation functions. For exponential and gaussian κ=0, for power exponential 0 < κ <= 2, and for matern correlation function κ > 0.

## Details

The spatial covariance matrix is given by

Σ = [Cov(s_i, s_j )] = σ^2 R(φ) + τ^2 I_n,

where σ^2 > 0 is the partial sill, φ > 0 is the spatial scaling parameter, τ^2 is known as the nugget effect in the geostatistical framework, R(φ) is the n x n correlation matrix computed from the correlation function, and I_n is the n x n identity matrix.

The spatial correlation functions available are:

Exponential:

Corr(d) = exp(-d/φ),

Gaussian:

Corr(d) = exp(-(d/φ)^2),

Matern:

Corr(d) = 1/(2^(κ-1)Γ(κ))(d/φ)^κ K_κ(d/φ),

Power exponential:

Corr(d) = exp(-(d/φ)^κ),

where d >= 0 is the Euclidean distance between two observations, Γ(.) is the gamma function, κ is the smoothness parameter, and K_κ(.) is the modified Bessel function of the second kind of order κ.

## Value

The function returns the n x n spatial covariance matrix.

## Author(s)

Katherine L. Valeriano, Alejandro Ordonez, Christian E. Galarza and Larissa A. Matos.

`EM.sclm`, `SAEM.sclm`, `MCEM.sclm`, `dist2Dmatrix`
 ```1 2 3 4 5 6 7 8``` ```# Initial parameter values phi = 5; tau2 = 0.80; sigma2 = 2 n = 20 set.seed(1000) x = round(runif(n,0,10), 5) # X coordinate y = round(runif(n,0,10), 5) # Y coordinate Ms = dist2Dmatrix(cbind(x, y)) Cov = CovMat(phi, tau2, sigma2, Ms, "exponential", 0) ```