SpatioTemporal (version 1.1.9.1)

calc.FX: Compute Matrix Product Bewteen Temporal Trends and a LUR components

Description

Computes the matrix products between a sparse matrix F containing the temporal trends and a list of land-use-regression components.

See the examples for details.

Usage

calc.FX(F, LUR, 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.

LUR

A list of matrices, usually mesa.model$X. Each matrix in the list should have the same number of rows, but the number of columns may vary.

loc.ind

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

Value

Returns a matrix

See Also

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

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

Examples

Run this code
# NOT RUN {
##This starts with a couple of simple examples, more elaborate examples
##with real data can be found further down.
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)
##a list of time points for each location/observation
T <- c(rep(1:3,each=3),4,4,5,5)
##create a list of matrices
X <- list(matrix(1,3,1), matrix(runif(6),3,2))

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

##compute F %*% X
FX <- calc.FX(F, X, idx)

##alternatievly this can be computed as block matrix
##times each (expanded) temporal trend
Fexp <- expandF(F, idx)
FX.alt <- Fexp %*% bdiag(X)

##compare results
# }
# NOT RUN {

##some examples using real data
data(mesa.model)

##Some information about the size(s) of the model.
dim <- loglikeSTdim(mesa.model)

##compute F %*% X
FX <- calc.FX(mesa.model$F, mesa.model$LUR, mesa.model$obs$idx)

##The resulting matrix is
##(number of time points) - by - (number of land use covariates)
##where the number of land use covariates are computed over all the
##two + intercept temporal trends.
##Each column contains the temporal trend for the observations
##multiplied by the corresponding LUR-covariate
par(mfrow=c(3,1))
plot(FX[,2])
points(mesa.model$LUR[[1]][mesa.model$obs$idx,2] * mesa.model$F[,1], col=2, pch=3)

plot(FX[,dim$p[1]+1])
points(mesa.model$LUR[[2]][mesa.model$obs$idx,1] *
       mesa.model$F[,2], col=2, pch=3)

plot(FX[,dim$p[1]+dim$p[2]+2])
points(mesa.model$LUR[[3]][mesa.model$obs$idx,2] *
       mesa.model$F[,3], col=2, pch=3)

##If the regression parameters, alpha, are known (or estimated)
##The intercept part of the model is given by FX %*% alpha
# }

Run the code above in your browser using DataLab