Description Usage Arguments Value Author(s) See Also Examples
Computes the quadratic form between a sparse matrix F
containing the
temporal trends and the covariance matrix for the beta fields (Sigma_B). Or
possibly the product between two different F
's and a cross-covariance
matrix.
See the examples for details.
1 | calc.FXtF2(F, mat, loc.ind, F2 = F, loc.ind2 = loc.ind)
|
F, F2 |
(number of obs.) - by - (number of temporal trends) matrices
containing the temporal trends. Usually |
mat |
A block diagonal, with equal size blocks. The
number of blocks need to equal |
loc.ind, loc.ind2 |
A vector indicating which location each row in |
Returns a square matrix with side dim(F)[1]
Johan Lindstrom and Adam Szpiro
Other block matrix functions: blockMult
,
calc.FX
, calc.mu.B
,
calc.tFXF
, calc.tFX
,
makeCholBlock
, makeSigmaB
,
makeSigmaNu
Other temporal trend functions: calc.FX
,
calc.tFXF
, calc.tFX
,
expandF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | require(Matrix)
##create a trend
trend <- cbind(1:5,sin(1:5))
##an index of locations
idx <- c(rep(1:3,3),1:2,2:3)
idx2 <- c(rep(1:2,3),2,2)
##a list of time points for each location/observation
T <- c(rep(1:3,each=3),4,4,5,5)
T2 <- c(rep(1:3,each=2),4,5)
##expand the F matrix to match the locations/times in idx/T.
F <- trend[T,]
F2 <- trend[T2,]
##first column gives time and second location for each observation
cbind(T, idx)
##...and for the second set
cbind(T2, idx2)
##create a cross covariance matrix
C <- makeSigmaB(list(c(1,1),c(1,.5)), crossDist(1:max(idx),1:max(idx2)))
##compute F %*% X %*% F2'
FXtF2 <- calc.FXtF2(F, C, loc.ind=idx, F2=F2, loc.ind2=idx2)
##which is equivalent to
FXtF2.alt <- expandF(F, idx) %*% C %*% t( expandF(F2, idx2) )
range(FXtF2 - FXtF2.alt)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.