Learn R Programming

SpatioTemporal (version 0.9.2)

make.sigma.nu: Crete (Cross)-Covariance Matrices for the Residual Field

Description

Creates covariance and cross-covariance matrices for the space-time residual nu field.

Usage

make.sigma.nu(sill, nugget, range, block.sizes, loc.index, dists)

make.sigma.nu.cross.cov(sill, nugget, range, loc.ind1, loc.ind2 = loc.ind1, loc.ind2.to.1 = 1:max(loc.ind2), T1, T2 = T1, dists)

Arguments

sill, nugget, range
Sill, nugget, and range parameters for the exponential covariance function.
block.sizes
A vector of containing the size(s) of each of the diagonal blocks, usually mesa.data.model$nt.
loc.index, loc.ind1, loc.ind2
Vectors indicating the location of each element in the covariance matrix, used to index the dist-matrix to determine the distance between locations, usually mesa.data.model$obs$idx.
dists
Distance matrix giving the distances between the (observed) locations.
loc.ind2.to.1
A vector that translates locations in loc.ind2 to locations in loc.ind1; used to determine if points are collocated.
T1, T2
Vectors with the observation times of each space-time point; used to determine if observtations are coincidental, usually mesa.data.model$obs$date.

Value

  • Returns the block-diagonal covariance or cross-covariance matrix for the spatio-temporal residual nu field.

encoding

latin1

See Also

make.sigma.B.full, make.sigma.B

This function is called by loglike.

Examples

Run this code
##First create some random locations
x <- rnorm(5)
y <- rnorm(5)

##compute distance matrix
D <- as.matrix(dist( cbind(x,y) ))

#a vector of locations
I <- c(1,2,3,1,4,4,3,2,1,1)
T <- c(1,1,1,2,2,3,3,3,3,4)

##create a block diagonal matrix consisting of four parts with
##exponential covariance using same sill, range, and nugget, but
##different locations in each block.
sigma.nu <- make.sigma.nu(sill=2, nugget=.1, range=.4,
    block.sizes=c(3,2,4,1), dists=D, loc.index=I)
print(sigma.nu)

sigma.nu.c <- make.sigma.nu.cross.cov(sill=2, nugget=.1, range=.4,
     loc.ind1=I, loc.ind2=I[7:10], T1=T, T2=T[7:10], dists=D)
print(sigma.nu.c)
##compare the cross-covariance with the relevant part of sigma.nu
range(sigma.nu.c-sigma.nu[,7:10])
if( abs(max(sigma.nu.c-sigma.nu[,7:10])) > 1e-10 ){
  stop("make.sigma.nu.cross.cov 1: Results not equal")
}
##an alternative showing the use of loc.ind2.to.1
sigma.nu.c <- make.sigma.nu.cross.cov(sill=2, nugget=.1, range=.4,
     loc.ind1=I, loc.ind2=1:2, loc.ind2.to.1=4:3,
     T1=T, T2=c(3,3), dists=D[,4:3])
print(sigma.nu.c)
##compare the cross-covariance with the relevant part of sigma.nu
range(sigma.nu.c-sigma.nu[,6:7])
if( abs(max(sigma.nu.c-sigma.nu[,6:7])) > 1e-10 ){
  stop("make.sigma.nu.cross.cov 1: Results not equal")
}

Run the code above in your browser using DataLab