Learn R Programming

SpatioTemporal (version 1.1.2)

expandF: Expand F

Description

Expands the temporal trends in F to a full matrix (with lots of zeros). Mainly used for testing, and illustration in examples.

Usage

expandF(F, loc.ind, n.loc = max(loc.ind), sparse = TRUE)

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 f
loc.ind
A vector indicating which location each row in F corresponds to, usually mesa.model$obs$idx.
n.loc
Number of locations.
sparse
Should the returned matrix be sparse (uses the Matrix-package, see sparseMatrix)

Value

  • Returns the expanded F, a dim(F)[1]-by-n.loc*dim(F)[2] matrix

See Also

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

Examples

Run this code
##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,]

##compute the expanded matrix
expandF(F, idx)

##compute the expanded matrix, assuming additional locations
expandF(F, idx, 5)

##or as a full matrix
expandF(F, idx, 5, sparse=FALSE)

if( abs(max(expandF(F, idx)-expandF(F, idx, sparse=FALSE)))>1e-13 ){
    stop("Error in 'expandF', full not equal")
  }
  if( abs(max(expandF(F, idx, 5)-expandF(F, idx, 5, sparse=FALSE)))>1e-13 ){
    stop("Error in 'expandF', expanded full not equal")
  }

Run the code above in your browser using DataLab