Learn R Programming

SpatioTemporal (version 0.9.2)

create.data.model: Creates the mesa.data.model structure; selection of model covariates

Description

Creates the auxiliary data structure mesa.data.model; the structure holds information regarding which geographic and spatio-temporal covariates to use for model fitting.

Usage

create.data.model(mesa.data, LUR = NA, ST.Ind = NA,
    strip = TRUE, strip.loc = strip, strip.time = strip)

Arguments

mesa.data
Data structure holding observations, observation locations, smooth temporal trends, geographic covariates and spatio-temporal covariates. See mesa.data.
LUR
A vector or list of vectors indicating which geographic covariates to use. LUR = NA uses all available covariates are used for all the temporal trends; a vector of integers or characters (names) specifies covariates to use for all
ST.Ind
A vector indicating which spatio-temporal covariates to use. ST.Ind = NA uses all spatio-temporal covariates, ST.Ind = NULL uses no spatio-temporal covariates. See further
strip, strip.loc, strip.time
Drop times and/or locations without observations, strip is a shortcut for setting both strip.loc and strip.time.

If strip.loc=TRUE all locations that do not have any observations are dr

Value

encoding

latin1

Warning

The structure mesa.data.model should always be created by running create.data.model on a mesa.data structure.

Details

The function creates the auxiliary data structure mesa.data.model which is used in model fitting and prediction, see fit.mesa.model, cond.expectation, and run.MCMC.

The resulting structure holds information regarding which geographic and spatio-temporal covariates to use for model fitting, as well as a number of precomputed fields that speed up log-likelihood evaluations.

For any observations that occur at times (dates) not in mesa.data$trend$date the smooth temporal trends are interpolated to these times using spline.

When selecting geographic covariates the code allows for different covariates for different temporal trends. LUR = NA gives all covariates are used for all the temporal trends. If a vector of integers or characters (names) is used to specify covariates then these covariates will be used for all the temporal trends (e.g. LUR = c(1,2,3)). If LUR instead is given as a list of vectors this allows for different covariates for each temporal trend. In this case the list needs to contain one vector for each of the temporal trends, starting with coefficients for the intercept, e.g. LUR = list(c(1,2,3),c(1,2),c(2)). LUR = NULL gives only an intercept, no covariates.

The option in strip, strip.loc, and strip.time to drop locations and times without observations can be used to reduce the dataset, thereby (drastically) speeding up the optimisation. To obtain predictions and simulations at the unobserved locations the original mesa.data structure can be passed to cond.expectation and simulateMesaData.

See Also

Used to create mesa.data.model from mesa.data. Uses default.LUR.list, default.ST.list, construct.LUR.basis, and construct.ST.basis to extract covariates from mesa.data. For optimization functions see loglike, loglike.var.names, run.MCMC, fit.mesa.model, and cond.expectation.

For other data functions, see mesa.data, mesa.data.raw, create.data.matrix, construct.LUR.basis and default.LUR.list.

Examples

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

##create a mesa.data.model with all covariates
model.all <- create.data.model(mesa.data)

##no covariates
model.none <- create.data.model(mesa.data, LUR=NULL, ST.Ind=NULL)

##with different covariates for the different temporal trends
model.diff <- create.data.model(mesa.data, LUR=list(c(1,4,5,6),5:6,5:6),
                                ST.Ind=NULL)

##with the same covariates for all temporal trends, calling by name
model.same <- create.data.model(mesa.data, LUR=c("log10.m.to.a1",
    "log10.m.to.road","km.to.coast","s2000.pop.div.10000"),
    ST.Ind="lax.conc.1500")

Run the code above in your browser using DataLab