Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stinteraction

subtract marginal (spatial and temporal) means from observations


Description

subtract marginal (spatial and temporal) means from observations

Usage

stInteraction(x, ...)

Arguments

x

object of class STFDF

...

arguments passed to rowMeans, colMeans and mean, such as na.rm=TRUE

Value

object of class STFDF with each attribute replaced by its residual, computed by $y_ij=x_ij-m_.jmi./m$ with $m$ the grand mean, $m_.j$ the temporal mean, $m_i.$ the spatial mean and $m$ the grand mean.

Examples

if (require(gstat)) {
library(sp)
data(wind)
wind.loc$y = as.numeric(char2dms(as.character(wind.loc[["Latitude"]])))
wind.loc$x = as.numeric(char2dms(as.character(wind.loc[["Longitude"]])))
coordinates(wind.loc) = ~x+y
proj4string(wind.loc) = "+proj=longlat +datum=WGS84"
# match station order to names in wide table:
stations = 4:15
wind.loc = wind.loc[match(names(wind[stations]), wind.loc$Code),]
row.names(wind.loc) = wind.loc$Station
wind$time = ISOdate(wind$year+1900, wind$month, wind$day, 0)
space = list(values = names(wind)[stations])
wind.st = stConstruct(wind[stations], space, wind$time, SpatialObj = wind.loc)

wind.sti = stInteraction(wind.st)
# temporal means for any station should be zero:
c(mean(wind.sti[3,]),
# spatial mean for each time step should be zero:
mean(wind.sti[,5][[1]]))
}

spacetime

Classes and Methods for Spatio-Temporal Data

v1.2-4
GPL (>= 2)
Authors
Edzer Pebesma [aut, cre] (<https://orcid.org/0000-0001-8049-7069>), Benedikt Graeler [ctb], Tom Gottfried [ctb], Robert J. Hijmans [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.