lgcp: Spatio-temporal Log-Gaussian Cox Process Model

Description Usage Arguments Details Value Examples

View source: R/analysis_functions.R

Description

Bayesian inference for a spatio-temporal LGCP model with or without covariates.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
lgcp(
  data,
  data.t = NULL,
  sp.covs = NULL,
  t.covs = NULL,
  pop.var = NULL,
  boundary,
  covariates = NULL,
  cellwidth,
  laglength,
  dirname = NULL,
  prevRun = NULL,
  mala.pars = c(26250, 20000, 50),
  nchains = parallel::detectCores(),
  lib = NULL
)

Arguments

data

A data frame consisting of columns x, y, and t, which are two spatial coordinates and time point respectively.

data.t

A data frame containing any temporal covariates with a column t with the time period and subsequent columns describing the value(s) of the covariates.

sp.covs

A vector with the names of spatially-varying covariate to use in the model (can be NULL). These must match the column names in covariates.

t.covs

A vector with the names of temporally-varying covariates (can be NULL). These names must match the names of columns in data.t.

pop.var

The name of the population density variable to be used for the population offset (can be NULL). This must match the name of a column in covariates.

boundary

A spatialPolygonsDataFrame of the boundary of the area of interest.

covariates

A spatialPolygonsDataFrame covering the area of interest and containing the covariate and population density data.

cellwidth

The width of cells of the computational grid.

laglength

The number of time periods to include. The maximum value of t in data is used as the present period, and time periods are counted back from this value.

dirname

The directory root name to save model output. A directory is created for each MCMC chain as dirname.1, dirname.2, etc. If NULL then a temporary directory is used, this will result in the data being lost after the session in closed though.

prevRun

Used to set prior distributions. Either output from a previous call to lgcp to use posterior distributions from previous period, or a call to lgcp::lgcpPrior.

mala.pars

Parameters for the MCMC sampler. A vector of three numbers: the total number of iterations, the number of warmup iterations, and the number to thin.

nchains

The number of MCMC chains, default is parallel::detectCores()

lib

Library location if not the default, otherwise NULL

Details

The lgcp function provides a wrapper to several functions from the lgcp package. It simplifies the workflow described in the vignette for that package, providing a single function to generate the appropriate grid, covariate matrices and lists, and perform inference with the function lgcp::lgcpPredictSpatioTemporalPlusPars. See the vignette for this package for a description of the model. The implementation here allows for spatially and/or temporally varying covariates but not spatio-temporally varying covariates, as in the time-scales relevant to real-time surveillance applications these are not generally available. For users requiring additional functionality, please refer to the lgcp package documentation.

Value

An object of class lgcpReal

Examples

1
2
3
4
5
6
7
8
9
data(dat,square,square_pop)
lg1 <- lgcp(data=dat,
            pop.var = c("popdens"),
            boundary=square,
            covariates=square_pop,
            cellwidth=0.1,
            laglength = 7,
            mala.pars=c(200,100,1),
            nchains=2)

realTimeSurv documentation built on May 18, 2021, 9:07 a.m.