Learn R Programming

SpatioTemporal (version 1.1.7)

createSTmodel: Construct STmodel Object

Description

Creates a STmodel object that can be for estimation and prediction. For details see the sub-functions linked under the relevant Arguments.

Usage

createSTmodel(STdata, LUR = NULL, ST = NULL,
    cov.beta = list(covf = "exp", nugget = FALSE),
    cov.nu = list(covf = "exp", nugget = TRUE, random.effect = FALSE),
    locations = list(coords = c("x", "y"), long.lat = NULL, coords.beta = NULL,
                     coords.nu = NULL, others = NULL),
    strip = FALSE, scale = FALSE, scale.covars = NULL)

Arguments

STdata

STdata object with observations, covariates, trends, etc; see createSTdata or mesa.data.raw for an example.

LUR

Specification of covariates for the beta-fields, see processLUR.

ST

Specification of spatio-temporal covariates, see processST.

cov.beta,cov.nu

Specification of the covariance functions, see updateCovf.

locations

Specification of the sites (both monitored and un-monitored), see processLocation.

strip

Should unobserved locations be dropped?

scale

Scale the covariates? If TRUE all non-factor covariates are scaled after the locations have been extracted but before constructing the covariate matrix for the beta-fields. (NOTE: If set to TRUE this scales the LUR.all elements to mean=0, sd=1).

scale.covars

list with elements mean and sd giving the mean and standard deviation to use when scaling the covariates. Computed from STdata$covars if not given.

Value

A STmodel object, see mesa.model for an example.

Details

The object holds observations, trends, geographic, and spatio-temporal covariates, as well as a number of precomputed fields that speed up log-likelihood evaluations. To improve performance the locations are also reorder so that observed locations come before unobserved.

See Also

Other STdata functions: c.STmodel, createDataMatrix, createSTdata, detrendSTdata, estimateBetaFields, removeSTcovarMean, updateSTdataTrend, updateTrend, updateTrend.STdata, updateTrend.STmodel

Other STmodel functions: createCV, createDataMatrix, dropObservations, estimateBetaFields, loglikeST, loglikeSTdim, loglikeSTnaive, predictNaive, processLocation, processLUR, processST, updateCovf, updateSTdataTrend, updateTrend, updateTrend.STdata, updateTrend.STmodel

Other STmodel methods: c.STmodel, estimate, estimate.STmodel, estimateCV, estimateCV.STmodel, MCMC, MCMC.STmodel, plot.STdata, plot.STmodel, predict.STmodel, predictCV, predictCV.STmodel, print.STmodel, print.summary.STmodel, qqnorm.predCVSTmodel, qqnorm.STdata, qqnorm.STmodel, scatterPlot.predCVSTmodel, scatterPlot.STdata, scatterPlot.STmodel, simulate.STmodel, summary.STmodel

Examples

Run this code
# NOT RUN {
##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"])

##define land-use covariates
LUR <-  list(~log10.m.to.a1+s2000.pop.div.10000+km.to.coast,
             ~km.to.coast, ~km.to.coast)
##and covariance model
cov.beta <- list(covf="exp", nugget=FALSE)
cov.nu <- list(covf="exp", nugget=TRUE, random.effect=FALSE)
##which locations to use
locations <- list(coords=c("x","y"), long.lat=c("long","lat"), others="type")

##create object
mesa.model <- createSTmodel(mesa.data, LUR=LUR, ST="lax.conc.1500",
                            cov.beta=cov.beta, cov.nu=cov.nu,
                            locations=locations)
print(mesa.model)
##This is the same as data(mesa.model)

##lets try some alternatives:
model.none <- createSTmodel(mesa.data, LUR=NULL, ST=NULL)
print(model.none)

##Specify LUR:s using numbers
names(mesa.data$covars)
model.diff <- createSTmodel(mesa.data, LUR=list(c(7,10,11,12),11:12,11:12),
                            ST=1)
print(model.diff)

##Same covariates for all temporal trends, calling by name
##but with different covariance models for each trend, and nugget that depends
##on monitor type
model.same <- createSTmodel(mesa.data, LUR=c("log10.m.to.a1", "log10.m.to.road",
                                         "km.to.coast","s2000.pop.div.10000"),
                            ST="lax.conc.1500", cov.nu=list(nugget="type"),
                            cov.beta=list(covf=c("exp","exp2","iid"),
                              nugget=c(FALSE, FALSE, TRUE)) )
print(model.same)
# }

Run the code above in your browser using DataLab