Learn R Programming

SpatioTemporal (version 0.9.2)

make.sigma.B: Create Covariance Matrix for the beta-Fields

Description

Creates the block diagonal covariance matrix for the beta fields.

Usage

make.sigma.B(sill, range, dists)

Arguments

sill, range
Vectors with the sill and range parameters for each of the block matrices.
dists
Distance matrix giving the distances between the (observed) locations.

Value

  • Returns a block diagonal covariance matrix with one block for each of the elements in the vectors sill and range. Each block contains the exponential covariance matrix for the elements in the dists matrix.

encoding

latin1

See Also

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

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) ))

##create a block diagonal matrix consisting of three parts with
##different sill and range (nugget=0) and exponential covariance
##function
sill <- c(2,1,3)
range <- c(.3,1,.5)
make.sigma.B(sill, range, D)
B <- make.sigma.B(sill, range, D)
B.alt <- matrix(0,length(sill)*dim(D)[1],length(sill)*dim(D)[1])
for(i in 1:length(sill)){
  B.alt[((i-1)*dim(D)[1]+1):(i*dim(D)[1]),((i-1)*dim(D)[1]+1):(i*dim(D)[1])] <- sill[i]*exp(-D/range[i])
}
if( abs(max(B-B.alt)) > 1e-10){
  stop("make.sigma.B: Results not equal")
}

Run the code above in your browser using DataLab