predictINLA: Prediction from INLA MBG models

Description Usage Arguments Value

Description

Given a fitted inla object for a spatial geostatistical model, make predictions to a new dataset or RasterBrick either from the maximum a posterior parameter set, or as samples from the predictive posterior.

Note that this function is only designed to work with a specific type of geostatistical model, fitted in a specific way and is likely to produce unexpected (i.e. wrong) results when used with other types of model.

Examples of things that aren't allowed are:

Usage

1
2
3
4
5
predictINLA(inla, data, mesh, coords = c("Longitude", "Latitude"),
  type = c("link", "response"), method = c("sample", "MAP"), n = 1,
  fixed = TRUE, spatial = TRUE, fixed_subset = NULL, ncpu = 1)

predictRasterINLA(inla, raster, mesh, constants = list(), ...)

Arguments

inla

a fitted inla object with fixed effects terms and a spatial or spatio-temporal random effect model. If method = "sample" then inla must have been fitted with the argument control.compute = list(config=TRUE).

data

a dataframe giving all of the covariates for the fixed effects part of the model and the temporal term is applicable.

mesh

the inla.mesh object used to construct the spatial random effect.

coords

a character vector of length two giving the names of the columns in data which contain the coordinates of locations at which to make predictions.

type

the type of prediction required. The default is on the scale of the linear predictors; the alternative "response" is on the scale of the response variable. Thus for a default binomial model the default predictions are of log-odds (probabilities on logit scale) and type = "response" gives the predicted probabilities.

method

whether to draw n samples from the predict posterior (if method = "sample", the default) or to make predictions at the maximum a posteriori estimates of the model parameters (if method = "MAP"). If method = "sample" then inla must have been fitted with the argument control.compute = list(config=TRUE).

n

if method = "sample", the number of samples to draw from the predictive posterior.

fixed

whether to include fixed effects terms in the predictor

spatial

whether to include spatial terms in the predictor

fixed_subset

an optional character vector giving a subset of covariates to include in the fixed effects prediction.

ncpu

the number of cores to use to make predictions. If ncpu = 1 then predicitons will be made sequentially, otherwise for n > 1 a snowfall cluster will be initiated and predictions run in parallel.

raster

a Raster* object containing the fixed effects covariates to use for prediction.

constants

an optional named list giving constant values for named fixed effects in inla. E.g. for an intercept term names int, do constants = list(int = 1).

...

arguments to be passed to predictINLA.

Value

predictINLA: a matrix with the same number of rows as data giving the predicted values at these locations

predictRasterINLA: a RasterBrick or RasterStack (if method = 'sample') or RasterLayer (if method = 'MAP') giving pixel-level predictions from inla.


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