Learn R Programming

SpatioTemporal (version 1.1.2)

removeSTcovarMean: Mean-Centre the Spatio-Temporal Covariate

Description

Removes the temporal mean at each location for the spatio-temporal covariares. The means are added to the covar field in the returned object and can be used as geographic covariates.

Usage

removeSTcovarMean(STdata)

Arguments

STdata
A STdata object, see mesa.data.

Value

  • Returns a modfied version of the input, where the spatio-temporal covariates have been expanded to include covariates where the site by site temporal average has been removed. The averages are seen as geographic covariates and added to STdata$covars.

See Also

Other STdata functions: createDataMatrix, createSTdata, createSTmodel, c.STmodel, detrendSTdata, updateSTdataTrend

Examples

Run this code
##load data
data(mesa.data)

mesa.data.mean0 <- removeSTcovarMean(mesa.data)

##compare the data structures
##geographic covariates
summary(mesa.data$covars)
summary(mesa.data.mean0$covars)

##mean of the spatio-temporal covariate, note that the new
##contains both mean-zero and original
cbind(colMeans(mesa.data$SpatioTemporal),
      colMeans(mesa.data.mean0$SpatioTemporal))

##mean of the spatio-temporal covariate
##compared to the added mean covariate
plot(mesa.data.mean0$covars$mean.lax.conc.1500,
     colMeans(mesa.data$SpatioTemporal))
if( max(abs(colMeans(mesa.data.mean0$SpatioTemporal[,,2]))) > 1e-10 ){
    stop("remove.ST.mean 1: mean(centred ST) != 0")
  }
  if( max(abs(mesa.data.mean0$covars$mean.lax.conc.1500 - 
              colMeans(mesa.data$SpatioTemporal))) > 1e-10 ){
    stop("remove.ST.mean 2: extracted mean != mean(ST)")
  }

Run the code above in your browser using DataLab