Learn R Programming

SpatioTemporal (version 1.1.2)

createSTdata: Construct STdata Object

Description

Creates a STdata object that can be used as input for createSTmodel. Names and dates are derived from the input data, either using predefined fields or rownames / colnames; for details see the sub-functions linked under the relevant Arguments.

Usage

createSTdata(obs, covars, SpatioTemporal = NULL,
    transform.obs = function(x) {     return(x) },
    mean.0.ST = FALSE, n.basis = NULL, extra.dates = NULL,
    ..., detrend = FALSE, region = NULL, method = NULL)

Arguments

obs
Either a data.frame with fields obs, date, ID giving obsevations, time-points and location names; or a matrix, e.g. output from createDataMatrix.
covars
matrix/data.frame of covariates; should include both geographic covariates and coordinates of all locations, see stCheckCovars.
SpatioTemporal
possible spatio-temporal covariate, see stCheckSTcovars.
transform.obs
function to apply to the observations, defaults to an identity transform. Possible options are log, sqrt, and
mean.0.ST
Call removeSTcovarMean to produce a mean-zero spatio-temporal covariate?
n.basis
Number of temporal components in the smooth trends computed by updateSTdataTrend, if NULL no trend is computed (implies only a constant).
extra.dates
Additional dates for which smooth trends should be computed, used by updateSTdataTrend. If n.basis=NULL this will force n.basis=0; since the dates are stored in the trend..
...
Additional parameters passed to updateSTdataTrend.
detrend
Use detrendSTdata to remove a termporal trend from the observations; requires n.basis!=NULL.
region,method
Additional parameters passed to detrendSTdata.

Value

  • A STdata object, see mesa.data for an example.

See Also

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

Other STdata methods: plot.STdata, plot.STmodel, print.STdata, print.summary.STdata, summary.STdata

Examples

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

##extract observations and covariates
obs <- mesa.data.raw$obs
covars <- mesa.data.raw$X

##list with the spatio-temporal covariates
ST.list <- list(lax.conc.1500=mesa.data.raw$lax.conc.1500)

##create STdata object
mesa.data <- createSTdata(obs, covars, SpatioTemporal=ST.list)
print(mesa.data)

##create object with mean 0 spatio temporal covariate
mesa.data.2 <- createSTdata(obs, covars, SpatioTemporal=ST.list,
                            mean.0.ST=TRUE)
print(mesa.data.2)

##create object with mean 0 spatio temporal covariate, and
##trend with two components, and additional dates (every seventh day)
extra.dates <- seq(min(as.Date(rownames(obs))),
                   max(as.Date(rownames(obs))), by=7)
mesa.data.3 <- createSTdata(obs, covars, n.basis=2, extra.dates=extra.dates)
print(mesa.data.3)

Run the code above in your browser using DataLab