gamTrans: Carry out a model-based covariate transformation using a GAM

Description Usage Arguments Value

Description

Define an optimal set of univariate covariate transformations of a set of model covariates by fitting a generalised additive model with univariate smoothers to data, and then using the smoothers to spline-transform the covariates. This makes use of thetype = 'terms' argument in predict.gam. This function also makes use of

Usage

1
2
3
4
gamTrans(coords, response, covs, family = gaussian, condition = NULL,
  condition_covs = NULL, extra_terms = NULL, extra_data = NULL,
  bam = TRUE, s_args = list(), extract_args = list(), predict = TRUE,
  ...)

Arguments

coords

a two-column matrix of coordinates of records

response

an object acting as thge response object in the GAM model (e.g. a vector of counts, or a matrix for binomial data)

covs

a Raster* object giving the spatial covariates for the main part of the model

family

the distribution family for the gam

condition

an optional vector of 1s and 0s of the same length as the number of records in coords and response and stating whether the record should also be modelled using covariates in condition_covs (1 if so and 0 if not). This enables the construction of slightly more complex models, such as those with an explicitly modelled observation process. This is achieved by passing condition to the by argument in mgcv::s when fitting smooths for the condition covariates, as well as adding the condition as an intercept.

condition_covs

an optional Raster* object giving the spatial covariates for the conditional part of the model

extra_terms

an optional formula object (of the form ~ s(x, k = 2) or similar which can be concatenated onto the model formula) specifying further model components (in extra_data) not provided in the spatial covariates.

extra_data

an optional dataframe giving the covariates referred to in extra_terms

bam

whether to fit the model using mgcv::bam (the default), otherwise mgcv::gam is used instead

s_args

a named list of additional arguments to pass to the smoother on each covariate. For example, this may include the smoother type (bs) or the basis dimension (k). See s for the list of available arguments.

extract_args

a named list of additional arguments to pass to raster::extract. For example, this may include a buffer about the points from which to extract covariate values and the function to aggregate these values.

predict

whether to transform the rasters after fitting the model. If set to FALSE this can enable model tweaking before the final transformations are applied, without the computational cost of prediction

...

other arguments to be passed to mgcv::bam or mgcv::gam

Value

a three-element named list containing:


SEEG-Oxford/seegMBG documentation built on May 9, 2019, 11:08 a.m.