detrendSTdata {SpatioTemporal} | R Documentation |
STdata
ObjectRemoves an estimated time-trend from the observations in a
STdata
object. Returns a modifed STdata
object with no trend;
the new object can be used to fit a simpler model.
detrendSTdata(STdata, region = NULL, method = lm, ...)
STdata |
A |
region |
Vector of the same length and order as |
method |
Method for fitting the trend (set to |
... |
Additional parameters passed to |
Sometimes there is no apparent spatial structure to the time-trend amplitude, or there is not enough identifiability in the data to properly model the structure. In that case, it is possible, at least as a sensitivity analysis, to de-trend the observations and run a model with a spatial field for the intercept only (apart from the spatio-temporal residual field).
detrendSTdata
will remove the trends from the observations, using
STdata$trend
. 'method' is applied as
metod(STdata$obs$obs ~ F,...)
where F
is the temporal trend from STdata$trend
for each
observation; or as
metod(STdata$obs$obs ~ F*obs.region,...)
where
obs.region = factor(region[ match(STdata$obs$ID, STdata$covars$ID)])
.
allowing for different trends in different region (i.e. interaction between
the time trend(s) and region identifiers).
predict( method(...) )
is then subtracted from
STdata$obs$obs
, detrending the data.
Returns a modfied version of the input, with detrended observations and some changes:
STdata$obs |
Has an additional column, |
STdata$trend |
Is reduced to only the |
STdata$old.trend |
The previous |
STdata$fit.trend |
The result of |
Assaf P. Oron and Johan Lindstrom
Other STdata functions: c.STmodel
,
createDataMatrix
,
createSTdata
, createSTmodel
,
estimateBetaFields
,
removeSTcovarMean
,
updateTrend.STdata
##load the data data(mesa.data.raw) ##and create STdata-object mesa.data <- createSTdata(mesa.data.raw$obs, mesa.data.raw$X, n.basis=2, SpatioTemporal=mesa.data.raw["lax.conc.1500"]) ##plot time-series for the first site, par(mfrow=c(3,2),mar=c(2.5,2.5,3,1)) plot(mesa.data, "obs", ID=1) ##And combined for all sites plot(mesa.data, "loc.obs", legend.loc="bottomleft") ##attempt to detrend mesa.data.detrend <- detrendSTdata(mesa.data) ##examine object, note the trends mesa.data.detrend ##plot detrended time-series for the first site, plot(mesa.data.detrend, "obs", ID=1) ##And combined for all sites plot(mesa.data.detrend, "loc.obs", legend.loc="bottomleft") ##use different detrending for different types of locations mesa.data.detrend2 <- detrendSTdata(mesa.data, region=mesa.data$covars$type) ##examine object, note the trends mesa.data.detrend2 ##plot for the first site, plot(mesa.data.detrend2, "obs", ID=1) plot(mesa.data.detrend2, "loc.obs", legend.loc="bottomleft") ##compare the two fitted and removed trends print(mesa.data.detrend$fit.trend) print(mesa.data.detrend2$fit.trend)