Learn R Programming

SpatioTemporal (version 1.1.9.1)

calc.tFXF: Compute Quadratic Form Bewteen Temporal Trends and Sigma nu

Description

Computes the quadratic form between a sparse matrix F containing the temporal trends and the covariance matrix for the residual fields (Sigma_nu)

See the examples for details.

Usage

calc.tFXF(F, mat, loc.ind, n.blocks = 1,
  block.sizes = rep(dim(mat)[1]/n.blocks, n.blocks), n.loc = max(loc.ind))

Arguments

F

A (number of obs.) - by - (number of temporal trends) matrix containing the temporal trends. Usually mesa.model$F, where mesa.model is obtained from createSTmodel.

mat

A block diagonal, square matrix.

loc.ind

A vector indicating which location each row in F corresponds to, usually mesa.model$obs$idx.

n.blocks

Number of diagonal blocks in mat (or R). Defaults to 1 (i.e. a full matrix) if neither n.blocks nor block.sizes given, o.w. it defaults to length(block.sizes)).

block.sizes

A vector of length n.blocks with the size of each of the diagonal blocks. If not given it will assume equal size blocks.

n.loc

Number of locations.

Value

Returns a square matrix with side dim(F)[2]*n.loc

See Also

Other block matrix functions: blockMult, calc.FXtF2, calc.FX, calc.mu.B, calc.tFX, makeCholBlock, makeSigmaB, makeSigmaNu

Other temporal trend functions: calc.FXtF2, calc.FX, calc.tFX, expandF

Examples

Run this code
# NOT RUN {
##create a trend
trend <- cbind(1:5,sin(1:5))
##an index of locations
idx <- c(rep(1:3,3),1:2,2:3)
##a list of time points for each location/observation
T <- c(rep(1:3,each=3),4,4,5,5)

##expand the F matrix to match the locations/times in idx/T.
F <- trend[T,]

##create a covariance matrix for locations and each of 
C <- makeSigmaNu(c(1,1), as.matrix(dist(1:max(idx))),
            blocks1=c(3,3,3,2,2), ind1=idx)

##compute F' %*% C %*% F
tFmatF <- calc.tFXF(F, C, idx, block.sizes = c(3,3,3,2,2),
                    n.blocks = 5)
##which is equivalent of
tFmatF.alt <- calc.tFX(F, t(calc.tFX(F, C, idx)), idx)

range(tFmatF-tFmatF.alt)
# }

Run the code above in your browser using DataLab