Learn R Programming

SpatioTemporal (version 1.1.7)

updateCovf: Update Covariance Functions in STmodel Objects

Description

Updates/sets the covariance functions for STmodel objects. Used by createSTmodel.

Usage

updateCovf(STmodel, cov.beta = STmodel$cov.beta,
    cov.nu = STmodel$cov.nu)

Arguments

STmodel

STmodel object with observations, covariates, trends, etc; see mesa.model.

cov.beta,cov.nu

Covariance specification for the beta- and nu-fields should contain fields covf, nugget, and random.effect (for the nu field); see details for description of these fields. For cov.beta the fields should contain one element for each smooth-temporal trend / beta-field if the fields have only one element, these elements are repeated implying the same covariance for all beta-fields.

Value

updated version of STmodel with new covariance specifications.

Details

The covariance function is specified using lists for cov.beta and cov.nu. The lists should contain the following elements:

covf

The type of covariance function(s), see namesCovFuns.

nugget

For the beta-fields: a vector of TRUE/FALSE indicating if each beta-field should contain a nugget. For the nu-field: Either TRUE/FALSE for constant nugget/no nugget; a formula; or length=1 character vector. For the latter two the nugget is allowed to vary as exp(B*theta) where: nugget = as.formula(paste("~", paste(cov.nu$nugget, collapse="+"))) covars = model.frame(nugget, covars, drop.unused.levels=TRUE) B=model.matrix(nugget, covars) B=as.matrix(B) The resulting regression matrix is stored as STmodel$cov.nu$nugget.matrix giving nugget for the observed locations. Unobserved locations are assumed to have a zero nugget.

random.effect

Only used for cov.nu, TRUE/FALSE indicating if a random.effect for the mean value should be included, see makeSigmaNu.

See Also

Other covariance functions: crossDist, evalCovFuns, makeSigmaB, makeSigmaNu, namesCovFuns, parsCovFuns

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

Examples

Run this code
# NOT RUN {
##load the data
data(mesa.model)

##covariance specification:
cov.beta <- list(covf="exp", nugget=FALSE)
cov.nu <- list(covf="exp", nugget=TRUE, random.effect=FALSE)

##Simple covariance structure
updateCovf(mesa.model, cov.beta, cov.nu)

##different behaviour for different beta:s
cov.beta <- list(covf=c("exp","exp2","matern"), nugget=c(TRUE,FALSE,FALSE))
updateCovf(mesa.model, cov.beta, cov.nu)

##Spatially varying nugget
cov.nu <- list(covf="exp", nugget="type", random.effect=FALSE)
print(tmp <- updateCovf(mesa.model, cov.beta, cov.nu))
##lets study the regression matrix for the nugget
str(tmp$cov.nu$nugget.matrix)
head(tmp$cov.nu$nugget.matrix)
# }

Run the code above in your browser using DataLab