Title: | Log-Gaussian Cox Process |
---|---|
Description: | Spatial and spatio-temporal modelling of point patterns using the log-Gaussian Cox process. Bayesian inference for spatial, spatiotemporal, multivariate and aggregated point processes using Markov chain Monte Carlo. See Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2015) <doi:10.18637/jss.v063.i07>. |
Authors: | Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle. Additional code contributions from Edzer Pebesma, Dominic Schumacher. |
Maintainer: | Benjamin M. Taylor <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 2.0 |
Built: | 2024-11-01 04:55:00 UTC |
Source: | https://github.com/cran/lgcp |
An R package for spatiotemporal prediction and forecasting for log-Gaussian Cox processes.
lgcp
lgcp
An object of class logical
of length 1.
This package was not yet installed at build time.
Index: This package was not yet installed at build time.
For examples and further details of the package, type vignette("lgcp"), or refer to the paper associated with this package.
The content of lgcp
can be broken up as follows:
Datasets wpopdata.rda, wtowncoords.rda, wtowns.rda. Giving regional and town poopulations as well as town coordinates,are provided by Wikipedia
and The Office for National Statistics under respectively
the Creative Commons Attribution-ShareAlike 3.0 Unported License and the Open Government Licence.
Data manipulation
Model fitting and parameter estimation
Unconditional and conditional simulation
Summary statistics, diagnostics and visualisation
The lgcp
package depends upon some other important contributions to CRAN in order to operate; their uses here are indicated:
spatstat, sp, RandomFields, iterators, ncdf, methods, tcltk, rgl, rpanel, fields, rgdal, maptools, rgeos, raster
To see how to cite lgcp
, type citation("lgcp")
at the console.
Benjamin Taylor, Health and Medicine, Lancaster University, Tilman Davies, Institute of Fundamental Sciences - Statistics, Massey University, New Zealand., Barry Rowlingson, Health and Medicine, Lancaster University Peter Diggle, Health and Medicine, Lancaster University
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
A function to print a welcome message on loading package
.onAttach(libname, pkgname)
.onAttach(libname, pkgname)
libname |
libname argument |
pkgname |
pkgname argument |
...
This function adds the elements of two list objects together and returns the result in another list object.
add.list(list1, list2)
add.list(list1, list2)
list1 |
a list of objects that could be summed using "+" |
list2 |
a list of objects that could be summed using "+" |
a list with ith entry the sum of list1[[i]] and list2[[i]]
A function to 'bolt on' temporal data onto a spatial covariate design matrix. The function takes a spatial design matrix, Z(s) and
converts it to a spatiotemporal design matrix Z(s,t) when the effects can be separably decomposed i.e.,
Z(s,t)beta = Z_1(s)beta_1 + Z_2(t)beta_2
An example of this function in action is given in the vignette "Bayesian_lgcp", in the section on spatiotemporal data.
addTemporalCovariates(temporal.formula, T, laglength, tdata, Zmat)
addTemporalCovariates(temporal.formula, T, laglength, tdata, Zmat)
temporal.formula |
a formula of the form t ~ tvar1 + tvar2 etc. Where the left hand side is a "t". Note there should not be an intercept term in both of the the spatial and temporal components. |
T |
the time point of interest |
laglength |
the number of previous time points to include in the analysis |
tdata |
a data frame with variable t minimally including times (T-laglength):T and var1, var2 etc. |
Zmat |
the spatial covariates Z(s), obtained by using the getZmat function. |
The main idea of this function is: having created a spatial Z(s) using getZmat, to create a dummy dataset tdata and temporal formula corresponding to the temporal component of the separable effects. The entries in the model matrix Z(s,t) corresponsing to the time covariates are constant over the observation window in space, but in general vary from time-point to time-point.
Note that if there is an intercept in the spatial part of the model e.g., X ~ var1 + var2, then in the temporal model, the intercept should be removed i.e., t ~ tvar1 + tvar2 - 1
A list of design matrices, one for each time, Z(s,t) for t in (T-laglength):T
chooseCellwidth, getpolyol, guessinterp, getZmat, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
An affine transformation of an object of class fromFunction
## S3 method for class 'fromFunction' affine(X, mat, ...)
## S3 method for class 'fromFunction' affine(X, mat, ...)
X |
an object of class fromFunction |
mat |
matrix of affine transformation |
... |
additional arguments |
the object acted on by the transformation matrix
An affine transformation of an object of class fromSPDF
## S3 method for class 'fromSPDF' affine(X, mat, ...)
## S3 method for class 'fromSPDF' affine(X, mat, ...)
X |
an object of class fromSPDF |
mat |
matrix of affine transformation |
... |
additional arguments |
the object acted on by the transformation matrix
An affine transformation of an object of class fromXYZ
. Nearest Neighbour interpolation
## S3 method for class 'fromXYZ' affine(X, mat, ...)
## S3 method for class 'fromXYZ' affine(X, mat, ...)
X |
an object of class fromFunction |
mat |
matrix of affine transformation |
... |
additional arguments |
the object acted on by the transformation matrix
An affine transformation of an object of class SpatialPolygonsDataFrame
## S3 method for class 'SpatialPolygonsDataFrame' affine(X, mat, ...)
## S3 method for class 'SpatialPolygonsDataFrame' affine(X, mat, ...)
X |
an object of class fromFunction |
mat |
matrix of affine transformation |
... |
additional arguments |
the object acted on by the transformation matrix
An affine transformation of an object of class stppp
## S3 method for class 'stppp' affine(X, mat, ...)
## S3 method for class 'stppp' affine(X, mat, ...)
X |
an object of class stppp |
mat |
matrix of affine transformation |
... |
additional arguments |
the object acted on by the transformation matrix
Generic function for aggregation of covariate information.
aggCovInfo(obj, ...)
aggCovInfo(obj, ...)
obj |
an object |
... |
additional arguments |
method aggCovInfo
Aggregation via weighted mean.
## S3 method for class 'ArealWeightedMean' aggCovInfo(obj, regwts, ...)
## S3 method for class 'ArealWeightedMean' aggCovInfo(obj, regwts, ...)
obj |
an ArealWeightedMean object |
regwts |
regional (areal) weighting vector |
... |
additional arguments |
Areal weighted mean.
Aggregation via weighted sum. Use to sum up population counts in regions.
## S3 method for class 'ArealWeightedSum' aggCovInfo(obj, regwts, ...)
## S3 method for class 'ArealWeightedSum' aggCovInfo(obj, regwts, ...)
obj |
an ArealWeightedSum object |
regwts |
regional (areal) weighting vector |
... |
additional arguments |
Areal weighted Sum.
Aggregation via majority.
## S3 method for class 'Majority' aggCovInfo(obj, regwts, ...)
## S3 method for class 'Majority' aggCovInfo(obj, regwts, ...)
obj |
an Majority object |
regwts |
regional (areal) weighting vector |
... |
additional arguments |
The most popular cell type.
A function called by cov.interp.fft to allocate and perform interpolation of covariate infomation onto the FFT grid
aggregateCovariateInfo(cellidx, cidx, gidx, df, fftovl, classes, polyareas)
aggregateCovariateInfo(cellidx, cidx, gidx, df, fftovl, classes, polyareas)
cellidx |
the index of the cell |
cidx |
index of covariate, no longer used |
gidx |
grid index |
df |
the data frame containing the covariate information |
fftovl |
an overlay of the fft grid onto the SpatialPolygonsDataFrame or SpatialPixelsDataFrame objects |
classes |
vector of class attributes of the dataframe |
polyareas |
polygon areas of the SpatialPolygonsDataFrame or SpatialPixelsDataFrame objects |
the interpolated covariate information onto the FFT grid
An internal function to collect terms from a formulalist. Not intended for general use.
aggregateformulaList(x, ...)
aggregateformulaList(x, ...)
x |
an object of class "formulaList" |
... |
other arguments |
a formula of the form X ~ var1 + var2 tec.
A Robbins-Munro stochastic approximation update is used to adapt the tuning parameter of the proposal kernel. The idea is to update the tuning parameter at each iteration of the sampler:
where and
are the tuning parameter and acceptance probability at iteration
and
is a target acceptance probability. For Gaussian targets, and in the limit
as the dimension of the problem tends to infinity, an appropriate target acceptance probability for
MALA algorithms is 0.574. The sequence
is chosen so that
is infinite whilst
is
finite for
. These two conditions ensure that any value of
can be reached, but in a way that
maintains the ergodic behaviour of the chain. One class of sequences with this property is,
where and
.The scheme is set via
the
mcmcpars
function.
andrieuthomsh(inith, alpha, C, targetacceptance = 0.574)
andrieuthomsh(inith, alpha, C, targetacceptance = 0.574)
inith |
initial h |
alpha |
parameter |
C |
parameter |
targetacceptance |
target acceptance probability |
an object of class andrieuthomsh
Andrieu C, Thoms J (2008). A tutorial on adaptive MCMC. Statistics and Computing, 18(4), 343-373.
Robbins H, Munro S (1951). A Stochastic Approximation Methods. The Annals of Mathematical Statistics, 22(3), 400-407.
Roberts G, Rosenthal J (2001). Optimal Scaling for Various Metropolis-Hastings Algorithms. Statistical Science, 16(4), 351-367.
andrieuthomsh(inith=1,alpha=0.5,C=1,targetacceptance=0.574)
andrieuthomsh(inith=1,alpha=0.5,C=1,targetacceptance=0.574)
Method to convert an lgcpgrid object into an array.
## S3 method for class 'lgcpgrid' as.array(x, ...)
## S3 method for class 'lgcpgrid' as.array(x, ...)
x |
an object of class lgcpgrid |
... |
other arguments |
conversion from lgcpgrid to array
Generic function for conversion to a fromXYZ object (eg as would have been produced by spatialAtRisk for example.)
as.fromXYZ(X, ...)
as.fromXYZ(X, ...)
X |
an object |
... |
additional arguments |
generic function returning method as.fromXYZ
as.im.fromXYZ, as.im.fromSPDF, as.im.fromFunction, as.fromXYZ
Method for converting from the fromFunction class of objects to the fromXYZ class of objects. Clearly this requires the user to specify a grid onto which to compute the discretised verion.
## S3 method for class 'fromFunction' as.fromXYZ(X, xyt, M = 100, N = 100, ...)
## S3 method for class 'fromFunction' as.fromXYZ(X, xyt, M = 100, N = 100, ...)
X |
an object of class fromFunction |
xyt |
and objects of class stppp |
M |
number of cells in x direction |
N |
number of cells in y direction |
... |
additional arguments |
object of class im containing normalised intensities
as.im.fromXYZ, as.im.fromSPDF, as.im.fromFunction, as.fromXYZ
Convert an object of class fromFunction(created by spatialAtRisk for example) into a spatstat im object.
## S3 method for class 'fromFunction' as.im(X, xyt, M = 100, N = 100, ...)
## S3 method for class 'fromFunction' as.im(X, xyt, M = 100, N = 100, ...)
X |
an object of class fromSPDF |
xyt |
and objects of class stppp |
M |
number of cells in x direction |
N |
number of cells in y direction |
... |
additional arguments |
object of class im containing normalised intensities
as.im.fromXYZ, as.im.fromSPDF, as.im.fromFunction, as.fromXYZ
Convert an object of class fromSPDF (created by spatialAtRisk for example) into a spatstat im object.
## S3 method for class 'fromSPDF' as.im(X, ncells = 100, ...)
## S3 method for class 'fromSPDF' as.im(X, ncells = 100, ...)
X |
an object of class fromSPDF |
ncells |
number of cells to divide range into; default 100 |
... |
additional arguments |
object of class im containing normalised intensities
as.im.fromXYZ, as.im.fromSPDF, as.im.fromFunction, as.fromXYZ
Convert an object of class fromXYZ (created by spatialAtRisk for example) into a spatstat im object.
## S3 method for class 'fromXYZ' as.im(X, ...)
## S3 method for class 'fromXYZ' as.im(X, ...)
X |
object of class fromXYZ |
... |
additional arguments |
object of class im containing normalised intensities
as.im.fromSPDF, as.im.fromFunction, as.fromXYZ
Method to convert an lgcpgrid object into a list of matrices.
## S3 method for class 'lgcpgrid' as.list(x, ...)
## S3 method for class 'lgcpgrid' as.list(x, ...)
x |
an object of class lgcpgrid |
... |
other arguments |
conversion from lgcpgrid to list
lgcpgrid.list, lgcpgrid.array, print.lgcpgrid, summary.lgcpgrid, quantile.lgcpgrid, image.lgcpgrid, plot.lgcpgrid
A function to extract the SpatialPolygons part of W and return it as an owin object.
## S3 method for class 'stapp' as.owin(W, ..., fatal = TRUE)
## S3 method for class 'stapp' as.owin(W, ..., fatal = TRUE)
W |
see ?as.owin |
... |
see ?as.owin |
fatal |
see ?as.owin |
an owin object
Generic function for creating lists of owin objects
as.owinlist(obj, ...)
as.owinlist(obj, ...)
obj |
an object |
... |
additional arguments |
method as.owinlist
A function to create a list of owin objects from a SpatialPolygonsDataFrame
## S3 method for class 'SpatialPolygonsDataFrame' as.owinlist(obj, dmin = 0, check = TRUE, subset = rep(TRUE, length(obj)), ...)
## S3 method for class 'SpatialPolygonsDataFrame' as.owinlist(obj, dmin = 0, check = TRUE, subset = rep(TRUE, length(obj)), ...)
obj |
a SpatialPolygonsDataFrame object |
dmin |
purpose is to simplify the SpatialPolygons. A numeric value giving the smallest permissible length of an edge. See ? simplify.owin |
check |
whether or not to use spatstat functions to check the validity of SpatialPolygons objects |
subset |
logical vector. Subset of regions to extract and conver to owin objects. By default, all regions are extracted. |
... |
additional arguments |
a list of owin objects corresponding to the constituent Polygons objects
A function to create a list of owin objects from a stapp
## S3 method for class 'stapp' as.owinlist(obj, dmin = 0, check = TRUE, ...)
## S3 method for class 'stapp' as.owinlist(obj, dmin = 0, check = TRUE, ...)
obj |
an stapp object |
dmin |
purpose is to simplify the SpatialPolygons. A numeric value giving the smallest permissible length of an edge. See ? simplify.owin |
check |
whether or not to use spatstat functions to check the validity of SpatialPolygons objects |
... |
additional arguments |
a list of owin objects corresponding to the constituent Polygons objects
Convert from mstppp to ppp. Can be useful for data handling.
## S3 method for class 'mstppp' as.ppp(X, ..., fatal = TRUE)
## S3 method for class 'mstppp' as.ppp(X, ..., fatal = TRUE)
X |
an object of class mstppp |
... |
additional arguments |
fatal |
logical value, see details in generic ?as.ppp |
a ppp object without observation times
Convert from stppp to ppp. Can be useful for data handling.
## S3 method for class 'stppp' as.ppp(X, ..., fatal = TRUE)
## S3 method for class 'stppp' as.ppp(X, ..., fatal = TRUE)
X |
an object of class stppp |
... |
additional arguments |
fatal |
logical value, see details in generic ?as.ppp |
a ppp object without observation times
Generic method for convertign to an object of class SpatialGridDataFrame.
as.SpatialGridDataFrame(obj, ...)
as.SpatialGridDataFrame(obj, ...)
obj |
an object |
... |
additional arguments |
method as.SpatialGridDataFrame
as.SpatialGridDataFrame.fromXYZ
Method for converting objects of class fromXYZ into those of class SpatialGridDataFrame
## S3 method for class 'fromXYZ' as.SpatialGridDataFrame(obj, ...)
## S3 method for class 'fromXYZ' as.SpatialGridDataFrame(obj, ...)
obj |
an object of class spatialAtRisk |
... |
additional arguments |
an object of class SpatialGridDataFrame
Generic function for conversion to SpatialPixels objects.
as.SpatialPixelsDataFrame(obj, ...)
as.SpatialPixelsDataFrame(obj, ...)
obj |
an object |
... |
additional arguments |
method as.SpatialPixels
as.SpatialPixelsDataFrame.lgcpgrid
Method to convert lgcpgrid objects to SpatialPixelsDataFrame objects.
## S3 method for class 'lgcpgrid' as.SpatialPixelsDataFrame(obj, ...)
## S3 method for class 'lgcpgrid' as.SpatialPixelsDataFrame(obj, ...)
obj |
an lgcpgrid object |
... |
additional arguments to be passed to SpatialPoints, eg a proj4string |
Either a SpatialPixelsDataFrame, or a list consisting of SpatialPixelsDataFrame objects.
Generic function for converting to stppp objects
as.stppp(obj, ...)
as.stppp(obj, ...)
obj |
an object |
... |
additional arguments |
method as.stppp
A function to convert stapp objects to stppp objects for use in lgcpPredict. The regional counts in the stapp object are assigned a random location within each areal region proportional to a population density (if that is available) else the counts are distributed uniformly across the observation windows.
## S3 method for class 'stapp' as.stppp(obj, popden = NULL, n = 100, dmin = 0, check = TRUE, ...)
## S3 method for class 'stapp' as.stppp(obj, popden = NULL, n = 100, dmin = 0, check = TRUE, ...)
obj |
an object of class stapp |
popden |
a 'spatialAtRisk' of sub-class 'fromXYZ' object representing the population density, or for better results, lambda(s) can also be used here. Cases are distributed across the spatial region according to popden. NULL by default, which has the effect of assigning counts uniformly. |
n |
if popden is NULL, then this parameter controls the resolution of the uniform. Otherwise if popden is of class 'fromFunction', it controls the size of the imputation grid used for sampling. Default is 100. |
dmin |
If any reginal counts are missing, then a set of polygonal 'holes' in the observation window will be computed for each. dmin is the parameter used to control the simplification of these holes (see ?simplify.owin). default is zero. |
check |
logical. If any reginal counts are missing, then roughly speaking, check specifies whether to check the 'holes'. |
... |
additional arguments |
...
A function to assign an interpolation type to a variable in a data frame.
assigninterp(df, vars, value)
assigninterp(df, vars, value)
df |
a data frame |
vars |
character vector giving name of variables |
value |
an interpolation type, posssible options are given by typing interptypes(), see ?interptypes |
The three types of interpolation method employed in the package lgcp are:
'Majority' The interpolated value corresponds to the value of the covariate occupying the largest area of the computational cell.
'ArealWeightedMean' The interpolated value corresponds to the mean of all covariate values contributing to the computational cell weighted by their respective areas.
'ArealWeightedSum' The interpolated value is the sum of all contributing covariates weighed by the proportion of area with respect to the covariate polygons. For example, suppose region A has the same area as a computational grid cell and has 500 inhabitants. If that region occupies half of a computational grid cell, then this interpolation type assigns 250 inhabitants from A to the computational grid cell.
assigns an interpolation type to a variable
chooseCellwidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
## Not run: spdf a SpatialPolygonsDataFrame ## Not run: spdf@data <- assigninterp(df=spdf@data,vars="pop",value="ArealWeightedSum")
## Not run: spdf a SpatialPolygonsDataFrame ## Not run: spdf@data <- assigninterp(df=spdf@data,vars="pop",value="ArealWeightedSum")
at function
at(t, mu, theta)
at(t, mu, theta)
t |
change in time parameter, see Brix and Diggle (2001) |
mu |
mean |
theta |
parameter beta in Brix and Diggle |
...
This function requires data to have been dumped to disk: see ?dump2dir
and ?setoutput
. The routine autocorr.lgcpPredict
computes cellwise selected autocorrelations of Y.
Since computing the quantiles is an expensive operation, the option to output the quantiles on a subregion of interest is also provided (by
setting the argument inWindow
, which has a sensible default).
autocorr( x, lags, tidx = NULL, inWindow = x$xyt$window, crop2parentwindow = TRUE, ... )
autocorr( x, lags, tidx = NULL, inWindow = x$xyt$window, crop2parentwindow = TRUE, ... )
x |
an object of class lgcpPredict |
lags |
a vector of the required lags |
tidx |
the index number of the the time interval of interest, default is the last time point. |
inWindow |
an observation owin window on which to compute the autocorrelations, can speed up calculation. Default is x$xyt$window, set to NULL for full grid. |
crop2parentwindow |
logical: whether to only compute autocorrelations for cells inside x$xyt$window (the 'parent window') |
... |
additional arguments |
an array, the [,,i]th slice being the grid of cell-wise autocorrelations.
lgcpPredict, dump2dir, setoutput, plot.lgcpAutocorr, ltar, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function to compute cell-wise autocorrelation in the latent field at specifiec lags
autocorrMultitype( x, lags, fieldno, inWindow = x$xyt$window, crop2parentwindow = TRUE, ... )
autocorrMultitype( x, lags, fieldno, inWindow = x$xyt$window, crop2parentwindow = TRUE, ... )
x |
an object of class lgcpPredictMultitypeSpatialPlusParameters |
lags |
the lags at which to compute the autocorrelation |
fieldno |
the index of the lateyt field, the i in Y_i, see the help file for lgcpPredictMultitypeSpatialPlusParameters. IN diagnostic checking ,this command should be called for each field in the model. |
inWindow |
an observation owin window on which to compute the autocorrelations, can speed up calculation. Default is x$xyt$window, set to NULL for full grid. |
crop2parentwindow |
logical: whether to only compute autocorrelations for cells inside x$xyt$window (the 'parent window') |
... |
other arguments |
an array, the [,,i]th slice being the grid of cell-wise autocorrelations.
An internal function to declare a vector a parameter vector for the main effects.
BetaParameters(beta)
BetaParameters(beta)
beta |
a vector |
...
A function to return the sampled beta from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars
betavals(lg)
betavals(lg)
lg |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars orlgcpPredictMultitypeSpatialPlusPars |
the posterior sampled beta
ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, etavals
Compute the base matrix of a continuous Gaussian field. Computed as a block circulant matrix on a torus where x and y is the x and y centroids (must be equally spaced)
blockcircbase(x, y, sigma, phi, model, additionalparameters, inverse = FALSE)
blockcircbase(x, y, sigma, phi, model, additionalparameters, inverse = FALSE)
x |
x centroids, an equally spaced vector |
y |
y centroids, an equally spaced vector |
sigma |
spatial variance parameter |
phi |
spatial decay parameter |
model |
covariance model, see ?CovarianceFct |
additionalparameters |
additional parameters for chosen covariance model. See ?CovarianceFct |
inverse |
logical. Whether to return the base matrix of the inverse covariance matrix (ie the base matrix for the precision matrix), default is FALSE |
the base matrix of a block circulant matrix representing a stationary covariance function on a toral grid.
Compute the base matrix of a continuous Gaussian field. Computed as a block circulant matrix on a torus where x and y is the x and y centroids (must be equally spaced). This is an extension of the function blockcircbase to extend the range of covariance functions that can be fitted to the model.
blockcircbaseFunction(x, y, CovFunction, CovParameters, inverse = FALSE)
blockcircbaseFunction(x, y, CovFunction, CovParameters, inverse = FALSE)
x |
x centroids, an equally spaced vector |
y |
y centroids, an equally spaced vector |
CovFunction |
a function of distance, returning the covariance between points that distance apart |
CovParameters |
an object of class CovParamters, see ?CovParameters |
inverse |
logical. Whether to return the base matrix of the inverse covariance matrix (ie the base matrix for the precision matrix), default is FALSE |
the base matrix of a block circulant matrix representing a stationary covariance function on a toral grid.
chooseCellwidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
bt.scalar function
bt.scalar(t, theta)
bt.scalar(t, theta)
t |
change in time, see Brix and Diggle (2001) |
theta |
parameter beta in Brix and Diggle |
...
A function to run on an object generated by the "selectObsWindow" function. Plots the observation window with grid, use as a visual aid to check the choice of cell width is correct.
checkObsWin(ow)
checkObsWin(ow)
ow |
an object generated by selectObsWindow, see ?selectObsWindow |
a plot of the observation window and grid
A function to help choose the cell width (the parameter "cellwidth" in lgcpPredictSpatialPlusPars, for example) prior to setting up the FFT grid, before an MCMC run.
chooseCellwidth(obj, cwinit)
chooseCellwidth(obj, cwinit)
obj |
an object of class ppp, stppp, SpatialPolygonsDataFrame, or owin |
cwinit |
the cell width |
Ideally this function should be used after having made a preliminary guess at the parameters of the latent field.The idea is to run chooseCellwidth several times, adjusting the parameter "cwinit" so as to balance available computational resources with output grid size.
produces a plot of the observation window and computational grid.
getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
generic function for constructing circulant matrices
circulant(x, ...)
circulant(x, ...)
x |
an object |
... |
additional arguments |
method circulant
If x is a matrix whose columns are the bases of the sub-blocks of a block circulant matrix, then this function returns the block circulant matrix of interest.
## S3 method for class 'matrix' circulant(x, ...)
## S3 method for class 'matrix' circulant(x, ...)
x |
a matrix object |
... |
additional arguments |
If x is a matrix whose columns are the bases of the sub-blocks of a block circulant matrix, then this function returns the block circulant matrix of interest.
returns a circulant matrix with base x
## S3 method for class 'numeric' circulant(x, ...)
## S3 method for class 'numeric' circulant(x, ...)
x |
an numeric object |
... |
additional arguments |
a circulant matrix with base x
A function to remove the interpolation methods from a data frame.
clearinterp(df)
clearinterp(df)
df |
a data frame |
removes the interpolation methods
Advanced use only. A function to compute a gradient truncation parameter for 'spatial only' MALA via simulation. The function requires an FFT 'grid' to be pre-computed, see fftgrid.
computeGradtruncSpatial( nsims = 100, scale = 1, nis, mu, rootQeigs, invrootQeigs, scaleconst, spatial, cellarea )
computeGradtruncSpatial( nsims = 100, scale = 1, nis, mu, rootQeigs, invrootQeigs, scaleconst, spatial, cellarea )
nsims |
The number of simulations to use in computation of gradient truncation. |
scale |
multiplicative scaling constant, returned value is scale (times) max(gradient over simulations). Default scale is 1. |
nis |
cell counts on the extended grid |
mu |
parameter of latent field, mu |
rootQeigs |
root of eigenvalues of precision matrix of latent field |
invrootQeigs |
reciprocal root of eigenvalues of precision matrix of latent field |
scaleconst |
expected number of cases, or ML estimate of this quantity |
spatial |
spatial at risk interpolated onto grid of requisite size |
cellarea |
cell area |
gradient truncation parameter
Advanced use only. A function to compute a gradient truncation parameter for 'spatial only' MALA via simulation. The function requires an FFT 'grid' to be pre-computed, see fftgrid.
computeGradtruncSpatioTemporal( nsims = 100, scale = 1, nis, mu, rootQeigs, invrootQeigs, spatial, temporal, bt, cellarea )
computeGradtruncSpatioTemporal( nsims = 100, scale = 1, nis, mu, rootQeigs, invrootQeigs, spatial, temporal, bt, cellarea )
nsims |
The number of simulations to use in computation of gradient truncation. |
scale |
multiplicative scaling constant, returned value is scale (times) max(gradient over simulations). Default scale is 1. |
nis |
cell counts on the extended grid |
mu |
parameter of latent field, mu |
rootQeigs |
root of eigenvalues of precision matrix of latent field |
invrootQeigs |
reciprocal root of eigenvalues of precision matrix of latent field |
spatial |
spatial at risk interpolated onto grid of requisite size |
temporal |
fitted temporal values |
bt |
vectoer of variances b(delta t) in Brix and Diggle 2001 |
cellarea |
cell area |
gradient truncation parameter
A function to compute the conditional type-probabilities from a multivariate LGCP. See the vignette "Bayesian_lgcp" for a full explanation of this.
condProbs(obj)
condProbs(obj)
obj |
an lgcpPredictMultitypeSpatialPlusParameters object |
We suppose there are K point types of interest. The model for point-type k is as follows:
X_k(s) ~ Poisson[R_k(s)]
R_k(s) = C_A lambda_k(s) exp[Z_k(s)beta_k+Y_k(s)]
Here X_k(s) is the number of events of type k in the computational grid cell containing the point s, R_k(s) is the Poisson rate, C_A is the cell area, lambda_k(s) is a known offset, Z_k(s) is a vector of measured covariates and Y_i(s) where i = 1,...,K+1 are latent Gaussian processes on the computational grid. The other parameters in the model are beta_k , the covariate effects for the kth type; and eta_i = [log(sigma_i),log(phi_i)], the parameters of the process Y_i for i = 1,...,K+1 on an appropriately transformed (again, in this case log) scale.
The term 'conditional probability of type k' means the probability that at a particular location there will be an event of type k, which denoted p_k.
an lgcpgrid object containing the consitional type-probabilities for each type
segProbs, postcov.lgcpPredictSpatialOnlyPlusParameters, postcov.lgcpPredictAggregateSpatialPlusParameters, postcov.lgcpPredictSpatioTemporalPlusParameters, postcov.lgcpPredictMultitypeSpatialPlusParameters, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
This function is used to set up a constant acceptance scheme in the argument
mcmc.control
of the function lgcpPredict
. The scheme is set via
the mcmcpars
function.
constanth(h)
constanth(h)
h |
an object |
object of class constanth
constanth(0.01)
constanth(0.01)
Generic function for creating constant-in-time temporalAtRisk objects, that is for models where mu(t) can be assumed to be constant in time. The assumption being that the global at-risk population does not change in size over time.
constantInTime(obj, ...)
constantInTime(obj, ...)
obj |
an object |
... |
additional arguments |
For further details of temporalAtRisk objects, see ?temporalAtRisk>
method constantInTime
temporalAtRisk, spatialAtRisk, temporalAtRisk.numeric, temporalAtRisk.function, constantInTime.numeric, constantInTime.stppp, print.temporalAtRisk, plot.temporalAtRisk
Create a constant-in-time temporalAtRisk object from a numeric object of length 1. The returned temporalAtRisk object is assumed to have been scaled correctly by the user so that mu(t) = E(number of cases in a unit time interval).
## S3 method for class 'numeric' constantInTime(obj, tlim, warn = TRUE, ...)
## S3 method for class 'numeric' constantInTime(obj, tlim, warn = TRUE, ...)
obj |
numeric constant |
tlim |
vector of length 2 giving time limits |
warn |
Issue a warning if the given temporal intensity treated is treated as 'known'? |
... |
additional arguments |
For further details of temporalAtRisk objects, see ?temporalAtRisk>
a function f(t) giving the (constant) temporal intensity at time t for integer t in the interval [tlim[1],tlim[2]] of class temporalAtRisk
temporalAtRisk, spatialAtRisk, temporalAtRisk.numeric, temporalAtRisk.function, constantInTime, constantInTime.stppp, print.temporalAtRisk, plot.temporalAtRisk,
Create a constant-in-time temporalAtRisk object from an stppp object. The returned temporalAtRisk object is scaled to return mu(t) = E(number of cases in a unit time interval).
## S3 method for class 'stppp' constantInTime(obj, ...)
## S3 method for class 'stppp' constantInTime(obj, ...)
obj |
an object of class stppp. |
... |
additional arguments |
For further details of temporalAtRisk objects, see ?temporalAtRisk>
a function f(t) giving the (constant) temporal intensity at time t for integer t in the interval [tlim[1],tlim[2]] of class temporalAtRisk
temporalAtRisk, spatialAtRisk, temporalAtRisk.numeric, temporalAtRisk.function, constantInTime, constantInTime.numeric, print.temporalAtRisk, plot.temporalAtRisk,
A function to interpolate covariate values onto the fft grid, ready for analysis
cov.interp.fft( formula, W, regionalcovariates = NULL, pixelcovariates = NULL, mcens, ncens, cellInside, overl = NULL )
cov.interp.fft( formula, W, regionalcovariates = NULL, pixelcovariates = NULL, mcens, ncens, cellInside, overl = NULL )
formula |
an object of class formula (or one that can be coerced to that class) starting with X ~ (eg X~var1+var2 *NOT for example* Y~var1+var2): a symbolic description of the model to be fitted. |
W |
an owin observation window |
regionalcovariates |
an optional SpatialPolygonsDataFrame |
pixelcovariates |
an optional SpatialPixelsDataFrame |
mcens |
x-coordinates of output grid centroids (not fft grid centroids ie *not* the extended grid) |
ncens |
y-coordinates of output grid centroids (not fft grid centroids ie *not* the extended grid) |
cellInside |
a 0-1 matrix indicating which computational cells are inside the observation window |
overl |
an overlay of the computational grid onto the SpatialPolygonsDataFrame or SpatialPixelsDataFrame. |
The interpolated design matrix, ready for analysis
A function to
CovarianceFct(u, sigma, phi, model, additionalparameters)
CovarianceFct(u, sigma, phi, model, additionalparameters)
u |
distance |
sigma |
parameter sigma |
phi |
parameter phi |
model |
character string, the model |
additionalparameters |
additional parameters for the covariance function that will be fixed. |
the covariance function evaluated at the specified distances
A function used in conjunction with the function "expectation" to compute the main covariate effects,
lambda(s) exp[Z(s)beta]
in each computational grid cell. Currently
only implemented for spatial processes (lgcpPredictSpatialPlusPars and lgcpPredictAggregateSpatialPlusPars).
covEffects(Y, beta, eta, Z, otherargs)
covEffects(Y, beta, eta, Z, otherargs)
Y |
the latent field |
beta |
the main effects |
eta |
the parameters of the latent field |
Z |
the design matrix |
otherargs |
other arguments to the function (see vignette "Bayesian_lgcp" for an explanation) |
the main effects
expectation, lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars
## Not run: ex <- expectation(lg,covEffects)[[1]] # lg is output from spatial LGCP MCMC
## Not run: ex <- expectation(lg,covEffects)[[1]] # lg is output from spatial LGCP MCMC
A Generic method used to specify the choice of covariance function for use in the MCMC algorithm. For further details and examples, see the vignette "Bayesian_lgcp".
CovFunction(obj, ...)
CovFunction(obj, ...)
obj |
an object |
... |
additional arguments |
method CovFunction
CovFunction.function, exponentialCovFct, RandomFieldsCovFct, SpikedExponentialCovFct
A function used to define the covariance function for the latent field prior to running the MCMC algorithm
## S3 method for class ''function'' CovFunction(obj, ...)
## S3 method for class ''function'' CovFunction(obj, ...)
obj |
a function object |
... |
additional arguments |
the covariance function ready to run the MCMC routine.
exponentialCovFct, RandomFieldsCovFct, SpikedExponentialCovFct, CovarianceFct
## Not run: cf1 <- CovFunction(exponentialCovFct) ## Not run: cf2 <- CovFunction(RandomFieldsCovFct(model="matern",additionalparameters=1))
## Not run: cf1 <- CovFunction(exponentialCovFct) ## Not run: cf2 <- CovFunction(RandomFieldsCovFct(model="matern",additionalparameters=1))
A function to provide a structure for the parameters of the latent field. Not intended for general use.
CovParameters(list)
CovParameters(list)
list |
a list |
an object used in the MCMC routine.
This function is used in thetaEst
to estimate the temporal correlation parameter, theta.
Cvb(xyt, spatial.intensity, N = 100, spatial.covmodel, covpars)
Cvb(xyt, spatial.intensity, N = 100, spatial.covmodel, covpars)
xyt |
object of class stppp |
spatial.intensity |
bivariate density estimate of lambda, an object of class im (produced from density.ppp for example) |
N |
number of integration points |
spatial.covmodel |
spatial covariance model |
covpars |
additional covariance parameters |
a function, see below. Computes Monte carlo estimate of function C(v;beta) in Brix and Diggle 2001 pp 829 (... note later corrigendum to paper (2003) corrects the expression given in this paper)
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
d.func function
d.func(mat1il, mat2jk, i, j, l, k)
d.func(mat1il, mat2jk, i, j, l, k)
mat1il |
matrix 1 |
mat2jk |
matrix 2 |
i |
index matrix 1 number 1 |
j |
index matrix 2 number 1 |
l |
index matrix 1 number 2 |
k |
index matrix 2 number 2 |
...
A wrapper function for density.ppp.
## S3 method for class 'stppp' density(x, bandwidth = NULL, ...)
## S3 method for class 'stppp' density(x, bandwidth = NULL, ...)
x |
an stppp object |
bandwidth |
'bandwidth' parameter, equivanent to parameter sigma in ?density.ppp ie standard deviation of isotropic Gaussian smoothing kernel. |
... |
additional arguments to be passed to density.ppp |
bivariate density estimate of xyt; not this is a wrapper function for density.ppp
Generic function for extracting the FFT discrete window.
discreteWindow(obj, ...)
discreteWindow(obj, ...)
obj |
an object |
... |
additional arguments |
method discreteWindow
A function for extracting the FFT discrete window from an lgcpPredict object.
## S3 method for class 'lgcpPredict' discreteWindow(obj, inclusion = "touching", ...)
## S3 method for class 'lgcpPredict' discreteWindow(obj, inclusion = "touching", ...)
obj |
an lgcpPredict object |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
... |
additional arguments |
...
This function, when set by the gridfunction
argument of setoutput, in turn called by the argument
output.control
of lgcpPredict
facilitates the dumping of data to disk. Data is dumped to a
netCDF file, simout.nc
, stored in the directory specified by the user. If the directory does not exist,
then it will be created. Since the requested data dumped to disk may be very large in a run of lgcpPredict
,
by default, the user is prompted as to whether to proceed with prediction, this can be turned off by setting
the option forceSave=TRUE
detailed here. To save space, or increase the number of simulations that can be
stored for a fixed disk space the option to only save the last time point is also available (lastonly=TRUE
,
which is the default setting).
dump2dir(dirname, lastonly = TRUE, forceSave = FALSE)
dump2dir(dirname, lastonly = TRUE, forceSave = FALSE)
dirname |
character vector of length 1 containing the name of the directory to create |
lastonly |
only save output from time T? (see ?lgcpPredict for definition of T) |
forceSave |
option to override display of menu |
object of class dump2dir
setoutput, \ GFinitialise, GFupdate, GFfinalise, GFreturnvalue
A function to compute the eigenvalues of an SPD block circulant matrix given the base matrix.
eigenfrombase(x)
eigenfrombase(x)
x |
the base matrix |
the eigenvalues
A function to return the sampled eta from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars
etavals(lg)
etavals(lg)
lg |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars orlgcpPredictMultitypeSpatialPlusPars |
the posterior sampled eta
ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals
An internal function used in the MCMC routine to evaluate the prior for a given set of parameters
EvaluatePrior(etaParameters, betaParameters, prior)
EvaluatePrior(etaParameters, betaParameters, prior)
etaParameters |
the paramter eta |
betaParameters |
the parameter beta |
prior |
the prior |
the prior evaluated at the given values.
This function can be called using MonteCarloAverage
(see fun3
the examples in the help file for
MonteCarloAverage). It computes exceedance probabilities,
that is the probability that the relative reisk exceeds threshold . Note that it is possible
to pass vectors of tresholds to the function, and the exceedance probabilities will be computed for each
of these.
exceedProbs(threshold, direction = "upper")
exceedProbs(threshold, direction = "upper")
threshold |
vector of threshold levels for the indicator function |
direction |
default 'upper' giving exceedance probabilities, alternative is 'lower', which gives 'subordinate probabilities' |
a function of Y that computes the indicator function I(exp(Y)>threshold) evaluated for each cell of a matrix Y If several tresholds are specified an array is returned with the [,,i]th slice equal to I(exp(Y)>threshold[i])
NOTE THIS FUNCTION IS IN TESTING AT PRESENT
exceedProbsAggregated(threshold, lg = NULL, lastonly = TRUE)
exceedProbsAggregated(threshold, lg = NULL, lastonly = TRUE)
threshold |
vector of threshold levels for the indicator function |
lg |
an object of class aggregatedPredict |
lastonly |
logical, whether to only compute the exceedances for the last time point. default is TRUE |
This function computes regional exceedance probabilities after MCMC has finished, it requires the information to have been dumped to disk, and to have been computed using the function lgcpPredictAggregated
that is the probability that the relative risk exceeds threshold . Note that it is possible
to pass vectors of tresholds to the function, and the exceedance probabilities will be computed for each
of these.
a function of Y that computes the indicator function I(exp(Y)>threshold) evaluated for each cell of a matrix Y, but with values aggregated to regions If several tresholds are specified an array is returned with the [,,i]th slice equal to I(exp(Y)>threshold[i])
Generic function used in the computation of Monte Carlo expectations.
expectation(obj, ...)
expectation(obj, ...)
obj |
an object |
... |
additional arguments |
method expectation
This function requires data to have been dumped to disk: see ?dump2dir
and ?setoutput
. This function computes the
Monte Carlo Average of a function where data from a run of lgcpPredict
has been dumped to disk.
## S3 method for class 'lgcpPredict' expectation(obj, fun, maxit = NULL, ...)
## S3 method for class 'lgcpPredict' expectation(obj, fun, maxit = NULL, ...)
obj |
an object of class lgcpPredict |
fun |
a function accepting a single argument that returns a numeric vector, matrix or array object |
maxit |
Not used in ordinary circumstances. Defines subset of samples over which to compute expectation. Expectation is computed using information from iterations 1:maxit, where 1 is the first non-burn in iteration dumped to disk. |
... |
additional arguments |
A Monte Carlo Average is computed as:
where is a function of interest,
is the
th retained sample from the target
and
is the total number of retained iterations. For example, to compute the mean of
set,
the output from such a Monte Carlo average would be a set of grids, each cell of which
being equal to the mean over all retained iterations of the algorithm (NOTE: this is just an example computation, in
practice, there is no need to compute the mean on line explicitly, as this is already done by default in
lgcpPredict
).
the expectated value of that function
lgcpPredict, dump2dir, setoutput
This function requires data to have been dumped to disk: see ?dump2dir
and ?setoutput
. This function computes the
Monte Carlo Average of a function where data from a run of lgcpPredict
has been dumped to disk.
"expectation(obj,fun,maxit=NULL,...)"
"expectation(obj,fun,maxit=NULL,...)"
obj |
an object of class lgcpPredictSpatialOnlyPlusParameters |
fun |
a function with arguments 'Y', 'beta', 'eta', 'Z' and 'otherargs'. See vignette("Bayesian_lgcp") for an example |
maxit |
Not used in ordinary circumstances. Defines subset of samples over which to compute expectation. Expectation is computed using information from iterations 1:maxit, where 1 is the first non-burn in iteration dumped to disk. |
... |
additional arguments |
the expectated value of that function
A function to declare and also evaluate an exponential covariance function.
exponentialCovFct(d, CovParameters)
exponentialCovFct(d, CovParameters)
d |
toral distance |
CovParameters |
parameters of the latent field, an object of class "CovParamaters". |
the exponential covariance function
CovFunction.function, RandomFieldsCovFct, SpikedExponentialCovFct
A function to extend a spatialAtRisk object, used in interpolating the fft grid NOTE THIS DOES NOT RETURN A PROPER spatialAtRisk OBJECT SINCE THE NORMALISING CONSTANT IS PUT BACK IN.
extendspatialAtRisk(spatial)
extendspatialAtRisk(spatial)
spatial |
a spatialAtRisk object inheriting class 'fromXYZ' |
the spatialAtRisk object on a slightly larger grid, with zeros appearing outside the original extent.
Generic function for extracting information dumped to disk. See extract.lgcpPredict for further information.
extract(obj, ...)
extract(obj, ...)
obj |
an object |
... |
additional arguments |
method extract
This function requires data to have been dumped to disk: see ?dump2dir
and ?setoutput
. extract.lgcpPredict
extracts chunks of data that have been dumped to disk. The subset of data can either be specified using an (x,y,t,s) box or (window,t,s) region
where window is a polygonal subregion of interest.
## S3 method for class 'lgcpPredict' extract( obj, x = NULL, y = NULL, t, s = -1, inWindow = NULL, crop2parentwindow = TRUE, ... )
## S3 method for class 'lgcpPredict' extract( obj, x = NULL, y = NULL, t, s = -1, inWindow = NULL, crop2parentwindow = TRUE, ... )
obj |
an object of class lgcpPredict |
x |
range of x-indices: vector (eg c(2,4)) corresponding to desired subset of x coordinates. If equal to -1, then all cells in this dimension are extracted |
y |
range of y-indices as above |
t |
range of t-indices: time indices of interest |
s |
range of s-indices ie the simulation indices of interest |
inWindow |
an observation owin window over which to extract the data (alternative to specifying x and y). |
crop2parentwindow |
logical: whether to only extract cells inside obj$xyt$window (the 'parent window') |
... |
additional arguments |
extracted array
lgcpPredict, loc2poly, dump2dir, setoutput
extracting subsets of an mstppp object.
"x[subset]"
"x[subset]"
x |
an object of class mstppp |
subset |
subsetto extract |
extracts subset of an mstppp object
extracting subsets of an stppp object.
"x[subset]"
"x[subset]"
x |
an object of class stppp |
subset |
the subset to extract |
extracts subset of an stppp object
## Not run: xyt <- lgcpSim() ## Not run: xyt ## Not run: xyt[xyt$t>0.5]
## Not run: xyt <- lgcpSim() ## Not run: xyt ## Not run: xyt[xyt$t>0.5]
! As of lgcp version 0.9-5, this function is no longer used !
fftgrid(xyt, M, N, spatial, sigma, phi, model, covpars, inclusion = "touching")
fftgrid(xyt, M, N, spatial, sigma, phi, model, covpars, inclusion = "touching")
xyt |
object of class stppp |
M |
number of centroids in x-direction |
N |
number of centroids in y-direction |
spatial |
an object of class spatialAtRisk |
sigma |
scaling paramter for spatial covariance function, see Brix and Diggle (2001) |
phi |
scaling paramter for spatial covariance function, see Brix and Diggle (2001) |
model |
correlation type see ?CovarianceFct |
covpars |
vector of additional parameters for certain classes of covariance function (eg Matern), these must be supplied in the order given in ?CovarianceFct |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
Advanced use only. Computes various quantities for use in lgcpPredict
,
lgcpSim
.
fft objects for use in MALA
Generic function used for computing interpolations used in the function fftgrid.
fftinterpolate(spatial, ...)
fftinterpolate(spatial, ...)
spatial |
an object |
... |
additional arguments |
method fftinterpolate
This method performs interpolation within the function fftgrid
for fromFunction
objects.
## S3 method for class 'fromFunction' fftinterpolate(spatial, mcens, ncens, ext, ...)
## S3 method for class 'fromFunction' fftinterpolate(spatial, mcens, ncens, ext, ...)
spatial |
objects of class spatialAtRisk |
mcens |
x-coordinates of interpolation grid in extended space |
ncens |
y-coordinates of interpolation grid in extended space |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
... |
additional arguments |
matrix of interpolated values
fftgrid, spatialAtRisk.function
This method performs interpolation within the function fftgrid
for fromSPDF
objects.
## S3 method for class 'fromSPDF' fftinterpolate(spatial, mcens, ncens, ext, ...)
## S3 method for class 'fromSPDF' fftinterpolate(spatial, mcens, ncens, ext, ...)
spatial |
objects of class spatialAtRisk |
mcens |
x-coordinates of interpolation grid in extended space |
ncens |
y-coordinates of interpolation grid in extended space |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
... |
additional arguments |
matrix of interpolated values
fftgrid, spatialAtRisk.SpatialPolygonsDataFrame
This method performs interpolation within the function fftgrid
for fromXYZ
objects.
## S3 method for class 'fromXYZ' fftinterpolate(spatial, mcens, ncens, ext, ...)
## S3 method for class 'fromXYZ' fftinterpolate(spatial, mcens, ncens, ext, ...)
spatial |
objects of class spatialAtRisk |
mcens |
x-coordinates of interpolation grid in extended space |
ncens |
y-coordinates of interpolation grid in extended space |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
... |
additional arguments |
matrix of interpolated values
fftgrid, spatialAtRisk.fromXYZ
A function to pre-multiply a vector by a block cirulant matrix
fftmultiply(efb, vector)
fftmultiply(efb, vector)
efb |
eigenvalues of the matrix |
vector |
the vector |
a vector: the product of the matrix and the vector.
A function to creat an object of class "formulaList" from a list of "formula" objects; use to define the model for the main effects prior to running the multivariate MCMC algorithm.
formulaList(X)
formulaList(X)
X |
a list object, each element of which is a formula |
an object of class "formulaList"
Generic function defining the the finalisation step for the gridAverage
class of functions.
The function is called invisibly within MALAlgcp
and facilitates the computation of
Monte Carlo Averages online.
GAfinalise(F, ...)
GAfinalise(F, ...)
F |
an object |
... |
additional arguments |
method GAfinalise
setoutput, GAinitialise, GAupdate, GAreturnvalue
Finalise a Monte Carlo averaging scheme. Divide the sum by the number of iterations.
## S3 method for class 'MonteCarloAverage' GAfinalise(F, ...)
## S3 method for class 'MonteCarloAverage' GAfinalise(F, ...)
F |
an object of class MonteCarloAverage |
... |
additional arguments |
computes Monte Carlo averages
MonteCarloAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullAverage' GAfinalise(F, ...)
## S3 method for class 'nullAverage' GAfinalise(F, ...)
F |
an object of class nullAverage |
... |
additional arguments |
nothing
nullAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
Generic function defining the the initialisation step for the gridAverage
class of functions.
The function is called invisibly within MALAlgcp
and facilitates the computation of
Monte Carlo Averages online.
GAinitialise(F, ...)
GAinitialise(F, ...)
F |
an object |
... |
additional arguments |
method GAinitialise
setoutput, GAupdate, GAfinalise, GAreturnvalue
Initialise a Monte Carlo averaging scheme.
## S3 method for class 'MonteCarloAverage' GAinitialise(F, ...)
## S3 method for class 'MonteCarloAverage' GAinitialise(F, ...)
F |
an object of class MonteCarloAverage |
... |
additional arguments |
nothing
MonteCarloAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullAverage' GAinitialise(F, ...)
## S3 method for class 'nullAverage' GAinitialise(F, ...)
F |
an object of class nullAverage |
... |
additional arguments |
nothing
nullAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
A function to change Ys (spatially correlated noise) into Gammas (white noise). Used in the MALA algorithm.
GammafromY(Y, rootQeigs, mu)
GammafromY(Y, rootQeigs, mu)
Y |
Y matrix |
rootQeigs |
square root of the eigenvectors of the precision matrix |
mu |
parameter of the latent Gaussian field |
Gamma
Generic function defining the the returned value for the gridAverage
class of functions.
The function is called invisibly within MALAlgcp
and facilitates the computation of
Monte Carlo Averages online.
GAreturnvalue(F, ...)
GAreturnvalue(F, ...)
F |
an object |
... |
additional arguments |
method GAreturnvalue
setoutput, GAinitialise, GAupdate, GAfinalise
Returns the required Monte Carlo average.
## S3 method for class 'MonteCarloAverage' GAreturnvalue(F, ...)
## S3 method for class 'MonteCarloAverage' GAreturnvalue(F, ...)
F |
an object of class MonteCarloAverage |
... |
additional arguments |
results from MonteCarloAverage
MonteCarloAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullAverage' GAreturnvalue(F, ...)
## S3 method for class 'nullAverage' GAreturnvalue(F, ...)
F |
an object of class nullAverage |
... |
additional arguments |
nothing
nullAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
Generic function defining the the update step for the gridAverage
class of functions.
The function is called invisibly within MALAlgcp
and facilitates the computation of
Monte Carlo Averages online.
GAupdate(F, ...)
GAupdate(F, ...)
F |
an object |
... |
additional arguments |
method GAupdate
setoutput, GAinitialise, GAfinalise, GAreturnvalue
Update a Monte Carlo averaging scheme. This function performs the Monte Carlo sum online.
## S3 method for class 'MonteCarloAverage' GAupdate(F, ...)
## S3 method for class 'MonteCarloAverage' GAupdate(F, ...)
F |
an object of class MonteCarloAverage |
... |
additional arguments |
updates Monte Carlo sums
MonteCarloAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullAverage' GAupdate(F, ...)
## S3 method for class 'nullAverage' GAupdate(F, ...)
F |
an object of class nullAverage |
... |
additional arguments |
nothing
nullAverage, setoutput, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
A function to create a Gaussian prior.
GaussianPrior(mean, variance)
GaussianPrior(mean, variance)
mean |
a vector of length 2 representing the mean. |
variance |
a 2x2 matrix representing the variance. |
an object of class LogGaussianPrior that can be passed to the function PriorSpec.
LogGaussianPrior, linkPriorSpec.list
## Not run: GaussianPrior(mean=rep(0,9),variance=diag(10^6,9))
## Not run: GaussianPrior(mean=rep(0,9),variance=diag(10^6,9))
A function to
gDisjoint_wg(w, gri)
gDisjoint_wg(w, gri)
w |
X |
gri |
X |
...
A function to generate an FFT grid and associated quantities including cell dimensions, size of extended grid, centroids, cell area, cellInside matrix (a 0/1 matrix: is the centroid of the cell inside the observation window?)
genFFTgrid(study.region, M, N, ext, inclusion = "touching")
genFFTgrid(study.region, M, N, ext, inclusion = "touching")
study.region |
an owin object |
M |
number of cells in x direction |
N |
number of cells in y direction |
ext |
multiplying constant: the size of the extended grid: ext*M by ext*N |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
a list
This function is used to count the number of observations falling inside grid cells.
getCellCounts(x, y, xgrid, ygrid)
getCellCounts(x, y, xgrid, ygrid)
x |
x-coordinates of events |
y |
y-coordinates of events |
xgrid |
x-coordinates of grid centroids |
ygrid |
y-coordinates of grid centroids |
The number of observations in each grid cell.
This function is used to count the number of observations falling inside grid cells, the output is used in the function lgcpPredict.
getCounts(xyt, subset = rep(TRUE, xyt$n), M, N, ext)
getCounts(xyt, subset = rep(TRUE, xyt$n), M, N, ext)
xyt |
stppp or ppp data object |
subset |
Logical vector. Subset of data of interest, by default this is all data. |
M |
number of centroids in x-direction |
N |
number of cnetroids in y-direction |
ext |
how far to extend the grid eg (M,N) to (ext*M,ext*N) |
The number of observations in each grid cell returned on a grid suitable for use in the extended FFT space.
require(spatstat.explore) xyt <- stppp(ppp(runif(100),runif(100)),t=1:100,tlim=c(1,100)) cts <- getCounts(xyt,M=64,N=64,ext=2) # gives an output grid of size 128 by 128 ctssub <- cts[1:64,1:64] # returns the cell counts in the observation # window of interest
require(spatstat.explore) xyt <- stppp(ppp(runif(100),runif(100)),t=1:100,tlim=c(1,100)) cts <- getCounts(xyt,M=64,N=64,ext=2) # gives an output grid of size 128 by 128 ctssub <- cts[1:64,1:64] # returns the cell counts in the observation # window of interest
Internal function for retrieving covariance parameters. not indended for general use.
getCovParameters(obj, ...)
getCovParameters(obj, ...)
obj |
an object |
... |
additional arguments |
method getCovParameters
Internal function for retrieving covariance parameters. not indended for general use.
## S3 method for class 'GPrealisation' getCovParameters(obj, ...)
## S3 method for class 'GPrealisation' getCovParameters(obj, ...)
obj |
an GPrealisation object |
... |
additional arguments |
...
Internal function for retrieving covariance parameters. not indended for general use.
## S3 method for class 'list' getCovParameters(obj, ...)
## S3 method for class 'list' getCovParameters(obj, ...)
obj |
an list object |
... |
additional arguments |
...
A function to get the interpolation methods from a data frame
getinterp(df)
getinterp(df)
df |
a data frame |
The three types of interpolation method employed in the package lgcp are:
'Majority' The interpolated value corresponds to the value of the covariate occupying the largest area of the computational cell.
'ArealWeightedMean' The interpolated value corresponds to the mean of all covariate values contributing to the computational cell weighted by their respective areas.
'ArealWeightedSum' The interpolated value is the sum of all contributing covariates weighed by the proportion of area with respect to the covariate polygons. For example, suppose region A has the same area as a computational grid cell and has 500 inhabitants. If that region occupies half of a computational grid cell, then this interpolation type assigns 250 inhabitants from A to the computational grid cell.
the interpolation methods
A function to download and 'install' lgcpPredictSpatialINLA into the lgcp namespace.
getlgcpPredictSpatialINLA()
getlgcpPredictSpatialINLA()
Does not return anything
A function to retrieve the dependent variables from a formulaList object. Not intended for general use.
getLHSformulaList(fl)
getLHSformulaList(fl)
fl |
an object of class "formulaList" |
the indepentdent variables
A function to perform polygon/polygon overlay operations and form the computational grid, on which inference will eventually take place. For details and examples of using this fucntion, please see the package vignette "Bayesian_lgcp"
getpolyol( data, regionalcovariates = NULL, pixelcovariates = NULL, cellwidth, ext = 2, inclusion = "touching" )
getpolyol( data, regionalcovariates = NULL, pixelcovariates = NULL, cellwidth, ext = 2, inclusion = "touching" )
data |
an object of class ppp or SpatialPolygonsDataFrame, containing the event counts, i.e. the dataset that will eventually be analysed |
regionalcovariates |
an object of class SpatialPolygonsDataFrame containng regionally measured covariate information |
pixelcovariates |
X an object of class SpatialPixelsDataFrame containng regionally measured covariate information |
cellwidth |
the chosen cell width |
ext |
the amount by which to extend the observation window in forming the FFT grid, default is 2. In the case that the point pattern has long range spatial correlation, this may need to be increased. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
an object of class lgcppolyol, which can then be fed into the function getZmat.
chooseCellwidth, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
Generic function for the computation of rotation matrices.
getRotation(xyt, ...)
getRotation(xyt, ...)
xyt |
an object |
... |
additional arguments |
method getRotation
Presently there is no default method, see ?getRotation.stppp
## Default S3 method: getRotation(xyt, ...)
## Default S3 method: getRotation(xyt, ...)
xyt |
an object |
... |
additional arguments |
currently no default implementation
Compute rotation matrix if observation window is a polygonal boundary
## S3 method for class 'stppp' getRotation(xyt, ...)
## S3 method for class 'stppp' getRotation(xyt, ...)
xyt |
an object of class stppp |
... |
additional arguments |
the optimal rotation matrix and rotated data and observation window. Note it may or may not be advantageous to rotate the window, this information is displayed prior to the MALA routine when using lgcpPredict
A function to get an object from a parent frame.
getup(n, lev = 1)
getup(n, lev = 1)
n |
a character string, the name of the object |
lev |
how many levels up the hierarchy to go (see the argument "envir" from the function "get"), default is 1. |
...
A function to construct a design matrix for use with the Bayesian MCMC routines in lgcp. See the vignette "Bayesian_lgcp" for further details on
how to use this function.
getZmat( formula, data, regionalcovariates = NULL, pixelcovariates = NULL, cellwidth, ext = 2, inclusion = "touching", overl = NULL )
getZmat( formula, data, regionalcovariates = NULL, pixelcovariates = NULL, cellwidth, ext = 2, inclusion = "touching", overl = NULL )
formula |
a formula object of the form X ~ var1 + var2 etc. The name of the dependent variable must be "X". Only accepts 'simple' formulae, such as the example given. |
data |
the data to be analysed (using, for example lgcpPredictSpatialPlusPars). Either an object of class ppp, or an object of class SpatialPolygonsDataFrame |
regionalcovariates |
an optional SpatialPolygonsDataFrame object containing covariate information, if applicable |
pixelcovariates |
an optional SpatialPixelsDataFrame object containing covariate information, if applicable |
cellwidth |
the width of computational cells |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
overl |
an object of class "lgcppolyol", created by the function getpolyol. Such an object contains the FFT grid and a polygon/polygon overlay and speeds up computation massively. |
For example, a spatial LGCP model for the would have the form:
X(s) ~ Poisson[R(s)]
R(s) = C_A lambda(s) exp[Z(s)beta+Y(s)]
The function getZmat helps create the matrix Z. The returned object is passed onto an MCMC function, for example lgcpPredictSpatialPlusPars or lgcpPredictAggregateSpatialPlusPars. This function can also be used to help construct Z for use with lgcpPredictSpatioTemporalPlusPars and lgcpPredictMultitypeSpatialPlusPars, but these functions require a list of such objects: see the vignette "Bayesian_lgcp" for examples.
a design matrix for passing on to the Bayesian MCMC functions
chooseCellwidth, getpolyol, guessinterp, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
An internal function to create Z_k from an lgcpZmat object, for use in the multivariate MCMC algorithm. Not intended for general use.
getZmats(Zmat, formulaList)
getZmats(Zmat, formulaList)
Zmat |
an objecty of class "lgcpZmat" |
formulaList |
an object of class "formulaList" |
design matrices for each of the point types
Generic function defining the the finalisation step for the gridFunction
class of objects.
The function is called invisibly within MALAlgcp
and facilitates the dumping of data to disk
GFfinalise(F, ...)
GFfinalise(F, ...)
F |
an object |
... |
additional arguments |
method GFfinalise
setoutput, GFinitialise, GFupdate, GFreturnvalue
This function finalises the dumping of data to a netCDF file.
## S3 method for class 'dump2dir' GFfinalise(F, ...)
## S3 method for class 'dump2dir' GFfinalise(F, ...)
F |
an object |
... |
additional arguments |
nothing
dump2dir, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullFunction' GFfinalise(F, ...)
## S3 method for class 'nullFunction' GFfinalise(F, ...)
F |
an object of class dump2dir |
... |
additional arguments |
nothing
nullFunction, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
Generic function defining the the initialisation step for the gridFunction
class of objects.
The function is called invisibly within MALAlgcp
and facilitates the dumping of data to disk
GFinitialise(F, ...)
GFinitialise(F, ...)
F |
an object |
... |
additional arguments |
method GFinitialise
setoutput, GFupdate, GFfinalise, GFreturnvalue
Creates a directory (if necessary) and allocates space for a netCDF dump.
## S3 method for class 'dump2dir' GFinitialise(F, ...)
## S3 method for class 'dump2dir' GFinitialise(F, ...)
F |
an object of class dump2dir |
... |
additional arguments |
creates initialisation file and folder
dump2dir, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullFunction' GFinitialise(F, ...)
## S3 method for class 'nullFunction' GFinitialise(F, ...)
F |
an object of class dump2dir |
... |
additional arguments |
nothing
nullFunction, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
Generic function defining the the returned value for the gridFunction
class of objects.
The function is called invisibly within MALAlgcp
and facilitates the dumping of data to disk
GFreturnvalue(F, ...)
GFreturnvalue(F, ...)
F |
an object |
... |
additional arguments |
method GFreturnvalue
setoutput, GFinitialise, GFupdate, GFfinalise
This function returns the name of the directory the netCDF file was written to.
## S3 method for class 'dump2dir' GFreturnvalue(F, ...)
## S3 method for class 'dump2dir' GFreturnvalue(F, ...)
F |
an object |
... |
additional arguments |
display where files have been written to
dump2dir, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullFunction' GFreturnvalue(F, ...)
## S3 method for class 'nullFunction' GFreturnvalue(F, ...)
F |
an object of class dump2dir |
... |
additional arguments |
nothing
nullFunction, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
Generic function defining the the update step for the gridFunction
class of objects.
The function is called invisibly within MALAlgcp
and facilitates the dumping of data to disk
GFupdate(F, ...)
GFupdate(F, ...)
F |
an object |
... |
additional arguments |
method GFupdate
setoutput, GFinitialise, GFfinalise, GFreturnvalue
This function gets the required information from MALAlgcp
and writes the data to the netCDF file.
## S3 method for class 'dump2dir' GFupdate(F, ...)
## S3 method for class 'dump2dir' GFupdate(F, ...)
F |
an object |
... |
additional arguments |
saves latent field
dump2dir, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
This is a null function and performs no action.
## S3 method for class 'nullFunction' GFupdate(F, ...)
## S3 method for class 'nullFunction' GFupdate(F, ...)
F |
an object of class dump2dir |
... |
additional arguments |
nothing
nullFunction, setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
A function to estimate the inhomogeneous pair correlation function for a spatiotemporal point process. See equation (8) of Diggle P, Rowlingson B, Su T (2005).
ginhomAverage( xyt, spatial.intensity, temporal.intensity, time.window = xyt$tlim, rvals = NULL, correction = "iso", suppresswarnings = FALSE, ... )
ginhomAverage( xyt, spatial.intensity, temporal.intensity, time.window = xyt$tlim, rvals = NULL, correction = "iso", suppresswarnings = FALSE, ... )
xyt |
an object of class stppp |
spatial.intensity |
A spatialAtRisk object |
temporal.intensity |
A temporalAtRisk object |
time.window |
time interval contained in the interval xyt$tlim over which to compute average. Useful if there is a lot of data over a lot of time points. |
rvals |
Vector of values for the argument r at which g(r) should be evaluated (see ?pcfinhom). There is a sensible default. |
correction |
choice of edge correction to use, see ?pcfinhom, default is Ripley isotropic correction |
suppresswarnings |
Whether or not to suppress warnings generated by pcfinhom |
... |
other parameters to be passed to pcfinhom, see ?pcfinhom |
time average of inhomogenous pcf, equation (13) of Brix and Diggle 2001.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Baddeley AJ, Moller J, Waagepetersen R (2000). Non-and semi-parametric estimation of interaction in inhomogeneous point patterns. Statistica Neerlandica, 54, 329-350.
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
KinhomAverage, spatialparsEst, thetaEst, lambdaEst, muEst
A function to
gIntersects_pg(spdf, grid)
gIntersects_pg(spdf, grid)
spdf |
X |
grid |
X |
...
A function to overlay the FFT grid, a SpatialPolygons object, onto a SpatialPolygonsDataFrame object.
gOverlay(grid, spdf)
gOverlay(grid, spdf)
grid |
the FFT grid, a SpatialPolygons object |
spdf |
a SpatialPolygonsDataFrame object |
this code was adapted from Roger Bivand:
https://stat.ethz.ch/pipermail/r-sig-geo/2011-June/012099.html
a matrix describing the features of the overlay: the originating indices of grid and spdf (all non-trivial intersections) and the area of each intersection.
A function to compute the first derivatives of the log target with respect to the paramters of the latent field. Not intended for general purpose use.
GPdrv( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc, fftgrid, covfunction, d, eps = 1e-06 )
GPdrv( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc, fftgrid, covfunction, d, eps = 1e-06 )
GP |
an object of class GPrealisation |
prior |
priors for the model |
Z |
design matirix on the FFT grid |
Zt |
transpose of the design matrix |
eta |
vector of parameters, eta |
beta |
vector of parameters, beta |
nis |
cell counts on the extended grid |
cellarea |
the cell area |
spatial |
the poisson offset |
gradtrunc |
gradient truncation parameter |
fftgrid |
an object of class FFTgrid |
covfunction |
the choice of covariance function, see ?CovFunction |
d |
matrix of toral distances |
eps |
the finite difference step size |
first derivatives of the log target at the specified paramters Y, eta and beta
A function to compute the second derivative of the log target with respect to the paramters of the latent field. Not intended for general purpose use.
GPdrv2( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc, fftgrid, covfunction, d, eps = 1e-06 )
GPdrv2( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc, fftgrid, covfunction, d, eps = 1e-06 )
GP |
an object of class GPrealisation |
prior |
priors for the model |
Z |
design matirix on the FFT grid |
Zt |
transpose of the design matrix |
eta |
vector of parameters, eta |
beta |
vector of parameters, beta |
nis |
cell counts on the extended grid |
cellarea |
the cell area |
spatial |
the poisson offset |
gradtrunc |
gradient truncation parameter |
fftgrid |
an object of class FFTgrid |
covfunction |
the choice of covariance function, see ?CovFunction |
d |
matrix of toral distances |
eps |
the finite difference step size |
first and second derivatives of the log target at the specified paramters Y, eta and beta
A function to compute the second derivatives of the log target for the multivariate model with respect to the paramters of the latent field. Not intended for general use.
GPdrv2_Multitype( GPlist, priorlist, Zlist, Ztlist, etalist, betalist, nis, cellarea, spatial, gradtrunc, fftgrid, covfunction, d, eps = 1e-06, k )
GPdrv2_Multitype( GPlist, priorlist, Zlist, Ztlist, etalist, betalist, nis, cellarea, spatial, gradtrunc, fftgrid, covfunction, d, eps = 1e-06, k )
GPlist |
a list of objects of class GPrealisation |
priorlist |
list of priors for the model |
Zlist |
list of design matirices on the FFT grid |
Ztlist |
list of transpose design matrices |
etalist |
list of parameters, eta, for each realisation |
betalist |
clist of parameters, beta, for each realisation |
nis |
cell counts of each type the extended grid |
cellarea |
the cell area |
spatial |
list of poisson offsets for each type |
gradtrunc |
gradient truncation parameter |
fftgrid |
an object of class FFTgrid |
covfunction |
list giving the choice of covariance function for each type, see ?CovFunction |
d |
matrix of toral distances |
eps |
the finite difference step size |
k |
index of type for which to compute the gradient and hessian |
first and second derivatives of the log target for tyupe k at the specified paramters Y, eta and beta
An internal function for turning a list of GPrealisation objects into an an array by a particular common element of the GPrealisation object
GPlist2array(GPlist, element)
GPlist2array(GPlist, element)
GPlist |
an object of class GPrealisation |
element |
the name of the element of GPlist[[1]] (for example) to extract, e.g. "Y" |
an array
A function to store a realisation of a spatial gaussian process for use in MCMC algorithms that include Bayesian parameter estimation. Stores not only the realisation, but also computational quantities.
GPrealisation(gamma, fftgrid, covFunction, covParameters, d)
GPrealisation(gamma, fftgrid, covFunction, covParameters, d)
gamma |
the transformed (white noise) realisation of the process |
fftgrid |
an object of class FFTgrid, see ?genFFTgrid |
covFunction |
an object of class function returning the spatial covariance |
covParameters |
an object of class CovParamaters, see ?CovParamaters |
d |
matrix of grid distances |
a realisation of a spatial Gaussian process on a regular grid
A function to convert a regular (x,y) grid of centroids into a SpatialPoints object
grid2spdf(xgrid, ygrid, proj4string = CRS(as.character(NA)))
grid2spdf(xgrid, ygrid, proj4string = CRS(as.character(NA)))
xgrid |
vector of x centroids (equally spaced) |
ygrid |
vector of x centroids (equally spaced) |
proj4string |
an optional proj4string, projection string for the grid, set using the function CRS |
a SpatialPolygonsDataFrame
A function to convert a regular (x,y) grid of centroids into a SpatialPixels object
grid2spix(xgrid, ygrid, proj4string = CRS(as.character(NA)))
grid2spix(xgrid, ygrid, proj4string = CRS(as.character(NA)))
xgrid |
vector of x centroids (equally spaced) |
ygrid |
vector of x centroids (equally spaced) |
proj4string |
an optional proj4string, projection string for the grid, set using the function CRS |
a SpatialPixels object
A function to convert a regular (x,y) grid of centroids into a SpatialPolygons object
grid2spoly(xgrid, ygrid, proj4string = CRS(as.character(NA)))
grid2spoly(xgrid, ygrid, proj4string = CRS(as.character(NA)))
xgrid |
vector of x centroids (equally spaced) |
ygrid |
vector of x centroids (equally spaced) |
proj4string |
proj 4 string: specify in the usual way |
a SpatialPolygons object
A function to convert a regular (x,y) grid of centroids into a SpatialPoints object
grid2spts(xgrid, ygrid, proj4string = CRS(as.character(NA)))
grid2spts(xgrid, ygrid, proj4string = CRS(as.character(NA)))
xgrid |
vector of x centroids (equally spaced) |
ygrid |
vector of x centroids (equally spaced) |
proj4string |
an optional proj4string, projection string for the grid, set using the function CRS |
a SpatialPoints object
A generic function for returning gridmeans
objects.
gridav(obj, ...)
gridav(obj, ...)
obj |
an object |
... |
additional arguments |
method gridav
Accessor function for lgcpPredict objects
: returns the gridmeans
argument
set in the output.control
argument of the function lgcpPredict
.
## S3 method for class 'lgcpPredict' gridav(obj, fun = NULL, ...)
## S3 method for class 'lgcpPredict' gridav(obj, fun = NULL, ...)
obj |
an object of class lgcpPredict |
fun |
an optional character vector of length 1 giving the name of a function to return Monte Carlo average of |
... |
additional arguments |
returns the output from the gridmeans option of the setoutput argument of lgcpPredict
A generic function for returning gridfunction
objects.
gridfun(obj, ...)
gridfun(obj, ...)
obj |
an object |
... |
additional arguments |
method gridfun
Accessor function for lgcpPredict objects
: returns the gridfunction
argument
set in the output.control
argument of the function lgcpPredict
.
## S3 method for class 'lgcpPredict' gridfun(obj, ...)
## S3 method for class 'lgcpPredict' gridfun(obj, ...)
obj |
an object of class lgcpPredict |
... |
additional arguments |
returns the output from the gridfunction option of the setoutput argument of lgcpPredict
For the grid defined by x-coordinates, xvals, and y-coordinates, yvals, and an owin object W, this function just returns a logical matrix M, whose [i,j] entry is TRUE if the point(xvals[i], yvals[j]) is inside the observation window.
gridInWindow(xvals, yvals, win, inclusion = "touching")
gridInWindow(xvals, yvals, win, inclusion = "touching")
xvals |
x coordinates |
yvals |
y coordinates |
win |
owin object |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
matrix of TRUE/FALSE, which elements of the grid are inside the observation window win
A function to
gTouches_wg(w, gri)
gTouches_wg(w, gri)
w |
X |
gri |
X |
...
gu function
gu(u, sigma, phi, model, additionalparameters)
gu(u, sigma, phi, model, additionalparameters)
u |
distance |
sigma |
variance parameter, see Brix and Diggle (2001) |
phi |
scale parameter, see Brix and Diggle (2001) |
model |
correlation type, see ?CovarianceFct |
additionalparameters |
vector of additional parameters for certain classes of covariance function (eg Matern), these must be supplied in the order given in ?CovarianceFct |
this is just a wrapper for CovarianceFct
A function to guess provisional interpolational methods to variables in a data frame. Numeric variables are assigned interpolation by areal weighted mean (see below); factor, character and other types of variable are assigned interpolation by majority vote (see below). Not that the interpolation type ArealWeightedSum is not assigned automatically.
guessinterp(df)
guessinterp(df)
df |
a data frame |
The three types of interpolation method employed in the package lgcp are:
'Majority' The interpolated value corresponds to the value of the covariate occupying the largest area of the computational cell.
'ArealWeightedMean' The interpolated value corresponds to the mean of all covariate values contributing to the computational cell weighted by their respective areas.
'ArealWeightedSum' The interpolated value is the sum of all contributing covariates weighed by the proportion of area with respect to the covariate polygons. For example, suppose region A has the same area as a computational grid cell and has 500 inhabitants. If that region occupies half of a computational grid cell, then this interpolation type assigns 250 inhabitants from A to the computational grid cell.
the data frame, but with attributes describing the interpolation method for each variable
chooseCellwidth, getpolyol, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
## Not run: spdf a SpatialPolygonsDataFrame ## Not run: spdf@data <- guessinterp(spdf@data)
## Not run: spdf a SpatialPolygonsDataFrame ## Not run: spdf@data <- guessinterp(spdf@data)
test if an iterator has any more values to go
hasNext(obj)
hasNext(obj)
obj |
an iterator |
method for iter objects test if an iterator has any more values to go
## S3 method for class 'iter' hasNext(obj)
## S3 method for class 'iter' hasNext(obj)
obj |
an iterator |
Generic function to return the values of the proposal scaling in the MCMC algorithm.
hvals(obj, ...)
hvals(obj, ...)
obj |
an object |
... |
additional arguments |
method hvals
Accessor function returning the value of , the MALA proposal scaling constant over the iterations of the algorithm for
objects of class
lgcpPredict
## S3 method for class 'lgcpPredict' hvals(obj, ...)
## S3 method for class 'lgcpPredict' hvals(obj, ...)
obj |
an object of class lgcpPredict |
... |
additional arguments |
returns the values of h taken during the progress of the algorithm
Identifies the indices of grid cells on plots of lgcpPredict
objects. Can be used to identify
a small number of cells for further information eg trace or autocorrelation plots (provided data has been dumped to disk). On calling
identify(lg)
for example (see code below), the user can click multiply with the left mouse button on the graphics device; once
the user has selected all points of interest, the right button is pressed, which returns them.
## S3 method for class 'lgcpPredict' identify(x, ...)
## S3 method for class 'lgcpPredict' identify(x, ...)
x |
an object of class lgcpPredict |
... |
additional arguments |
a 2 x n matrix containing the grid indices of the points of interest, where n is the number of points selected via the mouse.
## Not run: plot(lg) # lg an lgcpPredict object ## Not run: pt_indices <- identify(lg)
## Not run: plot(lg) # lg an lgcpPredict object ## Not run: pt_indices <- identify(lg)
Identifies the indices of grid cells on plots of objects.
identifygrid(x, y)
identifygrid(x, y)
x |
the x grid centroids |
y |
the y grid centroids |
a 2 x n matrix containing the grid indices of the points of interest, where n is the number of points selected via the mouse.
lgcpPredict, loc2poly, identify.lgcpPredict
Produce an image plot of an lgcpgrid object.
## S3 method for class 'lgcpgrid' image(x, sel = 1:x$len, ask = TRUE, ...)
## S3 method for class 'lgcpgrid' image(x, sel = 1:x$len, ask = TRUE, ...)
x |
an object of class lgcpgrid |
sel |
vector of integers between 1 and grid$len: which grids to plot. Default NULL, in which case all grids are plotted. |
ask |
logical; if TRUE the user is asked before each plot |
... |
other arguments |
grid plotting
lgcpgrid.list, lgcpgrid.array, as.list.lgcpgrid, print.lgcpgrid, summary.lgcpgrid, quantile.lgcpgrid, plot.lgcpgrid
A generic to be used for the purpose of user-defined adaptive MCMC schemes, initialiseAMCMC tells the MALA algorithm which value of h to use first. See lgcp vignette, codevignette("lgcp"), for further details on writing adaptive MCMC schemes.
initialiseAMCMC(obj, ...)
initialiseAMCMC(obj, ...)
obj |
an object |
... |
additional arguments |
method intialiseAMCMC
initialiseAMCMC.constanth, initialiseAMCMC.andrieuthomsh
Initialises the andrieuthomsh adaptive scheme.
## S3 method for class 'andrieuthomsh' initialiseAMCMC(obj, ...)
## S3 method for class 'andrieuthomsh' initialiseAMCMC(obj, ...)
obj |
an object |
... |
additional arguments |
initial h for scheme
Andrieu C, Thoms J (2008). A tutorial on adaptive MCMC. Statistics and Computing, 18(4), 343-373.
Robbins H, Munro S (1951). A Stochastic Approximation Methods. The Annals of Mathematical Statistics, 22(3), 400-407.
Roberts G, Rosenthal J (2001). Optimal Scaling for Various Metropolis-Hastings Algorithms. Statistical Science, 16(4), 351-367.
Initialises the constanth adaptive scheme.
## S3 method for class 'constanth' initialiseAMCMC(obj, ...)
## S3 method for class 'constanth' initialiseAMCMC(obj, ...)
obj |
an object |
... |
additional arguments |
initial h for scheme
Generic function for converting the time variable of an stppp object.
integerise(obj, ...)
integerise(obj, ...)
obj |
an object |
... |
additional arguments |
method integerise
Function for converting the times and time limits of an mstppp object into integer values.
## S3 method for class 'mstppp' integerise(obj, ...)
## S3 method for class 'mstppp' integerise(obj, ...)
obj |
an mstppp object |
... |
additional arguments |
The mstppp object, but with integerised times.
Function for converting the times and time limits of an stppp object into integer values. Do this before estimating mu(t), and hence before creating the temporalAtRisk object. Not taking this step is possible in lgcp, but can cause minor complications connected with the scaling of mu(t).
## S3 method for class 'stppp' integerise(obj, ...)
## S3 method for class 'stppp' integerise(obj, ...)
obj |
an stppp object |
... |
additional arguments |
The stppp object, but with integerised times.
Generic function to return the Poisson Intensity.
intens(obj, ...)
intens(obj, ...)
obj |
an object |
... |
additional arguments |
method intens
lgcpPredict, intens.lgcpPredict
Accessor function returning the Poisson intensity as an lgcpgrid object.
## S3 method for class 'lgcpPredict' intens(obj, ...)
## S3 method for class 'lgcpPredict' intens(obj, ...)
obj |
an lgcpPredict object |
... |
additional arguments |
the cell-wise mean Poisson intensity, as computed by MCMC.
A function to return the cellwise Poisson intensity used during in constructing the simulated data.
"intens(obj, ...)"
"intens(obj, ...)"
obj |
an object of class lgcpSimMultitypeSpatialPlusParameters |
... |
other parameters |
the Poisson intensity
A function to return the cellwise Poisson intensity used during in constructing the simulated data.
## S3 method for class 'lgcpSimSpatialPlusParameters' intens(obj, ...)
## S3 method for class 'lgcpSimSpatialPlusParameters' intens(obj, ...)
obj |
an object of class lgcpSimSpatialPlusParameters |
... |
other parameters |
the Poisson intensity
A function to return the types of covariate interpolation available
interptypes()
interptypes()
The three types of interpolation method employed in the package lgcp are:
'Majority' The interpolated value corresponds to the value of the covariate occupying the largest area of the computational cell.
'ArealWeightedMean' The interpolated value corresponds to the mean of all covariate values contributing to the computational cell weighted by their respective areas.
'ArealWeightedSum' The interpolated value is the sum of all contributing covariates weighed by the proportion of area with respect to the covariate polygons. For example, suppose region A has the same area as a computational grid cell and has 500 inhabitants. If that region occupies half of a computational grid cell, then this interpolation type assigns 250 inhabitants from A to the computational grid cell.
character string of available interpolation types
A function to compute the base of the inverse os a block circulant matrix, given the base of the matrix
inversebase(x)
inversebase(x)
x |
the base matrix of a block circulant matrix |
the base matrix of the inverse of the circulant matrix
if this mcmc iteration is in the burn-in period, return TRUE
is.burnin(obj)
is.burnin(obj)
obj |
an mcmc iterator |
TRUE or FALSE
Tests whether a number id
is.pow2(num)
is.pow2(num)
num |
a numeric |
logical: is num a power of 2?
is.pow2(128) # TRUE is.pow2(64.9) # FALSE
is.pow2(128) # TRUE is.pow2(64.9) # FALSE
if this mcmc iteration is one not thinned out, this is true
is.retain(obj)
is.retain(obj)
obj |
an mcmc iterator |
TRUE or FALSE
A function to compute whether a block circulant matrix is symmetric positive definite (SPD), given its base matrix.
is.SPD(base)
is.SPD(base)
base |
base matrix of a block circulant matrix |
logical, whether the circulant matrix the base represents is SPD
within a loop, this is the iteration number we are currently doing.
iteration(obj)
iteration(obj)
obj |
an mcmc iterator |
get the iteration number
integer iteration number, starting from 1.
A function to estimate the inhomogeneous K function for a spatiotemporal point process. The method of computation is similar to ginhomAverage, see eq (8) Diggle P, Rowlingson B, Su T (2005) to see how this is computed.
KinhomAverage( xyt, spatial.intensity, temporal.intensity, time.window = xyt$tlim, rvals = NULL, correction = "iso", suppresswarnings = FALSE )
KinhomAverage( xyt, spatial.intensity, temporal.intensity, time.window = xyt$tlim, rvals = NULL, correction = "iso", suppresswarnings = FALSE )
xyt |
an object of class stppp |
spatial.intensity |
A spatialAtRisk object |
temporal.intensity |
A temporalAtRisk object |
time.window |
time interval contained in the interval xyt$tlim over which to compute average. Useful if there is a lot of data over a lot of time points. |
rvals |
Vector of values for the argument r at which the inhmogeneous K function should be evaluated (see ?Kinhom). There is a sensible default. |
correction |
choice of edge correction to use, see ?Kinhom, default is Ripley isotropic correction |
suppresswarnings |
Whether or not to suppress warnings generated by Kinhom |
time average of inhomogenous K function.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Baddeley AJ, Moller J, Waagepetersen R (2000). Non-and semi-parametric estimation of interaction in inhomogeneous point patterns. Statistica Neerlandica, 54, 329-350.
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
ginhomAverage, spatialparsEst, thetaEst, lambdaEst, muEst
Generic function for estimating bivariate densities by eye. Specific methods exist for stppp objects and ppp objects.
lambdaEst(xyt, ...)
lambdaEst(xyt, ...)
xyt |
an object |
... |
additional arguments |
method lambdaEst
lambdaEst.stppp, lambdaEst.ppp
A tool for the visual estimation of lambda(s) via a 2 dimensional smoothing of the case locations. For parameter estimation, the alternative is
to estimate lambda(s) by some other means, convert it into a spatialAtRisk object and then into a pixel image object using the build in coercion
methods, this im
object can then be fed to ginhomAverage, KinhomAverage or thetaEst for instance.
## S3 method for class 'ppp' lambdaEst(xyt, weights = c(), edge = TRUE, bw = NULL, ...)
## S3 method for class 'ppp' lambdaEst(xyt, weights = c(), edge = TRUE, bw = NULL, ...)
xyt |
object of class stppp |
weights |
Optional vector of weights to be attached to the points. May include negative values. See ?density.ppp. |
edge |
Logical flag: if TRUE, apply edge correction. See ?density.ppp. |
bw |
optional bandwidth. Set to NULL by default, which calls teh resolve.2D.kernel function for computing an initial value of this |
... |
arguments to be passed to plot |
The function lambdaEst is built directly on the density.ppp function and as such, implements a bivariate Gaussian smoothing kernel. The bandwidth is initially that which is automatically chosen by the default method of density.ppp. Since image plots of these kernel density estimates may not have appropriate colour scales, the ability to adjust this is given with the slider 'colour adjustment'. With colour adjustment set to 1, the default image.plot for the equivalent pixel image object is shown and for values less than 1, the colour scheme is more spread out, allowing the user to get a better feel for the density that is being fitted. NOTE: colour adjustment does not affect the returned density and the user should be aware that the returned density will 'look like' that displayed when colour adjustment is set equal to 1.
This is an rpanel function for visual choice of lambda(s), the output is a variable, varname, with the density *per unit time* the variable varname can be fed to the function ginhomAverage or KinhomAverage as the argument density (see for example ?ginhomAverage), or into the function thetaEst as the argument spatial.intensity.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
spatialAtRisk, ginhomAverage, KinhomAverage, spatialparsEst, thetaEst, muEst
A tool for the visual estimation of lambda(s) via a 2 dimensional smoothing of the case locations. For parameter estimation, the alternative is
to estimate lambda(s) by some other means, convert it into a spatialAtRisk object and then into a pixel image object using the build in coercion
methods, this im
object can then be fed to ginhomAverage, KinhomAverage or thetaEst for instance.
## S3 method for class 'stppp' lambdaEst(xyt, weights = c(), edge = TRUE, bw = NULL, ...)
## S3 method for class 'stppp' lambdaEst(xyt, weights = c(), edge = TRUE, bw = NULL, ...)
xyt |
object of class stppp |
weights |
Optional vector of weights to be attached to the points. May include negative values. See ?density.ppp. |
edge |
Logical flag: if TRUE, apply edge correction. See ?density.ppp. |
bw |
optional bandwidth. Set to NULL by default, which calls teh resolve.2D.kernel function for computing an initial value of this |
... |
arguments to be passed to plot |
The function lambdaEst is built directly on the density.ppp function and as such, implements a bivariate Gaussian smoothing kernel. The bandwidth is initially that which is automatically chosen by the default method of density.ppp. Since image plots of these kernel density estimates may not have appropriate colour scales, the ability to adjust this is given with the slider 'colour adjustment'. With colour adjustment set to 1, the default image.plot for the equivalent pixel image object is shown and for values less than 1, the colour scheme is more spread out, allowing the user to get a better feel for the density that is being fitted. NOTE: colour adjustment does not affect the returned density and the user should be aware that the returned density will 'look like' that displayed when colour adjustment is set equal to 1.
This is an rpanel function for visual choice of lambda(s), the output is a variable, varname, with the density *per unit time* the variable varname can be fed to the function ginhomAverage or KinhomAverage as the argument density (see for example ?ginhomAverage), or into the function thetaEst as the argument spatial.intensity.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
spatialAtRisk, ginhomAverage, KinhomAverage, spatialparsEst, thetaEst, muEst
Display the introductory vignette for the lgcp package.
lgcpbayes()
lgcpbayes()
displays the vignette by calling browseURL
Function to produce forecasts for the mean field at times beyond the last time point in the
analysis (given by the argument
T
in the function lgcpPredict
).
lgcpForecast( lg, ptimes, spatial.intensity, temporal.intensity, inclusion = "touching" )
lgcpForecast( lg, ptimes, spatial.intensity, temporal.intensity, inclusion = "touching" )
lg |
an object of class lgcpPredict |
ptimes |
vector of time points for prediction. Must start strictly after last inferred time point. |
spatial.intensity |
the fixed spatial component: an object of that can be coerced to one of class spatialAtRisk |
temporal.intensity |
the fixed temporal component: either a numeric vector, or a function that can be coerced into an object of class temporalAtRisk |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
forcasted relative risk, Poisson intensities and Y values over grid, together with approximate variance.
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Generic function for the hadling of list objects where each element of the list is a matrix. Each matrix is assumed to have the same dimension. Such objects arise from the various routines in the package lgcp.
lgcpgrid(grid, ...)
lgcpgrid(grid, ...)
grid |
a list object with each member of the list being a numeric matrix, each matrix having the same dimension |
... |
other arguments |
lgcpgrid objects are list objects with names len, nrow, ncol, grid, xvals, yvals, zvals. The first three elements of the list store the dimension of the object, the fourth element, grid, is itself a list object consisting of matrices in which the data is stored. The last three arguments can be used to give what is effectively a 3 dimensional array a physical reference.
For example, the mean of Y from a call to lgcpPredict, obj$y.mean for example, is stored in an lgcpgrid object. If several time points have been stored in the call to lgcpPredict, then the grid element of the lgcpgrid object contains the output for each of the time points in succession. So the first element, obj$y.mean$grid[[1]],contains the output from the first time point and so on.
method lgcpgrid
lgcpgrid.list, lgcpgrid.array, lgcpgrid.matrix
Creates an lgcp grid object from an 3-dimensional array.
## S3 method for class 'array' lgcpgrid( grid, xvals = 1:dim(grid)[1], yvals = 1:dim(grid)[2], zvals = 1:dim(grid)[3], ... )
## S3 method for class 'array' lgcpgrid( grid, xvals = 1:dim(grid)[1], yvals = 1:dim(grid)[2], zvals = 1:dim(grid)[3], ... )
grid |
a three dimensional array object |
xvals |
optional vector of x-coordinates associated to grid. By default, this is the cell index in the x direction. |
yvals |
optional vector of y-coordinates associated to grid. By default, this is the cell index in the y direction. |
zvals |
optional vector of z-coordinates (time) associated to grid. By default, this is the cell index in the z direction. |
... |
other arguments |
an object of class lgcpgrid
lgcpgrid.list, as.list.lgcpgrid, print.lgcpgrid, summary.lgcpgrid, quantile.lgcpgrid, image.lgcpgrid, plot.lgcpgrid
Creates an lgcpgrid object from a list object plus some optional coordinates. Note that each element of the list should be a matrix, and that each matrix should have the same dimension.
## S3 method for class 'list' lgcpgrid( grid, xvals = 1:dim(grid[[1]])[1], yvals = 1:dim(grid[[1]])[2], zvals = 1:length(grid), ... )
## S3 method for class 'list' lgcpgrid( grid, xvals = 1:dim(grid[[1]])[1], yvals = 1:dim(grid[[1]])[2], zvals = 1:length(grid), ... )
grid |
a list object with each member of the list being a numeric matrix, each matrix having the same dimension |
xvals |
optional vector of x-coordinates associated to grid. By default, this is the cell index in the x direction. |
yvals |
optional vector of y-coordinates associated to grid. By default, this is the cell index in the y direction. |
zvals |
optional vector of z-coordinates (time) associated to grid. By default, this is the cell index in the z direction. |
... |
other arguments |
an object of class lgcpgrid
lgcpgrid.array, as.list.lgcpgrid, print.lgcpgrid, summary.lgcpgrid, quantile.lgcpgrid, image.lgcpgrid, plot.lgcpgrid
Creates an lgcp grid object from an 2-dimensional matrix.
## S3 method for class 'matrix' lgcpgrid(grid, xvals = 1:nrow(grid), yvals = 1:ncol(grid), ...)
## S3 method for class 'matrix' lgcpgrid(grid, xvals = 1:nrow(grid), yvals = 1:ncol(grid), ...)
grid |
a three dimensional array object |
xvals |
optional vector of x-coordinates associated to grid. By default, this is the cell index in the x direction. |
yvals |
optional vector of y-coordinates associated to grid. By default, this is the cell index in the y direction. |
... |
other arguments |
an object of class lgcpgrid
lgcpgrid.list, as.list.lgcpgrid, print.lgcpgrid, summary.lgcpgrid, quantile.lgcpgrid, image.lgcpgrid, plot.lgcpgrid
A function to declare initial values for a run of the MCMC routine. If specified, the MCMC algorithm will calibrate the proposal density using these as provisional estimates of the parameters.
lgcpInits(etainit = NULL, betainit = NULL)
lgcpInits(etainit = NULL, betainit = NULL)
etainit |
a vector, the initial value of eta to use |
betainit |
a vector, the initial value of beta to use, this vector must have names the same as the variable names in the formula in use, and in the same order. |
It is not necessary to supply intial values to the MCMC routine, by default the functions lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars and lgcpPredictMultitypeSpatialPlusPars will initialise the MCMC as follows. For eta, if no initial value is specified then the initial value of eta in the MCMC run will be the prior mean. For beta, if no initial value is specified then the initial value of beta in the MCMC run will be estimated from an overdispersed Poisson fit to the cell counts, ignoring spatial correlation. The user cannot specify an initial value of Y (or equivalently Gamma), as a sensible value is chosen by the MCMC function.
A secondary function of specifying initial values is to help design the MCMC proposal matrix, which is based on these initial estimates.
an object of class lgcpInits used in the MCMC routine.
chooseCellwidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, CovFunction, lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
## Not run: INITS <- lgcpInits(etainit=log(c(sqrt(1.5),275)), betainit=NULL)
## Not run: INITS <- lgcpInits(etainit=log(c(sqrt(1.5),275)), betainit=NULL)
A function for setting the parameters sigma, phi and theta for lgcpPredict
. Note that the returned
set of parameters also features mu=-0.5*sigma^2, gives mean(exp(Y)) = 1.
lgcppars(sigma = NULL, phi = NULL, theta = NULL, mu = NULL, beta = NULL)
lgcppars(sigma = NULL, phi = NULL, theta = NULL, mu = NULL, beta = NULL)
sigma |
sigma parameter |
phi |
phi parameter |
theta |
this is 'beta' parameter in Brix and Diggle (2001) |
mu |
the mean of the latent field, if equal to NULL, this is set to -sigma^2/2 |
beta |
ONLY USED IN case where there is covariate information. |
The function lgcpPredict
performs spatiotemporal prediction for log-Gaussian Cox Processes
lgcpPredict( xyt, T, laglength, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, temporal.intensity, mcmc.control, output.control = setoutput(), missing.data.areas = NULL, autorotate = FALSE, gradtrunc = Inf, ext = 2, inclusion = "touching" )
lgcpPredict( xyt, T, laglength, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, temporal.intensity, mcmc.control, output.control = setoutput(), missing.data.areas = NULL, autorotate = FALSE, gradtrunc = Inf, ext = 2, inclusion = "touching" )
xyt |
a spatio-temporal point pattern object, see ?stppp |
T |
time point of interest |
laglength |
specifies lag window, so that data from and including time (T-laglength) to time T is used in the MALA algorithm |
model.parameters |
values for parameters, see ?lgcppars |
spatial.covmodel |
correlation type see ?CovarianceFct |
covpars |
vector of additional parameters for certain classes of covariance function (eg Matern), these must be supplied in the order given in ?CovarianceFct |
cellwidth |
width of grid cells on which to do MALA (grid cells are square) in same units as observation window. Note EITHER gridsize OR cellwidth must be specified. |
gridsize |
size of output grid required. Note EITHER gridsize OR cellwidthe must be specified. |
spatial.intensity |
the fixed spatial component: an object of that can be coerced to one of class spatialAtRisk |
temporal.intensity |
the fixed temporal component: either a numeric vector, or a function that can be coerced into an object of class temporalAtRisk |
mcmc.control |
MCMC paramters, see ?mcmcpars |
output.control |
output choice, see ?setoutput |
missing.data.areas |
a list of owin objects (of length laglength+1) which has xyt$window as a base window, but with polygonal holes specifying spatial areas where there is missing data. |
autorotate |
logical: whether or not to automatically do MCMC on optimised, rotated grid. |
gradtrunc |
truncation for gradient vector equal to H parameter Moller et al 1998 pp 473. Default is Inf, which means no gradient truncation. Set to NULL to estimate this automatically (though note that this may not necessarily be a good choice). The default seems to work in most settings. |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays very slowly (compared withe the size of hte observation window), increasing 'ext' may be necessary. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. further notes on autorotate argument: If set to TRUE, and the argument spatial is not NULL, then the argument spatial must be computed in the original frame of reference (ie NOT in the rotated frame). Autorotate performs bilinear interpolation (via interp.im) on an inverse transformed grid; if there is no computational advantage in doing this, a warning message will be issued. Note that best accuracy is achieved by manually rotating xyt and then computing spatial on the transformed xyt and finally feeding these in as arguments to the function lgcpPredict. By default autorotate is set to FALSE. |
The following is a mathematical description of a log-Gaussian Cox Process, it is best viewed in the pdf version of the manual.
Let be a spatiotemporal Gaussian process,
be an
observation window in space and
be an interval of time of interest.
Cases occur at spatio-temporal positions
according to an inhomogeneous spatio-temporal Cox process,
i.e. a Poisson process with a stochastic intensity
,
The number of cases,
, arising in
any
during the interval
is
then Poisson distributed conditional on
,
Following Brix and Diggle (2001) and Diggle et al (2005), the intensity is decomposed multiplicatively as
In the above, the fixed spatial component, ,
is a known function, proportional to the population at risk at each point in space and scaled so that
whilst the fixed temporal component,
, is also a known function with
for in a small interval of time,
, over which the rate of the process over
can be considered constant.
NOTE: the xyt stppp object can be recorded in continuous time, but for the purposes of prediciton,
discretisation must take place. For the time dimension, this is achieved invisibly by as.integer(xyt$t)
and
as.integer(xyt$tlim)
. Therefore, before running an analysis please make sure that this is commensurate
with the physical inerpretation and requirements of your output. The spatial discretisation is
chosen with the argument cellwidth (or gridsize). If the chosen discretisation in time and space is too coarse for a
given set of parameters (sigma, phi and theta) then the proper correlation structures implied by the model will not
be captured in the output.
Before calling this function, the user must decide on the time point of interest, the
number of intervals of data to use, the parameters, spatial covariance model, spatial discretisation,
fixed spatial () and temporal (
) components, mcmc parameters, and whether or not any output is
required.
the results of fitting the model in an object of class lgcpPredict
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
KinhomAverage, ginhomAverage, lambdaEst, muEst, spatialparsEst, thetaEst, spatialAtRisk, temporalAtRisk, lgcppars, CovarianceFct, mcmcpars, setoutput print.lgcpPredict, xvals.lgcpPredict, yvals.lgcpPredict, plot.lgcpPredict, meanfield.lgcpPredict, rr.lgcpPredict, serr.lgcpPredict, intens.lgcpPredict, varfield.lgcpPredict, gridfun.lgcpPredict, gridav.lgcpPredict, hvals.lgcpPredict, window.lgcpPredict, mcmctrace.lgcpPredict, plotExceed.lgcpPredict, quantile.lgcpPredict, identify.lgcpPredict, expectation.lgcpPredict, extract.lgcpPredict, showGrid.lgcpPredict
The function lgcpPredict
performs spatiotemporal prediction for log-Gaussian Cox Processes for point process data where counts
have been aggregated to the regional level. This is achieved by imputation of the regional counts onto a spatial continuum; if something
is known about the underlying spatial density of cases, then this information can be added to improve the quality of the imputation,
without this, the counts are distributed uniformly within regions.
lgcpPredictAggregated( app, popden = NULL, T, laglength, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, temporal.intensity, mcmc.control, output.control = setoutput(), autorotate = FALSE, gradtrunc = NULL, n = 100, dmin = 0, check = TRUE )
lgcpPredictAggregated( app, popden = NULL, T, laglength, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, temporal.intensity, mcmc.control, output.control = setoutput(), autorotate = FALSE, gradtrunc = NULL, n = 100, dmin = 0, check = TRUE )
app |
a spatio-temporal aggregated point pattern object, see ?stapp |
popden |
a spatialAtRisk object of class 'fromFunction' describing the population density, if known. Default is NULL, which gives a uniform density on each region. |
T |
time point of interest |
laglength |
specifies lag window, so that data from and including time (T-laglength) to time T is used in the MALA algorithm |
model.parameters |
values for parameters, see ?lgcppars |
spatial.covmodel |
correlation type see ?CovarianceFct |
covpars |
vector of additional parameters for certain classes of covariance function (eg Matern), these must be supplied in the order given in ?CovarianceFct |
cellwidth |
width of grid cells on which to do MALA (grid cells are square). Note EITHER gridsize OR cellwidthe must be specified. |
gridsize |
size of output grid required. Note EITHER gridsize OR cellwidthe must be specified. |
spatial.intensity |
the fixed spatial component: an object of that can be coerced to one of class spatialAtRisk |
temporal.intensity |
the fixed temporal component: either a numeric vector, or a function that can be coerced into an object of class temporalAtRisk |
mcmc.control |
MCMC paramters, see ?mcmcpars |
output.control |
output choice, see ?setoutput |
autorotate |
logical: whether or not to automatically do MCMC on optimised, rotated grid. |
gradtrunc |
truncation for gradient vector equal to H parameter Moller et al 1998 pp 473. Set to NULL to estimate this automatically (default). Set to zero for no gradient truncation. |
n |
parameter for as.stppp. If popden is NULL, then this parameter controls the resolution of the uniform. Otherwise if popden is of class 'fromFunction', it controls the size of the imputation grid used for sampling. Default is 100. |
dmin |
parameter for as.stppp. If any reginal counts are missing, then a set of polygonal 'holes' in the observation window will be computed for each. dmin is the parameter used to control the simplification of these holes (see ?simplify.owin). default is zero. |
check |
logical parameter for as.stppp. If any reginal counts are missing, then roughly speaking, check specifies whether to check the 'holes'. further notes on autorotate argument: If set to TRUE, and the argument spatial is not NULL, then the argument spatial must be computed in the original frame of reference (ie NOT in the rotated frame). Autorotate performs bilinear interpolation (via interp.im) on an inverse transformed grid; if there is no computational advantage in doing this, a warning message will be issued. Note that best accuracy is achieved by manually rotating xyt and then computing spatial on the transformed xyt and finally feeding these in as arguments to the function lgcpPredict. By default autorotate is set to FALSE. |
The following is a mathematical description of a log-Gaussian Cox Process, it is best viewed in the pdf version of the manual.
Let be a spatiotemporal Gaussian process,
be an
observation window in space and
be an interval of time of interest.
Cases occur at spatio-temporal positions
according to an inhomogeneous spatio-temporal Cox process,
i.e. a Poisson process with a stochastic intensity
,
The number of cases,
, arising in
any
during the interval
is
then Poisson distributed conditional on
,
Following Brix and Diggle (2001) and Diggle et al (2005), the intensity is decomposed multiplicatively as
In the above, the fixed spatial component, ,
is a known function, proportional to the population at risk at each point in space and scaled so that
whilst the fixed temporal component,
, is also a known function with
for in a small interval of time,
, over which the rate of the process over
can be considered constant.
NOTE: the xyt stppp object can be recorded in continuous time, but for the purposes of prediciton,
discretisation must take place. For the time dimension, this is achieved invisibly by as.integer(xyt$t)
and
as.integer(xyt$tlim)
. Therefore, before running an analysis please make sure that this is commensurate
with the physical inerpretation and requirements of your output. The spatial discretisation is
chosen with the argument cellwidth (or gridsize). If the chosen discretisation in time and space is too coarse for a
given set of parameters (sigma, phi and theta) then the proper correlation structures implied by the model will not
be captured in the output.
Before calling this function, the user must decide on the time point of interest, the
number of intervals of data to use, the parameters, spatial covariance model, spatial discretisation,
fixed spatial () and temporal (
) components, mcmc parameters, and whether or not any output is
required.
the results of fitting the model in an object of class lgcpPredict
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
KinhomAverage, ginhomAverage, lambdaEst, muEst, spatialparsEst, thetaEst, spatialAtRisk, temporalAtRisk, lgcppars, CovarianceFct, mcmcpars, setoutput print.lgcpPredict, xvals.lgcpPredict, yvals.lgcpPredict, plot.lgcpPredict, meanfield.lgcpPredict, rr.lgcpPredict, serr.lgcpPredict, intens.lgcpPredict, varfield.lgcpPredict, gridfun.lgcpPredict, gridav.lgcpPredict, hvals.lgcpPredict, window.lgcpPredict, mcmctrace.lgcpPredict, plotExceed.lgcpPredict, quantile.lgcpPredict, identify.lgcpPredict, expectation.lgcpPredict, extract.lgcpPredict, showGrid.lgcpPredict
A function to deliver fully Bayesian inference for the aggregated spatial log-Gaussian Cox process.
lgcpPredictAggregateSpatialPlusPars( formula, spdf, Zmat = NULL, overlayInZmat = FALSE, model.priors, model.inits = lgcpInits(), spatial.covmodel, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, Nfreq = 101, inclusion = "touching", overlapping = FALSE, pixwts = NULL )
lgcpPredictAggregateSpatialPlusPars( formula, spdf, Zmat = NULL, overlayInZmat = FALSE, model.priors, model.inits = lgcpInits(), spatial.covmodel, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, Nfreq = 101, inclusion = "touching", overlapping = FALSE, pixwts = NULL )
formula |
a formula object of the form X ~ var1 + var2 etc. The name of the dependent variable must be "X". Only accepts 'simple' formulae, such as the example given. |
spdf |
a SpatialPolygonsDataFrame object with variable "X", the event counts per region. |
Zmat |
design matrix Z (see below) constructed with getZmat |
overlayInZmat |
if the covariate information in Zmat also comes from spdf, set to TRUE to avoid replicating the overlay operations. Default is FALSE. |
model.priors |
model priors, set using lgcpPrior |
model.inits |
model initial values. The default is NULL, in which case lgcp will use the prior mean to initialise eta and beta will be initialised from an oversispersed glm fit to the data. Otherwise use lgcpInits to specify. |
spatial.covmodel |
choice of spatial covariance function. See ?CovFunction |
cellwidth |
the width of computational cells |
poisson.offset |
A SpatialAtRisk object defining lambda (see below) |
mcmc.control |
MCMC paramters, see ?mcmcpars |
output.control |
output choice, see ?setoutput |
gradtrunc |
truncation for gradient vector equal to H parameter Moller et al 1998 pp 473. Default is Inf, which means no gradient truncation, which seems to work in most settings. |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
Nfreq |
the sampling frequency for the cell counts. Default is every 101 iterations. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
overlapping |
logical does spdf contain overlapping polygons? Default is FALSE. If set to TRUE, spdf can contain a variable named 'sintens' that gives the sampling intensity for each polygon; the default is to assume that cases are evenly split between overlapping regions. |
pixwts |
optional matrix of dimension (NM) x (number of regions in spdf) where M, N are the number of cells in the x and y directions (not the number of cells on the Fourier grid, rather the number of cell on the output grid). The ith row of this matrix are the probabilities that for the ith grid cell (in the same order as expand.grid(mcens,ncens)) a case belongs to each of the regions in spdf. Including this object overrides 'sintens' in the overlapping option above. |
See the vignette "Bayesian_lgcp" for examples of this code in use.
In this case, we OBSERVE case counts in the regions of a SpatialPolygonsDataFrame; the counts are stored as a variable, X.
The model for the UNOBSERVED data, X(s), is as follows:
X(s) ~ Poisson[R(s)]
R(s) = C_A lambda(s) exp[Z(s)beta+Y(s)]
Here X(s) is the number of events in the cell of the computational grid containing s, R(s) is the Poisson rate, C_A is the cell area, lambda(s) is a known offset, Z(s) is a vector of measured covariates and Y(s) is the latent Gaussian process on the computational grid. The other parameters in the model are beta, the covariate effects; and eta=[log(sigma),log(phi)], the parameters of the process Y on an appropriately transformed (in this case log) scale.
We recommend the user takes the following steps before running this method:
Compute approximate values of the parameters, eta, of the process Y using the function minimum.contrast. These approximate values are used for two main reasons: (1) to help inform the size of the computational grid, since we will need to use a cell width that enables us to capture the dependence properties of Y and (2) to help inform the proposal kernel for the MCMC algorithm.
Choose an appropriate grid on which to perform inference using the function chooseCellwidth; this will partly be determined by the results of the first stage and partly by the available computational resource available to perform inference.
Using the function getpolyol, construct the computational grid and polygon overlays, as required. As this can be an expensive step, we recommend that the user saves this object after it has been constructed and in future reference to the data, reloads this object, rather than having to re-compute it (provided the computational grid has not changed).
Decide on which covariates are to play a part in the analysis and use the lgcp function getZmat to interpolate these onto the computational grid. Note that having saved the results from the previous step, this is a relatively quick operation, and allows the user to quickly construct different design matrices, Z, from different candidate models for the data
If required, set up the population offset using SpatialAtRisk functions (see the vignette "Bayesian_lgcp"); specify the priors using lgcpPrior; and if desired, the initial values for the MCMC, using the function lgcpInits.
Run the MCMC algorithm and save the output to disk. We recommend dumping information to disk using the dump2dir function in the output.control argument because it offers much greater flexibility in terms of MCMC diagnosis and post-processing.
Perform post-processing analyses including MCMC diagnostic checks and produce summaries of the posterior expectations we require for presentation. (see the vignette "Bayesian_lgcp" for further details). Functions of use in this step include traceplots, autocorr, parautocorr, ltar, parsummary, priorpost, postcov, textsummary, expectation, exceedProbs and lgcp:::expectation.lgcpPredict
an object of class lgcpPredictAggregateSpatialPlusParameters
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle. Bayesian Inference and Data Augmentation Schemes for Spatial, Spatiotemporal and Multivariate Log-Gaussian Cox Processes in R. Submitted.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
linkchooseCellWidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function to deliver fully Bayesian inference for a multitype spatial log-Gaussian Cox process.
lgcpPredictMultitypeSpatialPlusPars( formulaList, sd, typemark = NULL, Zmat = NULL, model.priorsList, model.initsList = NULL, spatial.covmodelList, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
lgcpPredictMultitypeSpatialPlusPars( formulaList, sd, typemark = NULL, Zmat = NULL, model.priorsList, model.initsList = NULL, spatial.covmodelList, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
formulaList |
an object of class formulaList, see ?formulaList. A list of formulae of the form t1 ~ var1 + var2 etc. The name of the dependent variable must correspond to the name of the point type. Only accepts 'simple' formulae, such as the example given. |
sd |
a marked ppp object, the mark of interest must be able to be coerced to a factor variable |
typemark |
if there are multiple marks, thrun the MCMC algorithm for spatial point process data. Not for general purpose use.is sets the name of the mark by which |
Zmat |
design matrix including all covariate effects from each point type, constructed with getZmat |
model.priorsList |
model priors, a list object of length the number of types, each element set using lgcpPrior |
model.initsList |
list of model initial values (of length the number of types). The default is NULL, in which case lgcp will use the prior mean to initialise eta and beta will be initialised from an oversispersed glm fit to the data. Otherwise use lgcpInits to specify. |
spatial.covmodelList |
list of spatial covariance functions (of length the number of types). See ?CovFunction |
cellwidth |
the width of computational cells |
poisson.offset |
A list of SpatialAtRisk objects (of length the number of types) defining lambda_k (see below) |
mcmc.control |
MCMC paramters, see ?mcmcpars |
output.control |
output choice, see ?setoutput |
gradtrunc |
truncation for gradient vector equal to H parameter Moller et al 1998 pp 473. Default is Inf, which means no gradient truncation, which seems to work in most settings. |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
See the vignette "Bayesian_lgcp" for examples of this code in use.
We suppose there are K point types of interest. The model for point-type k is as follows:
X_k(s) ~ Poisson[R_k(s)]
R_k(s) = C_A lambda_k(s) exp[Z_k(s)beta_k+Y_k(s)]
Here X_k(s) is the number of events of type k in the computational grid cell containing the point s, R_k(s) is the Poisson rate, C_A is the cell area, lambda_k(s) is a known offset, Z_k(s) is a vector of measured covariates and Y_i(s) where i = 1,...,K+1 are latent Gaussian processes on the computational grid. The other parameters in the model are beta_k , the covariate effects for the kth type; and eta_i = [log(sigma_i),log(phi_i)], the parameters of the process Y_i for i = 1,...,K+1 on an appropriately transformed (again, in this case log) scale.
We recommend the user takes the following steps before running this method:
Compute approximate values of the parameters, eta, of the process Y using the function minimum.contrast. These approximate values are used for two main reasons: (1) to help inform the size of the computational grid, since we will need to use a cell width that enables us to capture the dependence properties of Y and (2) to help inform the proposal kernel for the MCMC algorithm.
Choose an appropriate grid on which to perform inference using the function chooseCellwidth; this will partly be determined by the results of the first stage and partly by the available computational resource available to perform inference.
Using the function getpolyol, construct the computational grid and polygon overlays, as required. As this can be an expensive step, we recommend that the user saves this object after it has been constructed and in future reference to the data, reloads this object, rather than having to re-compute it (provided the computational grid has not changed).
Decide on which covariates are to play a part in the analysis and use the lgcp function getZmat to interpolate these onto the computational grid. Note that having saved the results from the previous step, this is a relatively quick operation, and allows the user to quickly construct different design matrices, Z, from different candidate models for the data
If required, set up the population offset using SpatialAtRisk functions (see the vignette "Bayesian_lgcp"); specify the priors using lgcpPrior; and if desired, the initial values for the MCMC, using the function lgcpInits.
Run the MCMC algorithm and save the output to disk. We recommend dumping information to disk using the dump2dir function in the output.control argument because it offers much greater flexibility in terms of MCMC diagnosis and post-processing.
Perform post-processing analyses including MCMC diagnostic checks and produce summaries of the posterior expectations we require for presentation. (see the vignette "Bayesian_lgcp" for further details). Functions of use in this step include traceplots, autocorr, parautocorr, ltar, parsummary, priorpost, postcov, textsummary, expectation, exceedProbs and lgcp:::expectation.lgcpPredict
an object of class lgcpPredictMultitypeSpatialPlusParameters
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle. Bayesian Inference and Data Augmentation Schemes for Spatial, Spatiotemporal and Multivariate Log-Gaussian Cox Processes in R. Submitted.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
linkchooseCellWidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
The function lgcpPredictSpatial
performs spatial prediction for log-Gaussian Cox Processes
lgcpPredictSpatial( sd, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, spatial.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
lgcpPredictSpatial( sd, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, spatial.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
sd |
a spatial point pattern object, see ?ppp |
model.parameters |
values for parameters, see ?lgcppars |
spatial.covmodel |
correlation type see ?CovarianceFct |
covpars |
vector of additional parameters for certain classes of covariance function (eg Matern), these must be supplied in the order given in ?CovarianceFct |
cellwidth |
width of grid cells on which to do MALA (grid cells are square) in same units as observation window. Note EITHER gridsize OR cellwidthe must be specified. |
gridsize |
size of output grid required. Note EITHER gridsize OR cellwidthe must be specified. |
spatial.intensity |
the fixed spatial component: an object of that can be coerced to one of class spatialAtRisk |
spatial.offset |
Numeric of length 1. Optional offset parameter, corresponding to the expected number of cases. NULL by default, in which case, this is estimateed from teh data. |
mcmc.control |
MCMC paramters, see ?mcmcpars |
output.control |
output choice, see ?setoutput |
gradtrunc |
truncation for gradient vector equal to H parameter Moller et al 1998 pp 473. Default is Inf, which means no gradient truncation. Set to NULL to estimate this automatically (though note that this may not necessarily be a good choice). The default seems to work in most settings. |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
The following is a mathematical description of a log-Gaussian Cox Process, it is best viewed in the pdf version of the manual.
Let be a spatial Gaussian process and
be an
observation window in space.
Cases occur at spatial positions
according to an inhomogeneous spatial Cox process,
i.e. a Poisson process with a stochastic intensity
,
The number of cases,
, arising in
any
is
then Poisson distributed conditional on
,
Following Brix and Diggle (2001) and Diggle et al (2005) (but ignoring temporal variation), the intensity is decomposed multiplicatively as
In the above, the fixed spatial component, ,
is a known function, proportional to the population at risk at each point in space and scaled so that
Before calling this function, the user must decide on the parameters, spatial covariance model, spatial discretisation,
fixed spatial () component, mcmc parameters, and whether or not any output is
required. Note there is no autorotate option for this function.
the results of fitting the model in an object of class lgcpPredict
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
lgcpPredict KinhomAverage, ginhomAverage, lambdaEst, muEst, spatialparsEst, thetaEst, spatialAtRisk, temporalAtRisk, lgcppars, CovarianceFct, mcmcpars, setoutput print.lgcpPredict, xvals.lgcpPredict, yvals.lgcpPredict, plot.lgcpPredict, meanfield.lgcpPredict, rr.lgcpPredict, serr.lgcpPredict, intens.lgcpPredict, varfield.lgcpPredict, gridfun.lgcpPredict, gridav.lgcpPredict, hvals.lgcpPredict, window.lgcpPredict, mcmctrace.lgcpPredict, plotExceed.lgcpPredict, quantile.lgcpPredict, identify.lgcpPredict, expectation.lgcpPredict, extract.lgcpPredict, showGrid.lgcpPredict
——————————————————- !IMPORTANT! after library(lgcp) this will be a dummy function. In order to use, type getlgcpPredictSpatialINLA() at the console. This will download and install the true function. ——————————————————-
lgcpPredictSpatialINLA( sd, ns, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, ext = 2, optimverbose = FALSE, inlaverbose = TRUE, generic0hyper = list(theta = list(initial = 0, fixed = TRUE)), strategy = "simplified.laplace", method = "Nelder-Mead" )
lgcpPredictSpatialINLA( sd, ns, model.parameters = lgcppars(), spatial.covmodel = "exponential", covpars = c(), cellwidth = NULL, gridsize = NULL, spatial.intensity, ext = 2, optimverbose = FALSE, inlaverbose = TRUE, generic0hyper = list(theta = list(initial = 0, fixed = TRUE)), strategy = "simplified.laplace", method = "Nelder-Mead" )
sd |
a spatial point pattern object, see ?ppp |
ns |
size of neighbourhood to use for GMRF approximation ns=1 corresponds to 3^2-1=8 eight neighbours around each point, ns=2 corresponds to 5^2-1=24 neighbours etc ... |
model.parameters |
values for parameters, see ?lgcppars |
spatial.covmodel |
correlation type see ?CovarianceFct |
covpars |
vector of additional parameters for certain classes of covariance function (eg Matern), these must be supplied in the order given in ?CovarianceFct |
cellwidth |
width of grid cells on which to do MALA (grid cells are square). Note EITHER gridsize OR cellwidthe must be specified. |
gridsize |
size of output grid required. Note EITHER gridsize OR cellwidthe must be specified. |
spatial.intensity |
the fixed spatial component: an object of that can be coerced to one of class spatialAtRisk |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
optimverbose |
logical whether to print optimisation details of covariance matching step |
inlaverbose |
loogical whether to print the inla fitting procedure to the console |
generic0hyper |
optional hyperparameter list specification for "generic0" INLA model. default is list(theta=list(initial=0,fixed=TRUE)), which effectively treats the precision matrix as known. |
strategy |
inla strategy |
method |
optimisation method to be used in function matchcovariance, default is "Nelder-Mead". See ?matchcovariance |
The function lgcpPredictSpatialINLA
performs spatial prediction for log-Gaussian Cox Processes using the integrated nested Laplace approximation.
The following is a mathematical description of a log-Gaussian Cox Process, it is best viewed in the pdf version of the manual.
Let be a spatial Gaussian process and
be an
observation window in space.
Cases occur at spatial positions
according to an inhomogeneous spatial Cox process,
i.e. a Poisson process with a stochastic intensity
,
The number of cases,
, arising in
any
is
then Poisson distributed conditional on
,
Following Brix and Diggle (2001) and Diggle et al (2005) (but ignoring temporal variation), the intensity is decomposed multiplicatively as
In the above, the fixed spatial component, ,
is a known function, proportional to the population at risk at each point in space and scaled so that
Before calling this function, the user must decide on the parameters, spatial covariance model, spatial discretisation,
fixed spatial () component and whether or not any output is
required. Note there is no autorotate option for this function.
the results of fitting the model in an object of class lgcpPredict
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
lgcpPredict KinhomAverage, ginhomAverage, lambdaEst, muEst, spatialparsEst, thetaEst, spatialAtRisk, temporalAtRisk, lgcppars, CovarianceFct, mcmcpars, setoutput print.lgcpPredict, xvals.lgcpPredict, yvals.lgcpPredict, plot.lgcpPredict, meanfield.lgcpPredict, rr.lgcpPredict, serr.lgcpPredict, intens.lgcpPredict, varfield.lgcpPredict, gridfun.lgcpPredict, gridav.lgcpPredict, hvals.lgcpPredict, window.lgcpPredict, mcmctrace.lgcpPredict, plotExceed.lgcpPredict, quantile.lgcpPredict, identify.lgcpPredict, expectation.lgcpPredict, extract.lgcpPredict, showGrid.lgcpPredict,
A function to deliver fully Bayesian inference for the spatial log-Gaussian Cox process.
lgcpPredictSpatialPlusPars( formula, sd, Zmat = NULL, model.priors, model.inits = lgcpInits(), spatial.covmodel, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
lgcpPredictSpatialPlusPars( formula, sd, Zmat = NULL, model.priors, model.inits = lgcpInits(), spatial.covmodel, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
formula |
a formula object of the form X ~ var1 + var2 etc. The name of the dependent variable must be "X". Only accepts 'simple' formulae, such as the example given. |
sd |
a spatstat ppp object |
Zmat |
design matrix Z (see below) constructed with getZmat |
model.priors |
model priors, set using lgcpPrior |
model.inits |
model initial values. The default is NULL, in which case lgcp will use the prior mean to initialise eta and beta will be initialised from an oversispersed glm fit to the data. Otherwise use lgcpInits to specify. |
spatial.covmodel |
choice of spatial covariance function. See ?CovFunction |
cellwidth |
the width of computational cells |
poisson.offset |
A SpatialAtRisk object defining lambda (see below) |
mcmc.control |
MCMC paramters, see ?mcmcpars |
output.control |
output choice, see ?setoutput |
gradtrunc |
truncation for gradient vector equal to H parameter Moller et al 1998 pp 473. Default is Inf, which means no gradient truncation, which seems to work in most settings. |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
See the vignette "Bayesian_lgcp" for examples of this code in use.
The model for the data is as follows:
X(s) ~ Poisson[R(s)]
R(s) = C_A lambda(s) exp[Z(s)beta+Y(s)]
Here X(s) is the number of events in the cell of the computational grid containing s, R(s) is the Poisson rate, C_A is the cell area, lambda(s) is a known offset, Z(s) is a vector of measured covariates and Y(s) is the latent Gaussian process on the computational grid. The other parameters in the model are beta, the covariate effects; and eta=[log(sigma),log(phi)], the parameters of the process Y on an appropriately transformed (in this case log) scale.
We recommend the user takes the following steps before running this method:
Compute approximate values of the parameters, eta, of the process Y using the function minimum.contrast. These approximate values are used for two main reasons: (1) to help inform the size of the computational grid, since we will need to use a cell width that enables us to capture the dependence properties of Y and (2) to help inform the proposal kernel for the MCMC algorithm.
Choose an appropriate grid on which to perform inference using the function chooseCellwidth; this will partly be determined by the results of the first stage and partly by the available computational resource available to perform inference.
Using the function getpolyol, construct the computational grid and polygon overlays, as required. As this can be an expensive step, we recommend that the user saves this object after it has been constructed and in future reference to the data, reloads this object, rather than having to re-compute it (provided the computational grid has not changed).
Decide on which covariates are to play a part in the analysis and use the lgcp function getZmat to interpolate these onto the computational grid. Note that having saved the results from the previous step, this is a relatively quick operation, and allows the user to quickly construct different design matrices, Z, from different candidate models for the data
If required, set up the population offset using SpatialAtRisk functions (see the vignette "Bayesian_lgcp"); specify the priors using lgcpPrior; and if desired, the initial values for the MCMC, using the function lgcpInits.
Run the MCMC algorithm and save the output to disk. We recommend dumping information to disk using the dump2dir function in the output.control argument because it offers much greater flexibility in terms of MCMC diagnosis and post-processing.
Perform post-processing analyses including MCMC diagnostic checks and produce summaries of the posterior expectations we require for presentation. (see the vignette "Bayesian_lgcp" for further details). Functions of use in this step include traceplots, autocorr, parautocorr, ltar, parsummary, priorpost, postcov, textsummary, expectation, exceedProbs and lgcp:::expectation.lgcpPredict
an object of class lgcpPredictSpatialOnlyPlusParameters
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle. Bayesian Inference and Data Augmentation Schemes for Spatial, Spatiotemporal and Multivariate Log-Gaussian Cox Processes in R. Submitted.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
linkchooseCellWidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function to deliver fully Bayesian inference for the spatiotemporal log-Gaussian Cox process.
lgcpPredictSpatioTemporalPlusPars( formula, xyt, T, laglength, ZmatList = NULL, model.priors, model.inits = lgcpInits(), spatial.covmodel, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
lgcpPredictSpatioTemporalPlusPars( formula, xyt, T, laglength, ZmatList = NULL, model.priors, model.inits = lgcpInits(), spatial.covmodel, cellwidth = NULL, poisson.offset = NULL, mcmc.control, output.control = setoutput(), gradtrunc = Inf, ext = 2, inclusion = "touching" )
formula |
a formula object of the form X ~ var1 + var2 etc. The name of the dependent variable must be "X". Only accepts 'simple' formulae, such as the example given. |
xyt |
An object of class stppp |
T |
the time point of interest |
laglength |
the number of previous time points to include in the analysis |
ZmatList |
A list of design matrices Z constructed with getZmat and possibly addTemporalCovariates see the details below and Bayesian_lgcp vignette for details on how to construct this. |
model.priors |
model priors, set using lgcpPrior |
model.inits |
model initial values. The default is NULL, in which case lgcp will use the prior mean to initialise eta and beta will be initialised from an oversispersed glm fit to the data. Otherwise use lgcpInits to specify. |
spatial.covmodel |
choice of spatial covariance function. See ?CovFunction |
cellwidth |
the width of computational cells |
poisson.offset |
A list of SpatialAtRisk objects (of length the number of types) defining lambda_k (see below) |
mcmc.control |
MCMC paramters, see ?mcmcpars |
output.control |
output choice, see ?setoutput |
gradtrunc |
truncation for gradient vector equal to H parameter Moller et al 1998 pp 473. Default is Inf, which means no gradient truncation, which seems to work in most settings. |
ext |
integer multiple by which grid should be extended, default is 2. Generally this will not need to be altered, but if the spatial correlation decays slowly, increasing 'ext' may be necessary. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
See the vignette "Bayesian_lgcp" for examples of this code in use.
The model for the data is as follows:
X(s) ~ Poisson[R(s,t)]
R(s) = C_A lambda(s,t) exp[Z(s,t)beta+Y(s,t)]
Here X(s,t) is the number of events in the cell of the computational grid containing s, R(s,t) is the Poisson rate,
C_A is the cell area, lambda(s,t) is a known offset, Z(s,t) is a vector of measured covariates and Y(s,t) is the
latent Gaussian process on the computational grid. The other parameters in the model are beta, the covariate effects;
and eta=[log(sigma),log(phi),log(theta)], the parameters of the process Y on an appropriately transformed (in this case log) scale.
We recommend the user takes the following steps before running this method:
Compute approximate values of the parameters, eta, of the process Y using the function minimum.contrast. These approximate values are used for two main reasons: (1) to help inform the size of the computational grid, since we will need to use a cell width that enables us to capture the dependence properties of Y and (2) to help inform the proposal kernel for the MCMC algorithm.
Choose an appropriate grid on which to perform inference using the function chooseCellwidth; this will partly be determined by the results of the first stage and partly by the available computational resource available to perform inference.
Using the function getpolyol, construct the computational grid and polygon overlays, as required. As this can be an expensive step, we recommend that the user saves this object after it has been constructed and in future reference to the data, reloads this object, rather than having to re-compute it (provided the computational grid has not changed).
Decide on which covariates are to play a part in the analysis and use the lgcp function getZmat to interpolate these onto the computational grid. Note that having saved the results from the previous step, this is a relatively quick operation, and allows the user to quickly construct different design matrices, Z, from different candidate models for the data
If required, set up the population offset using SpatialAtRisk functions (see the vignette "Bayesian_lgcp"); specify the priors using lgcpPrior; and if desired, the initial values for the MCMC, using the function lgcpInits.
Run the MCMC algorithm and save the output to disk. We recommend dumping information to disk using the dump2dir function in the output.control argument because it offers much greater flexibility in terms of MCMC diagnosis and post-processing.
Perform post-processing analyses including MCMC diagnostic checks and produce summaries of the posterior expectations we require for presentation. (see the vignette "Bayesian_lgcp" for further details). Functions of use in this step include traceplots, autocorr, parautocorr, ltar, parsummary, priorpost, postcov, textsummary, expectation, exceedProbs and lgcp:::expectation.lgcpPredict
The user must provide a list of design matrices to use this function. In the interpolation step above, there are three cases to consider
where Z(s,t) cannot be decomposed, i.e., Z are true spatiotemporal covariates. In this case, each element of the list must be constructed separately using the function getZmat on the covariates for each time point.
Z(s,t)beta = Z_1(s)beta_1 + Z_2(t)beta_2: the spatial and temporal effects are separable; in this case use the function addTemporalCovariates, to aid in the construction of the list.
Z(s,t)beta = Z(s)beta, in which case the user only needs to perform the interpolation using getZmat once, each of the elements of the list will then be identical.
Z(s,t)beta = Z(t)beta in this case we follow the procedure for the separable case above. For example, if dotw is a temporal covariate we would use formula <- X ~ dotw for the main algorithm, formula.spatial <- X ~ 1 to interpolate the spatial covariates using getZmat, followed by temporal.formula <- t ~ dotw - 1 using addTemporalCovariates to construct the list of design matrices, Zmat.
an object of class lgcpPredictSpatioTemporalPlusParameters
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle. Bayesian Inference and Data Augmentation Schemes for Spatial, Spatiotemporal and Multivariate Log-Gaussian Cox Processes in R. Submitted.
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
linkchooseCellWidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictMultitypeSpatialPlusPars, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function to create the prior for beta and eta ready for a run of the MCMC algorithm.
lgcpPrior(etaprior = NULL, betaprior = NULL)
lgcpPrior(etaprior = NULL, betaprior = NULL)
etaprior |
an object of class PriorSpec defining the prior for the parameters of the latent field, eta. See ?PriorSpec.list. |
betaprior |
etaprior an object of class PriorSpec defining the prior for the parameters of main effects, beta. See ?PriorSpec.list. |
an R structure representing the prior density ready for a run of the MCMC algorithm.
GaussianPrior, LogGaussianPrior, PriorSpec.list, chooseCellwidth, getpolyol, guessinterp, getZmat, addTemporalCovariates, lgcpPrior, lgcpInits, CovFunction lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars, lgcpPredictMultitypeSpatialPlusPars
lgcpPrior(etaprior=PriorSpec(LogGaussianPrior(mean=log(c(1,500)), variance=diag(0.15,2))),betaprior=PriorSpec(GaussianPrior(mean=rep(0,9), variance=diag(10^6,9))))
lgcpPrior(etaprior=PriorSpec(LogGaussianPrior(mean=log(c(1,500)), variance=diag(0.15,2))),betaprior=PriorSpec(GaussianPrior(mean=rep(0,9), variance=diag(10^6,9))))
Approximate simulation from a spatiotemoporal log-Gaussian Cox Process. Returns an stppp object.
lgcpSim( owin = NULL, tlim = as.integer(c(0, 10)), spatial.intensity = NULL, temporal.intensity = NULL, cellwidth = 0.05, model.parameters = lgcppars(sigma = 2, phi = 0.2, theta = 1), spatial.covmodel = "exponential", covpars = c(), returnintensities = FALSE, progressbar = TRUE, ext = 2, plot = FALSE, ratepow = 0.25, sleeptime = 0, inclusion = "touching" )
lgcpSim( owin = NULL, tlim = as.integer(c(0, 10)), spatial.intensity = NULL, temporal.intensity = NULL, cellwidth = 0.05, model.parameters = lgcppars(sigma = 2, phi = 0.2, theta = 1), spatial.covmodel = "exponential", covpars = c(), returnintensities = FALSE, progressbar = TRUE, ext = 2, plot = FALSE, ratepow = 0.25, sleeptime = 0, inclusion = "touching" )
owin |
polygonal observation window |
tlim |
time interval on which to simulate data |
spatial.intensity |
object that can be coerced into a spatialAtRisk object. if NULL then uniform spatial is chosen |
temporal.intensity |
the fixed temporal component: either a numeric vector, or a function that can be coerced into an object of class temporalAtRisk |
cellwidth |
width of cells in same units as observation window |
model.parameters |
parameters of model, see ?lgcppars. |
spatial.covmodel |
spatial covariance function, default is exponential, see ?CovarianceFct |
covpars |
vector of additional parameters for spatial covariance function, in order they appear in chosen model in ?CovarianceFct |
returnintensities |
logigal, whether to return the spatial intensities and true field Y at each time. Default FALSE. |
progressbar |
logical, whether to print a progress bar. Default TRUE. |
ext |
how much to extend the parameter space by. Default is 2. |
plot |
logical, whether to plot intensities. |
ratepow |
power that intensity is raised to for plotting purposes (makes the plot more pleasign to the eye), defaul 0.25 |
sleeptime |
time in seconds to sleep between plots |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
The following is a mathematical description of a log-Gaussian Cox Process, it is best viewed in the pdf version of the manual.
Let be a spatiotemporal Gaussian process,
be an
observation window in space and
be an interval of time of interest.
Cases occur at spatio-temporal positions
according to an inhomogeneous spatio-temporal Cox process,
i.e. a Poisson process with a stochastic intensity
,
The number of cases,
, arising in
any
during the interval
is
then Poisson distributed conditional on
,
Following Brix and Diggle (2001) and Diggle et al (2005), the intensity is decomposed multiplicatively as
In the above, the fixed spatial component, ,
is a known function, proportional to the population at risk at each point in space and scaled so that
whilst the fixed temporal component,
, is also a known function with
for in a small interval of time,
, over which the rate of the process over
can be considered constant.
an stppp object containing the data
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
Wood ATA, Chan G (1994). Simulation of Stationary Gaussian Processes in [0,1]d. Journal of Computational and Graphical Statistics, 3(4), 409-432.
Moller J, Syversveen AR, Waagepetersen RP (1998). Log Gaussian Cox Processes. Scandinavian Journal of Statistics, 25(3), 451-482.
lgcpPredict, showGrid.stppp, stppp
## Not run: library(spatstat.explore); library(spatstat.utils); xyt <- lgcpSim()
## Not run: library(spatstat.explore); library(spatstat.utils); xyt <- lgcpSim()
A function to Simulate multivariate point process models
lgcpSimMultitypeSpatialCovariates( formulaList, owin, regionalcovariates, pixelcovariates, betaList, spatial.offsetList = NULL, cellwidth, model.parameters, spatial.covmodel = "exponential", covpars = c(), ext = 2, plot = FALSE, inclusion = "touching" )
lgcpSimMultitypeSpatialCovariates( formulaList, owin, regionalcovariates, pixelcovariates, betaList, spatial.offsetList = NULL, cellwidth, model.parameters, spatial.covmodel = "exponential", covpars = c(), ext = 2, plot = FALSE, inclusion = "touching" )
formulaList |
a list of formulae objetcs |
owin |
a spatstat owin object on which to simulate the data |
regionalcovariates |
a SpatialPolygonsDataFrame object |
pixelcovariates |
a SpatialPixelsDataFrame object |
betaList |
list of beta parameters |
spatial.offsetList |
list of poisson offsets |
cellwidth |
cellwidth |
model.parameters |
model parameters, a list eg list(sigma=1,phi=0.2) |
spatial.covmodel |
the choice of spatial covariance model, can be anything from the RandomFields covariance function, CovariacenFct. |
covpars |
additional covariance parameters, for the chosen model, optional. |
ext |
number of times to extend the simulation window |
plot |
whether to plot the results automatically |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
a marked ppp object, the simulated data
A function to simulate from a log gaussian process
lgcpSimSpatial( owin = NULL, spatial.intensity = NULL, expectednumcases = 100, cellwidth = 0.05, model.parameters = lgcppars(sigma = 2, phi = 0.2), spatial.covmodel = "exponential", covpars = c(), ext = 2, plot = FALSE, inclusion = "touching" )
lgcpSimSpatial( owin = NULL, spatial.intensity = NULL, expectednumcases = 100, cellwidth = 0.05, model.parameters = lgcppars(sigma = 2, phi = 0.2), spatial.covmodel = "exponential", covpars = c(), ext = 2, plot = FALSE, inclusion = "touching" )
owin |
observation window |
spatial.intensity |
an object that can be coerced to one of class spatialAtRisk |
expectednumcases |
the expected number of cases |
cellwidth |
width of cells in same units as observation window |
model.parameters |
parameters of model, see ?lgcppars. Only set sigma and phi for spatial model. |
spatial.covmodel |
spatial covariance function, default is exponential, see ?CovarianceFct |
covpars |
vector of additional parameters for spatial covariance function, in order they appear in chosen model in ?CovarianceFct |
ext |
how much to extend the parameter space by. Default is 2. |
plot |
logical, whether to plot the latent field. |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
a ppp object containing the data
A function to simulate a spatial LGCP.
lgcpSimSpatialCovariates( formula, owin, regionalcovariates = NULL, pixelcovariates = NULL, Zmat = NULL, beta, poisson.offset = NULL, cellwidth, model.parameters, spatial.covmodel = "exponential", covpars = c(), ext = 2, plot = FALSE, inclusion = "touching" )
lgcpSimSpatialCovariates( formula, owin, regionalcovariates = NULL, pixelcovariates = NULL, Zmat = NULL, beta, poisson.offset = NULL, cellwidth, model.parameters, spatial.covmodel = "exponential", covpars = c(), ext = 2, plot = FALSE, inclusion = "touching" )
formula |
a formula of the form X ~ var1 + var2 etc. |
owin |
the observation window on which to do the simulation |
regionalcovariates |
an optional object of class SpatialPolygonsDataFrame containing covariates |
pixelcovariates |
an optional object of class SpatialPixelsDataFrame containing covariates |
Zmat |
optional design matrix, if the polygon/polygon overlays have already been computed |
beta |
the parameters, beta for the model |
poisson.offset |
the poisson offet, created using a SpatialAtRisk.fromXYZ class of objects |
cellwidth |
the with of cells on which to do the simulation |
model.parameters |
the paramters of the model eg list(sigma=1,phi=0.2) |
spatial.covmodel |
the choice of spatial covariance model, can be anything from the RandomFields covariance function, CovariacenFct. |
covpars |
additional covariance parameters, for the chosen model, optional. |
ext |
the amount by which to extend the observation grid in each direction, default is 2 |
plot |
whether to plot the resulting data |
inclusion |
criterion for cells being included into observation window. Either 'touching' or 'centroid'. The former, the default, includes all cells that touch the observation window, the latter includes all cells whose centroids are inside the observation window. |
a ppp onject containing the simulated data
Display the introductory vignette for the lgcp package.
lgcpvignette()
lgcpvignette()
displays the vignette by calling browseURL
Converts a polygon selected via the mouse in a graphics window into an polygonal owin object. (Make sure the x and y scales are correct!) Points must be selected traversing the required window in one direction (ie either clockwise, or anticlockwise), points must not be overlapping. Select the sequence of edges via left mouse button clicks and store the polygon with a right click.
loc2poly(n = 512, type = "l", col = "black", ...)
loc2poly(n = 512, type = "l", col = "black", ...)
n |
the maximum number of points to locate |
type |
same as argument type in function locator. see ?locator. Default draws lines |
col |
colour of lines/points |
... |
other arguments to pass to locate |
a polygonal owin object
lgcpPredict, identify.lgcpPredict
## Not run: plot(lg) # lg an lgcpPredict object ## Not run: subwin <- loc2poly())
## Not run: plot(lg) # lg an lgcpPredict object ## Not run: subwin <- loc2poly())
A function to create a Gaussian prior on the log scale
LogGaussianPrior(mean, variance)
LogGaussianPrior(mean, variance)
mean |
a vector of length 2 representing the mean (on the log scale) |
variance |
a 2x2 matrix representing the variance (on the log scale) |
an object of class LogGaussianPrior that can be passed to the function PriorSpec.
GaussianPrior, linkPriorSpec.list
## Not run: LogGaussianPrior(mean=log(c(1,500)),variance=diag(0.15,2))
## Not run: LogGaussianPrior(mean=log(c(1,500)),variance=diag(0.15,2))
useful for testing progress bars
loop.mcmc(object, sleep = 1)
loop.mcmc(object, sleep = 1)
object |
an mcmc iterator |
sleep |
pause between iterations in seconds |
A function to return the sampled log-target from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars. This is used as a convergence diagnostic.
ltar(lg)
ltar(lg)
lg |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars orlgcpPredictMultitypeSpatialPlusPars |
the log-target from each saved iteration of the MCMC chain.
autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
ADVANCED USE ONLY A function to perform MALA for the spatial only case
MALAlgcp( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, sigma, phi, theta, mu, nis, cellarea, spatialvals, temporal.fitted, tdiff, scaleconst, rootQeigs, invrootQeigs, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, mcens, ncens, aggtimes )
MALAlgcp( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, sigma, phi, theta, mu, nis, cellarea, spatialvals, temporal.fitted, tdiff, scaleconst, rootQeigs, invrootQeigs, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, mcens, ncens, aggtimes )
mcmcloop |
an mcmcLoop object |
inits |
initial values from mcmc.control |
adaptivescheme |
adaptive scheme from mcmc.control |
M |
number of cells in x direction on output grid |
N |
number of cells in y direction on output grid |
Mext |
number of cells in x direction on extended output grid |
Next |
number of cells in y direction on extended output grid |
sigma |
spatial covariance parameter sigma |
phi |
spatial covariance parameter phi |
theta |
temporal correlation parameter theta |
mu |
spatial covariance parameter mu |
nis |
cell counts matrix |
cellarea |
area of cells |
spatialvals |
spatial at risk, function lambda, interpolated onto the requisite grid |
temporal.fitted |
temporal fitted values representing mu(t) |
tdiff |
vecto of time differences with convention that the first element is Inf |
scaleconst |
expected number of observations |
rootQeigs |
square root of eigenvalues of precision matrix |
invrootQeigs |
inverse square root of eigenvalues of precision matrix |
cellInside |
logical matrix dictating whether cells are inside the observation window |
MCMCdiag |
defunct |
gradtrunc |
gradient truncation parameter |
gridfun |
grid functions |
gridav |
grid average functions |
mcens |
x-coordinates of cell centroids |
ncens |
y-coordinates of cell centroids |
aggtimes |
z-coordinates of cell centroids (ie time) |
object passed back to lgcpPredictSpatial
A function to run the MCMC algorithm for aggregated spatial point process data. Not for general purpose use.
MALAlgcpAggregateSpatial.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formula, Zmat, model.priors, model.inits, fftgrid, spatial.covmodel, nis, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, d, spdf, ol, Nfreq )
MALAlgcpAggregateSpatial.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formula, Zmat, model.priors, model.inits, fftgrid, spatial.covmodel, nis, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, d, spdf, ol, Nfreq )
mcmcloop |
details of the mcmc loop |
inits |
initial values |
adaptivescheme |
the adaptive MCMC scheme |
M |
number of grid cells in x direction |
N |
number of grid cells in y direction |
Mext |
number of extended grid cells in x direction |
Next |
number of extended grid cells in y direction |
mcens |
centroids in x direction |
ncens |
centroids in y direction |
formula |
a formula object of the form X ~ var1 + var2 etc. |
Zmat |
design matrix constructed using getZmat |
model.priors |
model priors, constructed using lgcpPrior |
model.inits |
initial values for the MCMC |
fftgrid |
an objects of class FFTgrid, see genFFTgrid |
spatial.covmodel |
spatial covariance model, consructed with CovFunction |
nis |
cell counts on the etended grid |
cellarea |
the cell area |
spatialvals |
inerpolated poisson offset on fft grid |
cellInside |
0-1 matrix indicating inclusion in the observation window |
MCMCdiag |
not used |
gradtrunc |
gradient truncation parameter |
gridfun |
used to specify other actions to be taken, e.g. dumping MCMC output to disk. |
gridav |
used for computing Monte Carlo expectations online |
d |
matrix of toral distances |
spdf |
the SpatialPolygonsDataFrame containing the aggregate counts as a variable X |
ol |
overlay of fft grid onto spdf |
Nfreq |
frequency at which to resample nis |
output from the MCMC run
A function to run the MCMC algorithm for multivariate spatial point process data. Not for general purpose use.
MALAlgcpMultitypeSpatial.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formulaList, zml, Zmat, model.priorsList, model.initsList, fftgrid, spatial.covmodelList, nis, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, marks, ntypes, d )
MALAlgcpMultitypeSpatial.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formulaList, zml, Zmat, model.priorsList, model.initsList, fftgrid, spatial.covmodelList, nis, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, marks, ntypes, d )
mcmcloop |
details of the mcmc loop |
inits |
initial values |
adaptivescheme |
the adaptive MCMC scheme |
M |
number of grid cells in x direction |
N |
number of grid cells in y direction |
Mext |
number of extended grid cells in x direction |
Next |
number of extended grid cells in y direction |
mcens |
centroids in x direction |
ncens |
centroids in y direction |
formulaList |
a list of formula objects of the form X ~ var1 + var2 etc. |
zml |
list of design matrices |
Zmat |
a design matrix constructed using getZmat |
model.priorsList |
list of model priors, see lgcpPriors |
model.initsList |
list of model initial values, see lgcpInits |
fftgrid |
an objects of class FFTgrid, see genFFTgrid |
spatial.covmodelList |
list of spatial covariance models constructed using CovFunction |
nis |
cell counts on the etended grid |
cellarea |
the cell area |
spatialvals |
inerpolated poisson offset on fft grid |
cellInside |
0-1 matrix indicating inclusion in the observation window |
MCMCdiag |
not used |
gradtrunc |
gradient truncation parameter |
gridfun |
used to specify other actions to be taken, e.g. dumping MCMC output to disk. |
gridav |
used for computing Monte Carlo expectations online |
marks |
the marks from the marked ppp object |
ntypes |
the number of types being analysed |
d |
matrix of toral distances |
output from the MCMC run
ADVANCED USE ONLY A function to perform MALA for the spatial only case
MALAlgcpSpatial( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, sigma, phi, mu, nis, cellarea, spatialvals, scaleconst, rootQeigs, invrootQeigs, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, mcens, ncens )
MALAlgcpSpatial( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, sigma, phi, mu, nis, cellarea, spatialvals, scaleconst, rootQeigs, invrootQeigs, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, mcens, ncens )
mcmcloop |
an mcmcLoop object |
inits |
initial values from mcmc.control |
adaptivescheme |
adaptive scheme from mcmc.control |
M |
number of cells in x direction on output grid |
N |
number of cells in y direction on output grid |
Mext |
number of cells in x direction on extended output grid |
Next |
number of cells in y direction on extended output grid |
sigma |
spatial covariance parameter sigma |
phi |
spatial covariance parameter phi |
mu |
spatial covariance parameter mu |
nis |
cell counts matrix |
cellarea |
area of cells |
spatialvals |
spatial at risk, function lambda, interpolated onto the requisite grid |
scaleconst |
expected number of observations |
rootQeigs |
square root of eigenvalues of precision matrix |
invrootQeigs |
inverse square root of eigenvalues of precision matrix |
cellInside |
logical matrix dictating whether cells are inside the observation window |
MCMCdiag |
defunct |
gradtrunc |
gradient truncation parameter |
gridfun |
grid functions |
gridav |
grid average functions |
mcens |
x-coordinates of cell centroids |
ncens |
y-coordinates of cell centroids |
object passed back to lgcpPredictSpatial
A function to run the MCMC algorithm for spatial point process data. Not for general purpose use.
MALAlgcpSpatial.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formula, Zmat, model.priors, model.inits, fftgrid, spatial.covmodel, nis, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, d )
MALAlgcpSpatial.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formula, Zmat, model.priors, model.inits, fftgrid, spatial.covmodel, nis, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, d )
mcmcloop |
details of the mcmc loop |
inits |
initial values |
adaptivescheme |
the adaptive MCMC scheme |
M |
number of grid cells in x direction |
N |
number of grid cells in y direction |
Mext |
number of extended grid cells in x direction |
Next |
number of extended grid cells in y direction |
mcens |
centroids in x direction |
ncens |
centroids in y direction |
formula |
a formula object of the form X ~ var1 + var2 etc. |
Zmat |
design matrix constructed using getZmat |
model.priors |
model priors, constructed using lgcpPrior |
model.inits |
initial values for the MCMC |
fftgrid |
an objects of class FFTgrid, see genFFTgrid |
spatial.covmodel |
spatial covariance model, consructed with CovFunction |
nis |
cell counts on the etended grid |
cellarea |
the cell area |
spatialvals |
inerpolated poisson offset on fft grid |
cellInside |
0-1 matrix indicating inclusion in the observation window |
MCMCdiag |
not used |
gradtrunc |
gradient truncation parameter |
gridfun |
used to specify other actions to be taken, e.g. dumping MCMC output to disk. |
gridav |
used for computing Monte Carlo expectations online |
d |
matrix of toral distances |
output from the MCMC run
A function to run the MCMC algorithm for spatiotemporal point process data. Not for general purpose use.
MALAlgcpSpatioTemporal.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formula, ZmatList, model.priors, model.inits, fftgrid, spatial.covmodel, nis, tdiff, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, d, aggtimes, spatialOnlyCovariates )
MALAlgcpSpatioTemporal.PlusPars( mcmcloop, inits, adaptivescheme, M, N, Mext, Next, mcens, ncens, formula, ZmatList, model.priors, model.inits, fftgrid, spatial.covmodel, nis, tdiff, cellarea, spatialvals, cellInside, MCMCdiag, gradtrunc, gridfun, gridav, d, aggtimes, spatialOnlyCovariates )
mcmcloop |
details of the mcmc loop |
inits |
initial values |
adaptivescheme |
the adaptive MCMC scheme |
M |
number of grid cells in x direction |
N |
number of grid cells in y direction |
Mext |
number of extended grid cells in x direction |
Next |
number of extended grid cells in y direction |
mcens |
centroids in x direction |
ncens |
centroids in y direction |
formula |
a formula object of the form X ~ var1 + var2 etc. |
ZmatList |
list of design matrices constructed using getZmat |
model.priors |
model priors, constructed using lgcpPrior |
model.inits |
initial values for the MCMC |
fftgrid |
an objects of class FFTgrid, see genFFTgrid |
spatial.covmodel |
spatial covariance model, consructed with CovFunction |
nis |
cell counts on the etended grid |
tdiff |
vector of time differences |
cellarea |
the cell area |
spatialvals |
inerpolated poisson offset on fft grid |
cellInside |
0-1 matrix indicating inclusion in the observation window |
MCMCdiag |
not used |
gradtrunc |
gradient truncation parameter |
gridfun |
used to specify other actions to be taken, e.g. dumping MCMC output to disk. |
gridav |
used for computing Monte Carlo expectations online |
d |
matrix of toral distances |
aggtimes |
the aggregate times |
spatialOnlyCovariates |
whether this is a 'spatial' only problem |
output from the MCMC run
A function to match the covariance matrix of a Gaussian Field with an approximate GMRF with neighbourhood size ns.
matchcovariance( xg, yg, ns, sigma, phi, model, additionalparameters, verbose = TRUE, r = 1, method = "Nelder-Mead" )
matchcovariance( xg, yg, ns, sigma, phi, model, additionalparameters, verbose = TRUE, r = 1, method = "Nelder-Mead" )
xg |
x grid must be equally spaced |
yg |
y grid must be equally spaced |
ns |
neighbourhood size |
sigma |
spatial variability parameter |
phi |
spatial dependence parameter |
model |
covariance model, see ?CovarianceFct |
additionalparameters |
additional parameters for chosen covariance model |
verbose |
whether or not to print stuff generated by the optimiser |
r |
parameter used in optimisation, see Rue and Held (2005) pp 188. default value 1. |
method |
The choice of optimising routine must either be 'Nelder-Mead' or 'BFGS'. see ?optim |
...
A function to declare and also evaluate an Matern 1.5 covariance function.
maternCovFct15(d, CovParameters)
maternCovFct15(d, CovParameters)
d |
toral distance |
CovParameters |
parameters of the latent field, an object of class "CovParamaters". |
the exponential covariance function
Dominic Schumacher
CovFunction.function, RandomFieldsCovFct, SpikedExponentialCovFct
A function to declare and also evaluate an Matern 2.5 covariance function.
maternCovFct25(d, CovParameters)
maternCovFct25(d, CovParameters)
d |
toral distance |
CovParameters |
parameters of the latent field, an object of class "CovParamaters". |
the exponential covariance function
Dominic Schumacher
CovFunction.function, RandomFieldsCovFct, SpikedExponentialCovFct
control an MCMC loop with this iterator
mcmcLoop(N, burnin, thin, trim = TRUE, progressor = mcmcProgressPrint)
mcmcLoop(N, burnin, thin, trim = TRUE, progressor = mcmcProgressPrint)
N |
number of iterations |
burnin |
length of burn-in |
thin |
frequency of thinning |
trim |
whether to cut off iterations after the last retained iteration |
progressor |
a function that returns a progress object |
A function for setting MCMC options in a run of lgcpPredict
for example.
mcmcpars(mala.length, burnin, retain, inits = NULL, adaptivescheme)
mcmcpars(mala.length, burnin, retain, inits = NULL, adaptivescheme)
mala.length |
default = 100, |
burnin |
default = floor(mala.length/2), |
retain |
thinning parameter eg operated on chain every 'retain' iteration (eg store output or compute some posterior functional) |
inits |
optional initial values for MCMC |
adaptivescheme |
the type of adaptive mcmc to use, see ?constanth (constant h) or ?andrieuthomsh (adaptive MCMC of Andrieu and Thoms (2008)) |
mcmc parameters
a progress monitor that does nothing
mcmcProgressNone(mcmcloop)
mcmcProgressNone(mcmcloop)
mcmcloop |
an mcmc loop iterator |
a progress monitor
a progress monitor that prints each iteration
mcmcProgressPrint(mcmcloop)
mcmcProgressPrint(mcmcloop)
mcmcloop |
an mcmc loop iterator |
a progress monitor
a progress monitor that uses a text progress bar
mcmcProgressTextBar(mcmcloop)
mcmcProgressTextBar(mcmcloop)
mcmcloop |
an mcmc loop iterator |
a progress monitor
a progress monitor that uses tcltk dialogs
mcmcProgressTk(mcmcloop)
mcmcProgressTk(mcmcloop)
mcmcloop |
an mcmc loop iterator |
a progress monitor
Generic function to extract the information required to produce MCMC trace plots.
mcmctrace(obj, ...)
mcmctrace(obj, ...)
obj |
an object |
... |
additional arguments |
method mcmctrace
If MCMCdiag
was positive when lgcpPredict
was called, then this retrieves information from the chains stored.
## S3 method for class 'lgcpPredict' mcmctrace(obj, ...)
## S3 method for class 'lgcpPredict' mcmctrace(obj, ...)
obj |
an object of class lgcpPredict |
... |
additional arguments |
returns the saved MCMC chains in an object of class mcmcdiag
.
Generic function to extract the mean of the latent field Y.
meanfield(obj, ...)
meanfield(obj, ...)
obj |
an object |
... |
additional arguments |
method meanfield
This is an accessor function for objects of class lgcpPredict
and returns the mean of the
field Y as an lgcpgrid object.
## S3 method for class 'lgcpPredict' meanfield(obj, ...)
## S3 method for class 'lgcpPredict' meanfield(obj, ...)
obj |
an object of class lgcpPredict |
... |
additional arguments |
returns the cell-wise mean of Y computed via Monte Carlo.
A function to return the mean of the latent field from a call to lgcpPredictINLA output.
## S3 method for class 'lgcpPredictINLA' meanfield(obj, ...)
## S3 method for class 'lgcpPredictINLA' meanfield(obj, ...)
obj |
an object of class lgcpPredictINLA |
... |
other arguments |
the mean of the latent field
This function creates an object of class MonteCarloAverage
. The purpose of the function is to compute
Monte Carlo expectations online in the function lgcpPredict
, it is set in the argument gridmeans
of the argument output.control
.
MonteCarloAverage(funlist, lastonly = TRUE)
MonteCarloAverage(funlist, lastonly = TRUE)
funlist |
a character vector of names of functions, each accepting single argument Y |
lastonly |
compute average using only time T? (see ?lgcpPredict for definition of T) |
A Monte Carlo Average is computed as:
where is a function of interest,
is the
th retained sample from the target
and
is the total number of retained iterations. For example, to compute the mean of
set,
the output from such a Monte Carlo average would be a set of grids, each cell of which
being equal to the mean over all retained iterations of the algorithm (NOTE: this is just an example computation, in
practice, there is no need to compute the mean on line explicitly, as this is already done by defaul in
lgcpPredict
).
For further examples, see below. The option last=TRUE
computes,
so in this case the expectation over the last time point only is computed. This can save computation time.
object of class MonteCarloAverage
setoutput, lgcpPredict, GAinitialise, GAupdate, GAfinalise, GAreturnvalue, exceedProbs
fun1 <- function(x){return(x)} # gives the mean fun2 <- function(x){return(x^2)} # computes E(X^2). Can be used with the # mean to compute variances, since # Var(X) = E(X^2) - E(X)^2 fun3 <- exceedProbs(c(1.5,2,3)) # exceedance probabilities, #see ?exceedProbs mca <- MonteCarloAverage(c("fun1","fun2","fun3")) mca2 <- MonteCarloAverage(c("fun1","fun2","fun3"),lastonly=TRUE)
fun1 <- function(x){return(x)} # gives the mean fun2 <- function(x){return(x^2)} # computes E(X^2). Can be used with the # mean to compute variances, since # Var(X) = E(X^2) - E(X)^2 fun3 <- exceedProbs(c(1.5,2,3)) # exceedance probabilities, #see ?exceedProbs mca <- MonteCarloAverage(c("fun1","fun2","fun3")) mca2 <- MonteCarloAverage(c("fun1","fun2","fun3"),lastonly=TRUE)
Generic function used in the construction of marked space-time planar point patterns. An mstppp object is like an stppp object, but with an extra component containing a data frame (the mark information).
mstppp(P, ...)
mstppp(P, ...)
P |
an object |
... |
additional arguments |
Observations are assumed to occur in the plane and the observation window is assumed not to change over time.
method mstppp
mstppp, mstppp.ppp, mstppp.list
Construct a marked space-time planar point pattern from a list object
## S3 method for class 'list' mstppp(P, ...)
## S3 method for class 'list' mstppp(P, ...)
P |
list object containing $xyt, an (n x 3) matrix corresponding to (x,y,t) values; $tlim, a vector of length 2 givign the observation time window, $window giving an owin spatial observation winow, see ?owin for more details, and $data, a data frame containing the collection of marks |
... |
additional arguments |
an object of class mstppp
Construct a marked space-time planar point pattern from a ppp object
## S3 method for class 'ppp' mstppp(P, t, tlim, data, ...)
## S3 method for class 'ppp' mstppp(P, t, tlim, data, ...)
P |
a spatstat ppp object |
t |
a vector of length P$n |
tlim |
a vector of length 2 specifying the observation time window |
data |
a data frame containing the collection of marks |
... |
additional arguments |
an object of class mstppp
Construct a marked space-time planar point pattern from an stppp object
## S3 method for class 'stppp' mstppp(P, data, ...)
## S3 method for class 'stppp' mstppp(P, data, ...)
P |
an lgcp stppp object |
data |
a data frame containing the collection of marks |
... |
additional arguments |
an object of class mstppp
Computes a non-parametric estimate of mu(t). For the purposes of performing prediction, the alternatives are: (1) use a parameteric model as in Diggle P, Rowlingson B, Su T (2005), or (2) a constantInTime model.
muEst(xyt, ...)
muEst(xyt, ...)
xyt |
an stppp object |
... |
additional arguments to be passed to lowess |
object of class temporalAtRisk giving the smoothed mut using the lowess function
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
temporalAtRisk, constantInTime, ginhomAverage, KinhomAverage, spatialparsEst, thetaEst, lambdaEst
This function multiplies the elements of two list objects together and returns the result in another list object.
multiply.list(list1, list2)
multiply.list(list1, list2)
list1 |
a list of objects that could be summed using "+" |
list2 |
a list of objects that could be summed using "+" |
a list with ith entry the sum of list1[[i]] and list2[[i]]
Function to print right-aligned tables to the console.
neattable(mat, indent = 0)
neattable(mat, indent = 0)
mat |
a numeric or character matrix object |
indent |
indent |
prints to screen with specified indent
mat <- rbind(c("one","two","three"),matrix(round(runif(9),3),3,3)) neattable(mat)
mat <- rbind(c("one","two","three"),matrix(round(runif(9),3),3,3)) neattable(mat)
A function to compute the neighbours of a cell on a toral grid
neigh2D(i, j, ns, M, N)
neigh2D(i, j, ns, M, N)
i |
cell index i |
j |
cell index j |
ns |
number of neighbours either side |
M |
size of grid in x direction |
N |
size of grid in y direction |
the cell indices of the neighbours
just a wrapper for nextElem really.
nextStep(object)
nextStep(object)
object |
an mcmc loop object |
A null scheme, that does not perform any computation in the running of lgcpPredict
, it is the default
value of gridmeans
in the argument output.control
.
nullAverage()
nullAverage()
object of class nullAverage
setoutput, lgcpPredict, GAinitialise, GAupdate, GAfinalise, GAreturnvalue
This is a null function and performs no action.
nullFunction()
nullFunction()
object of class nullFunction
setoutput, GFinitialise, GFupdate, GFfinalise, GFreturnvalue
A function used in conjunction with the function "expectation" to compute the expected number of cases in each computational grid cell. Currently only implemented for spatial processes (lgcpPredictSpatialPlusPars and lgcpPredictAggregateSpatialPlusPars).
numCases(Y, beta, eta, Z, otherargs)
numCases(Y, beta, eta, Z, otherargs)
Y |
the latent field |
beta |
the main effects |
eta |
the parameters of the latent field |
Z |
the design matrix |
otherargs |
other arguments to the function (see vignette "Bayesian_lgcp" for an explanation) |
the number of cases in each cell
expectation, lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars
## Not run: ex <- expectation(lg,numCases)[[1]] # lg is output from spatial LGCP MCMC
## Not run: ex <- expectation(lg,numCases)[[1]] # lg is output from spatial LGCP MCMC
A function to transform a ppp object in the OSGB projection (epsg:27700) to a ppp object in the latitude/longitude (epsg:4326) projection.
osppp2latlon(obj)
osppp2latlon(obj)
obj |
a ppp object in OSGB |
a pppobject in Lat/Lon
A function to transform a ppp object in the OS GB projection (epsg:27700) to a ppp object in the Mercator (epsg:3857) projection.
osppp2merc(obj)
osppp2merc(obj)
obj |
a ppp object in OSGB |
a ppp object in Mercator
A function to compute the precision matrix of a GMRF on an M x N toral grid with neighbourhood size ns. Note that the precision matrix is block circulant. The returned function operates on a parameter vector as in Rue and Held (2005) pp 187.
paramprec(ns, M, N)
paramprec(ns, M, N)
ns |
neighbourhood size |
M |
number of cells in x direction |
N |
number of cells in y direction |
a function that returns the precision matrix given a parameter vector.
A function to compute the parametrised base matrix of a precision matrix of a GMRF on an M x N toral grid with neighbourhood size ns. Note that the precision matrix is block circulant. The returned function operates on a parameter vector as in Rue and Held (2005) pp 187.
paramprecbase(ns, M, N, inverse = FALSE)
paramprecbase(ns, M, N, inverse = FALSE)
ns |
neighbourhood size |
M |
number of x cells |
N |
number of y cells |
inverse |
whether or not to compute the base matrix of the inverse precision matrix (ie the covariance matrix). default is FALSE |
a functioin that returns the base matrix of the precision matrix
A function to produce autocorrelation plots for the paramerers beta and eta from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars
parautocorr(obj, xlab = "Lag", ylab = NULL, main = "", ask = TRUE, ...)
parautocorr(obj, xlab = "Lag", ylab = NULL, main = "", ask = TRUE, ...)
obj |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars orlgcpPredictMultitypeSpatialPlusPars |
xlab |
optional label for x-axis, there is a sensible default. |
ylab |
optional label for y-axis, there is a sensible default. |
main |
optional title of the plot, there is a sensible default. |
ask |
the paramter "ask", see ?par |
... |
other arguments passed to the function "hist" |
produces autocorrelation plots of the parameters beta and eta
ltar, autocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function to produce a summary table for the parameters beta and eta from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars
parsummary(obj, expon = TRUE, LaTeX = FALSE, ...)
parsummary(obj, expon = TRUE, LaTeX = FALSE, ...)
obj |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars orlgcpPredictMultitypeSpatialPlusPars |
expon |
whether to exponentiate the results, so that the parameters beta haev the interpretation of "relative risk per unit increase in the covariate" default is TRUE |
LaTeX |
whether to print paramter names using LaTeX symbols (if the table is later to be exported to a LaTeX document) |
... |
other arguments |
a data frame containing the median, 0.025 and 0.975 quantiles.
ltar, autocorr, parautocorr, traceplots, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
Plot method for objects of class fromSPDF.
## S3 method for class 'fromSPDF' plot(x, ...)
## S3 method for class 'fromSPDF' plot(x, ...)
x |
an object of class spatialAtRisk |
... |
additional arguments |
prints the object
Plot method for objects of class fromXYZ.
## S3 method for class 'fromXYZ' plot(x, ...)
## S3 method for class 'fromXYZ' plot(x, ...)
x |
object of class spatialAtRisk |
... |
additional arguments |
an image plot
Plots lgcpAutocorr
objects: output from autocorr
## S3 method for class 'lgcpAutocorr' plot(x, sel = 1:dim(x)[3], ask = TRUE, crop = TRUE, plotwin = FALSE, ...)
## S3 method for class 'lgcpAutocorr' plot(x, sel = 1:dim(x)[3], ask = TRUE, crop = TRUE, plotwin = FALSE, ...)
x |
an object of class lgcpAutocorr |
sel |
vector of integers between 1 and grid$len: which grids to plot. Default NULL, in which case all grids are plotted. |
ask |
logical; if TRUE the user is asked before each plot |
crop |
whether or not to crop to bounding box of observation window |
plotwin |
logical whether to plot the window attr(x,"window"), default is FALSE |
... |
other arguments passed to image.plot |
a plot
## Not run: ac <- autocorr(lg,qt=c(1,2,3)) # assumes that lg has class lgcpPredict ## Not run: plot(ac)
## Not run: ac <- autocorr(lg,qt=c(1,2,3)) # assumes that lg has class lgcpPredict ## Not run: plot(ac)
This is a wrapper function for image.lgcpgrid
## S3 method for class 'lgcpgrid' plot(x, sel = 1:x$len, ask = TRUE, ...)
## S3 method for class 'lgcpgrid' plot(x, sel = 1:x$len, ask = TRUE, ...)
x |
an object of class lgcpgrid |
sel |
vector of integers between 1 and grid$len: which grids to plot. Default NULL, in which case all grids are plotted. |
ask |
logical; if TRUE the user is asked before each plot |
... |
other arguments |
an image-type plot
lgcpgrid.list, lgcpgrid.array, as.list.lgcpgrid, print.lgcpgrid, summary.lgcpgrid,quantile.lgcpgrid, image.lgcpgrid
Simple plotting function for objects of class lgcpPredict
.
## S3 method for class 'lgcpPredict' plot( x, type = "relrisk", sel = 1:x$EY.mean$len, plotdata = TRUE, ask = TRUE, clipWindow = TRUE, ... )
## S3 method for class 'lgcpPredict' plot( x, type = "relrisk", sel = 1:x$EY.mean$len, plotdata = TRUE, ask = TRUE, clipWindow = TRUE, ... )
x |
an object of class lgcpPredict |
type |
Character string: what type of plot to produce. Choices are "relrisk" (=exp(Y)); "serr" (standard error of relative risk); or "intensity" (=lambda*mu*exp(Y)). |
sel |
vector of integers between 1 and grid$len: which grids to plot. Default NULL, in which case all grids are plotted. |
plotdata |
whether or not to overlay the data |
ask |
logical; if TRUE the user is asked before each plot |
clipWindow |
whether to plot grid cells outside the observation window |
... |
additional arguments passed to image.plot |
plots the Monte Carlo mean of quantities obtained via simulation. By default the mean relative risk is plotted.
Plots lgcpQuantiles
objects: output from quantiles.lgcpPredict
## S3 method for class 'lgcpQuantiles' plot(x, sel = 1:dim(x)[3], ask = TRUE, crop = TRUE, plotwin = FALSE, ...)
## S3 method for class 'lgcpQuantiles' plot(x, sel = 1:dim(x)[3], ask = TRUE, crop = TRUE, plotwin = FALSE, ...)
x |
an object of class lgcpQuantiles |
sel |
vector of integers between 1 and grid$len: which grids to plot. Default NULL, in which case all grids are plotted. |
ask |
logical; if TRUE the user is asked before each plot |
crop |
whether or not to crop to bounding box of observation window |
plotwin |
logical whether to plot the window attr(x,"window"), default is FALSE |
... |
other arguments passed to image.plot |
grid plotting This is a wrapper function for image.lgcpgrid
## Not run: qtiles <- quantile(lg,qt=c(0.5,0.75,0.9),fun=exp) # assumed that lg has class lgcpPredict ## Not run: plot(qtiles)
## Not run: qtiles <- quantile(lg,qt=c(0.5,0.75,0.9),fun=exp) # assumed that lg has class lgcpPredict ## Not run: plot(qtiles)
A function to plot lgcpZmat objects
## S3 method for class 'lgcpZmat' plot( x, ask = TRUE, pow = 1, main = NULL, misscol = "black", obswin = NULL, ... )
## S3 method for class 'lgcpZmat' plot( x, ask = TRUE, pow = 1, main = NULL, misscol = "black", obswin = NULL, ... )
x |
an lgcpZmat object, see ?getZmat |
ask |
graphical parameter ask, see ?par |
pow |
power parameter, raises the image values to this power (helps with visualisation, default is 1.) |
main |
title for plot, default is null which gives an automatic title to the plot (the name of the covariate) |
misscol |
colour to identify imputed grid cells, default is yellow |
obswin |
optional observation window to add to plot using plot(obswin). |
... |
other paramters |
a sequence of plots of the interpolated covariate values
The command plot(trace(lg))
, where lg
is an object of class lgcpPredict
will plot the
mcmc traces of a subset of the cells, provided they have been stored, see mcmpars
.
## S3 method for class 'mcmcdiag' plot(x, idx = 1:dim(x$trace)[2], ...)
## S3 method for class 'mcmcdiag' plot(x, idx = 1:dim(x$trace)[2], ...)
x |
an object of class mcmcdiag |
idx |
vector of chain indices to plot, default plots all chains |
... |
additional arguments passed to plot |
plots the saved MCMC chains
mcmctrace.lgcpPredict, mcmcpars,
Plot method for mstppp objects
## S3 method for class 'mstppp' plot(x, cols = "red", ...)
## S3 method for class 'mstppp' plot(x, cols = "red", ...)
x |
an object of class mstppp |
cols |
optional vector of colours to plot points with |
... |
additional arguments passed to plot |
plots the mstppp object x
Plot method for stppp objects
## S3 method for class 'stppp' plot(x, ...)
## S3 method for class 'stppp' plot(x, ...)
x |
an object of class stppp |
... |
additional arguments passed to plot |
plots the stppp object x
Pot a temporalAtRisk object.
## S3 method for class 'temporalAtRisk' plot(x, ...)
## S3 method for class 'temporalAtRisk' plot(x, ...)
x |
an object |
... |
additional arguments |
print the object
temporalAtRisk, spatialAtRisk, temporalAtRisk.numeric, temporalAtRisk.function, constantInTime, constantInTime.numeric, constantInTime.stppp, print.temporalAtRisk,
A generic function for plotting exceedance probabilities.
plotExceed(obj, ...)
plotExceed(obj, ...)
obj |
an object |
... |
additional arguments |
generic function returning method plotExceed
plotExceed.lgcpPredict, plotExceed.array
Function for plotting exceedance probabilities stored in array objects. Used in plotExceed.lgcpPredict
.
## S3 method for class 'array' plotExceed( obj, fun, lgcppredict = NULL, xvals = NULL, yvals = NULL, window = NULL, cases = NULL, nlevel = 64, ask = TRUE, mapunderlay = NULL, alpha = 1, sub = NULL, ... )
## S3 method for class 'array' plotExceed( obj, fun, lgcppredict = NULL, xvals = NULL, yvals = NULL, window = NULL, cases = NULL, nlevel = 64, ask = TRUE, mapunderlay = NULL, alpha = 1, sub = NULL, ... )
obj |
an object |
fun |
the name of the function used to compute exceedances (character vector of length 1). Note that the named function must be in memory. |
lgcppredict |
an object of class lgcpPredict that can be used to supply an observation window and x and y coordinates |
xvals |
optional vector giving x coords of centroids of cells |
yvals |
optional vector giving y coords of centroids of cells |
window |
optional obervation window |
cases |
optional xy (n x 2) matrix of locations of cases to plot |
nlevel |
number of colour levels to use in plot, default is 64 |
ask |
whether or not to ask for a new plot between plotting exceedances at different thresholds. |
mapunderlay |
optional underlay to plot underneath maps of exceedance probabilities. Use in conjunction with rainbow parameter 'alpha' (eg alpha=0.3) to set transparency of exceedance layer. |
alpha |
graphical parameter takign values in [0,1] controlling transparency of exceedance layer. Default is 1. |
sub |
optional subtitle for plot |
... |
additional arguments passed to image.plot |
generic function returning method plotExceed
Function for plotting exceedance probabilities stored in lgcpPredict
ojects.
## S3 method for class 'lgcpPredict' plotExceed( obj, fun, nlevel = 64, ask = TRUE, plotcases = FALSE, mapunderlay = NULL, alpha = 1, ... )
## S3 method for class 'lgcpPredict' plotExceed( obj, fun, nlevel = 64, ask = TRUE, plotcases = FALSE, mapunderlay = NULL, alpha = 1, ... )
obj |
an object |
fun |
the name of the function used to compute exceedances (character vector of length 1). Note that the named function must be in memory. |
nlevel |
number of colour levels to use in plot, default is 64 |
ask |
whether or not to ask for a new plot between plotting exceedances at different thresholds. |
plotcases |
whether or not to plot the cases on the map |
mapunderlay |
optional underlay to plot underneath maps of exceedance probabilities. Use in conjunction with rainbow parameter 'alpha' (eg alpha=0.3) to set transparency of exceedance layer. |
alpha |
graphical parameter takign values in [0,1] controlling transparency of exceedance layer. Default is 1. |
... |
additional arguments passed to image.plot |
plot of exceedances
lgcpPredict, MonteCarloAverage, setoutput
## Not run: exceedfun <- exceedProbs(c(1.5,2,4)) ## Not run: plot(lg,"exceedfun") # lg is an object of class lgcpPredict # in which the Monte Carlo mean of # "exceedfun" was computed # see ?MonteCarloAverage and ?setoutput ## End(Not run)
## Not run: exceedfun <- exceedProbs(c(1.5,2,4)) ## Not run: plot(lg,"exceedfun") # lg is an object of class lgcpPredict # in which the Monte Carlo mean of # "exceedfun" was computed # see ?MonteCarloAverage and ?setoutput ## End(Not run)
A function to plot various objects. A developmental tool: not intended for general use
plotit(x)
plotit(x)
x |
an a list, matrix, or GPrealisation object. |
plots the objects.
Generic function for producing plots of the posterior covariance function from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars.
postcov(obj, ...)
postcov(obj, ...)
obj |
an object |
... |
additional arguments |
method postcov
postcov.lgcpPredictSpatialOnlyPlusParameters,postcov.lgcpPredictAggregateSpatialPlusParameters, postcov.lgcpPredictSpatioTemporalPlusParameters, postcov.lgcpPredictMultitypeSpatialPlusParameters, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, exceedProbs, betavals, etavals
A function for producing plots of the posterior covariance function.
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
obj |
an lgcpPredictAggregateSpatialPlusParameters object |
qts |
vector of quantiles of length 3, default is 0.025, 0.5, 0.975 |
covmodel |
the assumed covariance model. NULL by default, this information is read in from the object obj, so generally does not need to be set. |
ask |
parameter "ask", see ?par |
... |
additional arguments |
...
postcov.lgcpPredictSpatialOnlyPlusParameters, postcov.lgcpPredictAggregateSpatialPlusParameters, postcov.lgcpPredictSpatioTemporalPlusParameters, postcov.lgcpPredictMultitypeSpatialPlusParameters, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function for producing plots of the posterior covariance function.
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
obj |
an lgcpPredictMultitypeSpatialPlusParameters object |
qts |
vector of quantiles of length 3, default is 0.025, 0.5, 0.975 |
covmodel |
the assumed covariance model. NULL by default, this information is read in from the object obj, so generally does not need to be set. |
ask |
parameter "ask", see ?par |
... |
additional arguments |
plots of the posterior covariance function for each type.
postcov.lgcpPredictSpatialOnlyPlusParameters, postcov.lgcpPredictAggregateSpatialPlusParameters, postcov.lgcpPredictSpatioTemporalPlusParameters, postcov.lgcpPredictMultitypeSpatialPlusParameters, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function for producing plots of the posterior spatial covariance function.
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
obj |
an lgcpPredictSpatialOnlyPlusParameters object |
qts |
vector of quantiles of length 3, default is 0.025, 0.5, 0.975 |
covmodel |
the assumed covariance model. NULL by default, this information is read in from the object obj, so generally does not need to be set. |
ask |
parameter "ask", see ?par |
... |
additional arguments |
a plot of the posterior covariance function.
postcov.lgcpPredictSpatialOnlyPlusParameters, postcov.lgcpPredictAggregateSpatialPlusParameters, postcov.lgcpPredictSpatioTemporalPlusParameters, postcov.lgcpPredictMultitypeSpatialPlusParameters, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function for producing plots of the posterior spatiotemporal covariance function.
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
"postcov(obj,qts=c(0.025,0.5,0.975),covmodel=NULL,ask=TRUE,...)"
obj |
an lgcpPredictSpatioTemporalPlusParameters object |
qts |
vector of quantiles of length 3, default is 0.025, 0.5, 0.975 |
covmodel |
the assumed covariance model. NULL by default, this information is read in from the object obj, so generally does not need to be set. |
ask |
parameter "ask", see ?par |
... |
additional arguments |
a plot of the posterior spatial covariance function and temporal correlation function.
postcov.lgcpPredictSpatialOnlyPlusParameters, postcov.lgcpPredictAggregateSpatialPlusParameters, postcov.lgcpPredictSpatioTemporalPlusParameters, postcov.lgcpPredictMultitypeSpatialPlusParameters, ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
Display function for dump2dir objects.
## S3 method for class 'dump2dir' print(x, ...)
## S3 method for class 'dump2dir' print(x, ...)
x |
an object of class dump2dir |
... |
additional arguments |
nothing
Print method for objects of class fromFunction.
## S3 method for class 'fromFunction' print(x, ...)
## S3 method for class 'fromFunction' print(x, ...)
x |
an object of class spatialAtRisk |
... |
additional arguments |
prints the object
Print method for objects of class fromSPDF.
## S3 method for class 'fromSPDF' print(x, ...)
## S3 method for class 'fromSPDF' print(x, ...)
x |
an object of class spatialAtRisk |
... |
additional arguments |
prints the object
Print method for objects of class fromXYZ.
## S3 method for class 'fromXYZ' print(x, ...)
## S3 method for class 'fromXYZ' print(x, ...)
x |
an object of class spatialAtRisk |
... |
additional arguments |
prints the object
Print method for gridaverage
objects
## S3 method for class 'gridaverage' print(x, ...)
## S3 method for class 'gridaverage' print(x, ...)
x |
an object of class gridaverage |
... |
other arguments |
just prints out details
Print method for lgcp grid objects.
## S3 method for class 'lgcpgrid' print(x, ...)
## S3 method for class 'lgcpgrid' print(x, ...)
x |
an object of class lgcpgrid |
... |
other arguments |
just prints out details to the console
lgcpgrid.list, lgcpgrid.array, as.list.lgcpgrid, summary.lgcpgrid quantile.lgcpgrid image.lgcpgrid plot.lgcpgrid
Print method for lgcpPredict objects.
## S3 method for class 'lgcpPredict' print(x, ...)
## S3 method for class 'lgcpPredict' print(x, ...)
x |
an object of class lgcpPredict |
... |
additional arguments |
just prints information to the screen
print method print an mcmc iterator's details
## S3 method for class 'mcmc' print(x, ...)
## S3 method for class 'mcmc' print(x, ...)
x |
a mcmc iterator |
... |
other args |
Print method for mstppp objects
## S3 method for class 'mstppp' print(x, ...)
## S3 method for class 'mstppp' print(x, ...)
x |
an object of class mstppp |
... |
additional arguments |
prints the mstppp object x
Print method for stapp objects
## S3 method for class 'stapp' print(x, printhead = TRUE, ...)
## S3 method for class 'stapp' print(x, printhead = TRUE, ...)
x |
an object of class stapp |
printhead |
whether or not to print the head of the counts matrix |
... |
additional arguments |
prints the stapp object x
Print method for stppp objects
## S3 method for class 'stppp' print(x, ...)
## S3 method for class 'stppp' print(x, ...)
x |
an object of class stppp |
... |
additional arguments |
prints the stppp object x
Printing method for temporalAtRisk objects.
## S3 method for class 'temporalAtRisk' print(x, ...)
## S3 method for class 'temporalAtRisk' print(x, ...)
x |
an object |
... |
additional arguments |
print the object
temporalAtRisk, spatialAtRisk, temporalAtRisk.numeric, temporalAtRisk.function, constantInTime, constantInTime.numeric, constantInTime.stppp, plot.temporalAtRisk
A function to plot the prior and posterior densities of the model parameters eta and beta. The prior appears as a red line and the posterior appears as a histogram.
priorpost( obj, breaks = 30, xlab = NULL, ylab = "Density", main = "", ask = TRUE, ... )
priorpost( obj, breaks = 30, xlab = NULL, ylab = "Density", main = "", ask = TRUE, ... )
obj |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars |
breaks |
"breaks" paramter from the function "hist" |
xlab |
optional label for x-axis, there is a sensible default. |
ylab |
optional label for y-axis, there is a sensible default. |
main |
optional title of the plot, there is a sensible default. |
ask |
the paramter "ask", see ?par |
... |
other arguments passed to the function "hist" |
plots of the prior and posterior of the model parameters eta and beta.
ltar, autocorr, parautocorr, traceplots, parsummary, textsummary, postcov, exceedProbs, betavals, etavals
Generic for declaring that an object is of valid type for use as as prior in lgcp. For further details and examples, see the vignette "Bayesian_lgcp".
PriorSpec(obj, ...)
PriorSpec(obj, ...)
obj |
an object |
... |
additional arguments |
method PriorSpec
Method for declaring a Bayesian prior density in lgcp. Checks to confirm that the object obj has the requisite components for functioning as a prior.
## S3 method for class 'list' PriorSpec(obj, ...)
## S3 method for class 'list' PriorSpec(obj, ...)
obj |
a list object defining a prior , see ?GaussianPrior and ?LogGaussianPrior |
... |
additional arguments |
an object suitable for use in a call to the MCMC routines
GaussianPrior, LogGaussianPrior
## Not run: PriorSpec(LogGaussianPrior(mean=log(c(1,500)),variance=diag(0.15,2))) ## Not run: PriorSpec(GaussianPrior(mean=rep(0,9),variance=diag(10^6,9)))
## Not run: PriorSpec(LogGaussianPrior(mean=log(c(1,500)),variance=diag(0.15,2))) ## Not run: PriorSpec(GaussianPrior(mean=rep(0,9),variance=diag(10^6,9)))
Quantile method for lgcp objects. This just applies the quantile function to each of the elements of x$grid
## S3 method for class 'lgcpgrid' quantile(x, ...)
## S3 method for class 'lgcpgrid' quantile(x, ...)
x |
an object of class lgcpgrid |
... |
other arguments |
Quantiles per grid, see ?quantile for further options
lgcpgrid.list, lgcpgrid.array, as.list.lgcpgrid, print.lgcpgrid, summary.lgcpgrid, image.lgcpgrid, plot.lgcpgrid
This function requires data to have been dumped to disk: see ?dump2dir
and ?setoutput
. The routine quantile.lgcpPredict
computes quantiles of functions of Y. For example, to get cell-wise quantiles of exceedance probabilities, set fun=exp
.
Since computign the quantiles is an expensive operation, the option to output the quantiles on a subregion of interest is also provided (by
setting the argument inWindow
, which has a sensible default).
## S3 method for class 'lgcpPredict' quantile( x, qt, tidx = NULL, fun = NULL, inWindow = x$xyt$window, crop2parentwindow = TRUE, startidx = 1, sampcount = NULL, ... )
## S3 method for class 'lgcpPredict' quantile( x, qt, tidx = NULL, fun = NULL, inWindow = x$xyt$window, crop2parentwindow = TRUE, startidx = 1, sampcount = NULL, ... )
x |
an object of class lgcpPredict |
qt |
a vector of the required quantiles |
tidx |
the index number of the the time interval of interest, default is the last time point. |
fun |
a 1-1 function (default the identity function) to be applied cell-wise to the grid. Must be able to evaluate sapply(vec,fun) for vectors vec. |
inWindow |
an observation owin window on which to compute the quantiles, can speed up calculation. Default is x$xyt$window. |
crop2parentwindow |
logical: whether to only compute the quantiles for cells inside x$xyt$window (the 'parent window') |
startidx |
optional starting sample index for computing quantiles. Default is 1. |
sampcount |
number of samples to include in computation of quantiles after startidx. Default is all |
... |
additional arguments |
an array, the [,,i]th slice being the grid of cell-wise quantiles, qt[i], of fun(Y), where Y is the MCMC output dumped to disk.
lgcpPredict, dump2dir, setoutput, plot.lgcpQuantiles
A function to declare and also evaluate an covariance function from the RandomFields Package. See ?CovarianceFct. Note that the present version of lgcp only offers estimation for sigma and phi, any additional paramters are treated as fixed.
RandomFieldsCovFct(model, additionalparameters = c())
RandomFieldsCovFct(model, additionalparameters = c())
model |
the choice of model e.g. "matern" |
additionalparameters |
additional parameters for chosen covariance model. See ?CovarianceFct |
a covariance function from the RandomFields package
CovFunction.function, exponentialCovFct, SpikedExponentialCovFct, CovarianceFct
## Not run: RandomFieldsCovFct(model="matern",additionalparameters=1)
## Not run: RandomFieldsCovFct(model="matern",additionalparameters=1)
A function to convert lgcpgrid objects into either a raster object, or a RasterBrick object.
## S3 method for class 'lgcpgrid' raster(x, crs = NA, transpose = FALSE, ...)
## S3 method for class 'lgcpgrid' raster(x, crs = NA, transpose = FALSE, ...)
x |
an lgcpgrid object |
crs |
PROJ4 type description of a map projection (optional). See ?raster |
transpose |
Logical. Transpose the data? See ?brick method for array |
... |
additional arguments |
...
Rescale an mstppp object. Similar to rescale.ppp
## S3 method for class 'mstppp' rescale(X, s, unitname)
## S3 method for class 'mstppp' rescale(X, s, unitname)
X |
an object of class mstppp |
s |
scale as in rescale.ppp: x and y coordinaes are scaled by 1/s |
unitname |
parameter as defined in ?rescale |
a ppp object without observation times
Rescale an stppp object. Similar to rescale.ppp
## S3 method for class 'stppp' rescale(X, s, unitname)
## S3 method for class 'stppp' rescale(X, s, unitname)
X |
an object of class stppp |
s |
scale as in rescale.ppp: x and y coordinaes are scaled by 1/s |
unitname |
parameter as defined in ?rescale |
a ppp object without observation times
call this to reset an iterator's state to the initial
resetLoop(obj)
resetLoop(obj)
obj |
an mcmc iterator |
A function to simulate a Gaussian field on a regular square lattice, the returned object is of class lgcpgrid.
rgauss( n = 1, range = c(0, 1), ncells = 128, spatial.covmodel = "exponential", model.parameters = lgcppars(sigma = 2, phi = 0.1), covpars = c(), ext = 2 )
rgauss( n = 1, range = c(0, 1), ncells = 128, spatial.covmodel = "exponential", model.parameters = lgcppars(sigma = 2, phi = 0.1), covpars = c(), ext = 2 )
n |
the number of realisations to generate. Default is 1. |
range |
a vector of length 2, defining the left-most and right most cell centroids in the x-direction. Note that the centroids in the y-direction are the same as those in the x-direction. |
ncells |
the number of cells, typially a power of 2 |
spatial.covmodel |
spatial covariance function, default is exponential, see ?CovarianceFct |
model.parameters |
parameters of model, see ?lgcppars. Only set sigma and phi for spatial model. |
covpars |
vector of additional parameters for spatial covariance function, in order they appear in chosen model in ?CovarianceFct |
ext |
how much to extend the parameter space by. Default is 2. |
an lgcp grid object containing the simulated field(s).
Compute whether there might be any advantage in rotating the observation window in the object xyt for a proposed cell width.
roteffgain(xyt, cellwidth)
roteffgain(xyt, cellwidth)
xyt |
an object of class stppp |
cellwidth |
size of grid on which to do MALA |
whether or not there woud be any efficiency gain in the MALA by rotating window
This function returns a rotation matrix corresponding to an anticlockwise rotation of theta radians about the origin
rotmat(theta)
rotmat(theta)
theta |
an angle in radians |
the transformation matrix corresponding to an anticlockwise rotation of theta radians about the origin
Generic function to return relative risk.
rr(obj, ...)
rr(obj, ...)
obj |
an object |
... |
additional arguments |
method rr
Accessor function returning the relative risk = exp(Y) as an lgcpgrid object.
## S3 method for class 'lgcpPredict' rr(obj, ...)
## S3 method for class 'lgcpPredict' rr(obj, ...)
obj |
an lgcpPredict object |
... |
additional arguments |
the relative risk as computed my MCMC
A function to draw a sample from the posterior of a spatial LGCP. Randomly selects an index i, and returns the ith value of eta, the ith value of beta and the ith value of Y as a named list.
samplePosterior(x)
samplePosterior(x)
x |
an object of class lgcpPredictSpatialOnlyPlusParameters or lgcpPredictAggregateSpatialPlusParameters |
a sample from the posterior named list object with names elements "eta", "beta" and "Y".
A function to compute segregation probabilities from a multivariate LGCP. See the vignette "Bayesian_lgcp" for a full explanation of this.
segProbs(obj, domprob)
segProbs(obj, domprob)
obj |
an lgcpPredictMultitypeSpatialPlusParameters object |
domprob |
the threshold beyond which we declare a type as dominant e.g. a value of 0.8 would mean we would consider each type to be dominant if the conditional probability of an event of a given type at that location exceeded 0.8. |
We suppose there are K point types of interest. The model for point-type k is as follows:
X_k(s) ~ Poisson[R_k(s)]
R_k(s) = C_A lambda_k(s) exp[Z_k(s)beta_k+Y_k(s)]
Here X_k(s) is the number of events of type k in the computational grid cell containing the point s, R_k(s) is the Poisson rate, C_A is the cell area, lambda_k(s) is a known offset, Z_k(s) is a vector of measured covariates and Y_i(s) where i = 1,...,K+1 are latent Gaussian processes on the computational grid. The other parameters in the model are beta_k , the covariate effects for the kth type; and eta_i = [log(sigma_i),log(phi_i)], the parameters of the process Y_i for i = 1,...,K+1 on an appropriately transformed (again, in this case log) scale.
The term 'conditional probability of type k' means the probability that at a particular location, x, there will be an event of type k, we denote this p_k(x).
It is also of interest to scientists to be able to illustrate spatial regions where a genotype dominates a posteriori. We say that type k dominates at position x if p_k(x)>c, where c (the parameter domprob) is a threshold is a threshold set by the user. Let A_k(c,q) denote the set of locations x for which P[p_k(x)>c|X] > q.
As the quantities c and q tend to 1 each area A_k(c,p) shrinks towards the empty set; this happens more slowly in a highly segregated pattern compared with a weakly segregated one.
The function segProbs computes P[p_k(x)>c|X] for each type, from which plots of P[p_k(x)>c|X] > q can be produced.
an lgcpgrid object contatining the segregation probabilities.
Generic function to return the standard error of the Poisson Intensity.
seintens(obj, ...)
seintens(obj, ...)
obj |
an object |
... |
additional arguments |
method seintens
lgcpPredict, seintens.lgcpPredict
Accessor function returning the standard error of the Poisson intensity as an lgcpgrid object.
## S3 method for class 'lgcpPredict' seintens(obj, ...)
## S3 method for class 'lgcpPredict' seintens(obj, ...)
obj |
an lgcpPredict object |
... |
additional arguments |
the cell-wise standard error of the Poisson intensity, as computed by MCMC.
See ?selectObsWindow.stppp for further details on usage. This is a generic function for the purpose of selecting an observation window (or more precisely a bounding box) to contain the extended FFT grid.
selectObsWindow(xyt, ...)
selectObsWindow(xyt, ...)
xyt |
an object |
... |
additional arguments |
method selectObsWindow
selectObsWindow.default, selectObsWindow.stppp
Default method, note at present, there is only an implementation for stppp objects.
## Default S3 method: selectObsWindow(xyt, cellwidth, ...)
## Default S3 method: selectObsWindow(xyt, cellwidth, ...)
xyt |
an object |
cellwidth |
size of the grid spacing in chosen units (equivalent to the cell width argument in lgcpPredict) |
... |
additional arguments |
!!NOTE!! that this function also returns the grid ($xvals and $yvals) on which the FFT (and hence MALA) will be performed. It is useful to define spatialAtRiskobjects on this grid to prevent loss of information from the bilinear interpolation that takes place as part of the fitting algorithm.
this is the same as selectObsWindow.stppp
spatialAtRisk selectObsWindow.stppp
This function computes an appropriate observation window on which to perform prediction. Since the FFT grid
must have dimension 2^M by 2^N for some M and N, the window xyt$window
, is extended to allow this to be fit in for a given cell width.
## S3 method for class 'stppp' selectObsWindow(xyt, cellwidth, ...)
## S3 method for class 'stppp' selectObsWindow(xyt, cellwidth, ...)
xyt |
an object of class stppp |
cellwidth |
size of the grid spacing in chosen units (equivalent to the cell width argument in lgcpPredict) |
... |
additional arguments |
!!NOTE!! that this function also returns the grid ($xvals and $yvals) on which the FFT (and hence MALA) will be performed. It is useful to define spatialAtRiskobjects on this grid to prevent loss of information from the bilinear interpolation that takes place as part of the fitting algorithm.
a resized stppp object together with grid sizes M and N ready for FFT, together with the FFT grid locations, can be useful for estimating lambda(s)
Generic function to return standard error of relative risk.
serr(obj, ...)
serr(obj, ...)
obj |
an object |
... |
additional arguments |
method serr
Accessor function returning the standard error of relative risk as an lgcpgrid object.
## S3 method for class 'lgcpPredict' serr(obj, ...)
## S3 method for class 'lgcpPredict' serr(obj, ...)
obj |
an lgcpPredict object |
... |
additional arguments |
Standard error of the relative risk as computed by MCMC.
Sets output functionality for lgcpPredict via the main functions dump2dir and MonteCarloAverage. Note that it is possible for
the user to create their own gridfunction
and gridmeans
schemes.
setoutput(gridfunction = NULL, gridmeans = NULL)
setoutput(gridfunction = NULL, gridmeans = NULL)
gridfunction |
what to do with the latent field, but default this set to nothing, but could save output to a directory, see ?dump2dir |
gridmeans |
list of Monte Carlo averages to compute, see ?MonteCarloAverage |
output parameters
lgcpPredict, dump2dir, MonteCarloAverage
update a text progress bar. See help(txtProgressBar) for more info.
setTxtProgressBar2(pb, value, title = NULL, label = NULL)
setTxtProgressBar2(pb, value, title = NULL, label = NULL)
pb |
text progress bar object |
value |
new value |
title |
ignored |
label |
text for end of progress bar |
Generic method for displaying the FFT grid used in computation.
showGrid(x, ...)
showGrid(x, ...)
x |
an object |
... |
additional arguments |
generic function returning method showGrid
showGrid.default, showGrid.lgcpPredict, showGrid.stppp
Default method for printing a grid to a screen. Arguments are vectors giving the x any y coordinates of the centroids.
## Default S3 method: showGrid(x, y, ...)
## Default S3 method: showGrid(x, y, ...)
x |
an vector of grid values for the x coordinates |
y |
an vector of grid values for the y coordinates |
... |
additional arguments passed to points |
plots grid centroids on the current graphics device
showGrid.lgcpPredict, showGrid.stppp
This function displays the FFT grid used on a plot of an lgcpPredict
object.
First plot the object using for example plot(lg)
, where lg
is an object
of class lgcpPredict
, then for any of the plots produced, a call to
showGrid(lg,pch=="+",cex=0.5)
will display the centroids of the FFT grid.
## S3 method for class 'lgcpPredict' showGrid(x, ...)
## S3 method for class 'lgcpPredict' showGrid(x, ...)
x |
an object of class lgcpPredict |
... |
additional arguments passed to points |
plots grid centroids on the current graphics device
lgcpPredict, showGrid.default, showGrid.stppp
If an stppp object has been created via simulation, ie using the function lgcpSim
, then
this function will display the grid centroids that were used in the simulation
## S3 method for class 'stppp' showGrid(x, ...)
## S3 method for class 'stppp' showGrid(x, ...)
x |
an object of class stppp. Note this function oly applies to SIMULATED data. |
... |
additional arguments passed to points |
plots grid centroids on the current graphics device. FOR SIMULATED DATA ONLY.
lgcpSim, showGrid.default, showGrid.lgcpPredict
## Not run: xyt <- lgcpSim() ## Not run: plot(xyt) ## Not run: showGrid(xyt,pch="+",cex=0.5)
## Not run: xyt <- lgcpSim() ## Not run: plot(xyt) ## Not run: showGrid(xyt,pch="+",cex=0.5)
This function multiplies each element of a list by a scalar constant.
smultiply.list(list, const)
smultiply.list(list, const)
list |
a list of objects that could be summed using "+" |
const |
a numeric constant |
a list with ith entry the scalar multiple of const * list[[i]]
A function that returns the full precision matrix in sparse format from the base of a block circulant matrix, see ?Matrix::sparseMatrix
sparsebase(base)
sparsebase(base)
base |
base matrix of a block circulant matrix |
...
The methods for this generic function:spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame and spatialAtRisk.bivden are used to represent the fixed spatial component, lambda(s) in the log-Gaussian Cox process model. Typically lambda(s) would be represented as a spatstat object of class im, that encodes population density information. However, regardless of the physical interpretation of lambda(s), in lgcp we assume that it integrates to 1 over the observation window. The above methods make sure this condition is satisfied (with the exception of the method for objects of class function), as well as providing a framework for manipulating these structures. lgcp uses bilinear interpolation to project a user supplied lambda(s) onto a discrete grid ready for inference via MCMC, this grid can be obtained via the selectObsWindow function.
spatialAtRisk(X, ...)
spatialAtRisk(X, ...)
X |
an object |
... |
additional arguments |
Generic function used in the construction of spatialAtRisk objects. The class of spatialAtRisk objects provide a framework for describing the spatial inhomogeneity of the at-risk population, lambda(s). This is in contrast to the class of temporalAtRisk objects, which describe the global levels of the population at risk, mu(t).
Unless the user has specified lambda(s) directly by an R function (a mapping the from the real plane onto the non-negative real numbers, see ?spatialAtRisk.function), then it is only necessary to describe the population at risk up to a constant of proportionality, as the routines automatically normalise the lambda provided to integrate to 1.
For reference purposes, the following is a mathematical description of a log-Gaussian Cox Process, it is best viewed in the pdf version of the manual.
Let be a spatiotemporal Gaussian process,
be an
observation window in space and
be an interval of time of interest.
Cases occur at spatio-temporal positions
according to an inhomogeneous spatio-temporal Cox process,
i.e. a Poisson process with a stochastic intensity
,
The number of cases,
, arising in
any
during the interval
is
then Poisson distributed conditional on
,
Following Brix and Diggle (2001) and Diggle et al (2005), the intensity is decomposed multiplicatively as
In the above, the fixed spatial component, ,
is a known function, proportional to the population at risk at each point in space and scaled so that
whilst the fixed temporal component,
, is also a known function with
for in a small interval of time,
, over which the rate of the process over
can be considered constant.
method spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
selectObsWindow lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame, spatialAtRisk.bivden
Creates a spatialAtRisk object from a sparr bivden object
## S3 method for class 'bivden' spatialAtRisk(X, ...)
## S3 method for class 'bivden' spatialAtRisk(X, ...)
X |
a bivden object |
... |
additional arguments |
object of class spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame
The default method for creating a spatialAtRisk object, which attempts to extract x, y and Zm values from the object using xvals
,
yvals
and zvals
.
## Default S3 method: spatialAtRisk(X, ...)
## Default S3 method: spatialAtRisk(X, ...)
X |
an object |
... |
additional arguments |
object of class spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame, spatialAtRisk.bivden, xvals
, yvals
, zvals
Creates a spatialAtRisk object from a list of X, Y, Zm giving respectively the x and y coordinates of the grid and the 'z' values ie so that Zm[i,j] is proportional to the at-risk population at X[i], Y[j].
## S3 method for class 'fromXYZ' spatialAtRisk(X, Y, Zm, ...)
## S3 method for class 'fromXYZ' spatialAtRisk(X, Y, Zm, ...)
X |
vector of x-coordinates |
Y |
vector of y-coordinates |
Zm |
matrix such that Zm[i,j] = f(x[i],y[j]) for some function f |
... |
additional arguments |
object of class spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame, spatialAtRisk.bivden
Creates a spatialAtRisk object from a function mapping R^2 onto the non negative reals. Note that for spatialAtRisk objects defined in this manner, the user is responsible for ensurng that the integral of the function is 1 over the observation window of interest.
## S3 method for class ''function'' spatialAtRisk(X, warn = TRUE, ...)
## S3 method for class ''function'' spatialAtRisk(X, warn = TRUE, ...)
X |
a function with accepts arguments x and y that returns the at risk population at coordinate (x,y), which should be a numeric of length 1 |
warn |
whether to issue a warning or not |
... |
additional arguments |
object of class spatialAtRisk NOTE The function provided is assumed to integrate to 1 over the observation window, the user is responsible for ensuring this is the case.
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame, spatialAtRisk.bivden
Creates a spatialAtRisk object from a spatstat pixel image (im) object.
## S3 method for class 'im' spatialAtRisk(X, ...)
## S3 method for class 'im' spatialAtRisk(X, ...)
X |
object of class im |
... |
additional arguments |
object of class spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame, spatialAtRisk.bivden
Creates a spatialAtRisk object from an lgcpgrid object
## S3 method for class 'lgcpgrid' spatialAtRisk(X, idx = length(X$grid), ...)
## S3 method for class 'lgcpgrid' spatialAtRisk(X, idx = length(X$grid), ...)
X |
an lgcpgrid object |
idx |
in the case that X$grid is a list of length > 1, this argument specifies which element of the list to convert. By default, it is the last. |
... |
additional arguments |
object of class spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.SpatialPolygonsDataFrame
Creates a spatialAtRisk object from an sp SpatialGridDataFrame object
## S3 method for class 'SpatialGridDataFrame' spatialAtRisk(X, ...)
## S3 method for class 'SpatialGridDataFrame' spatialAtRisk(X, ...)
X |
a SpatialGridDataFrame object |
... |
additional arguments |
object of class spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialPolygonsDataFrame, spatialAtRisk.bivden
Creates a spatialAtRisk object from a SpatialPolygonsDataFrame object.
## S3 method for class 'SpatialPolygonsDataFrame' spatialAtRisk(X, ...)
## S3 method for class 'SpatialPolygonsDataFrame' spatialAtRisk(X, ...)
X |
a SpatialPolygonsDataFrame object; one column of the data frame should have name "atrisk", containing the aggregate population at risk for that region |
... |
additional arguments |
object of class spatialAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
lgcpPredict, linklgcpSim, spatialAtRisk.default, spatialAtRisk.fromXYZ, spatialAtRisk.im, spatialAtRisk.function, spatialAtRisk.SpatialGridDataFrame, spatialAtRisk.bivden
Generic method for extracting spatial intensities.
spatialIntensities(X, ...)
spatialIntensities(X, ...)
X |
an object |
... |
additional arguments |
method spatialintensities
spatialIntensities.fromXYZ, spatialIntensities.fromSPDF
Extract the spatial intensities from an object of class fromSPDF (as would have been created by spatialAtRisk.SpatialPolygonsDataFrame for example).
## S3 method for class 'fromSPDF' spatialIntensities(X, xyt, ...)
## S3 method for class 'fromSPDF' spatialIntensities(X, xyt, ...)
X |
an object of class fromSPDF |
xyt |
object of class stppp or a list object of numeric vectors with names $x, $y |
... |
additional arguments |
normalised spatial intensities
spatialIntensities, spatialIntensities.fromXYZ
Extract the spatial intensities from an object of class fromXYZ (as would have been created by spatialAtRisk for example).
## S3 method for class 'fromXYZ' spatialIntensities(X, xyt, ...)
## S3 method for class 'fromXYZ' spatialIntensities(X, xyt, ...)
X |
object of class fromXYZ |
xyt |
object of class stppp or a list object of numeric vectors with names $x, $y |
... |
additional arguments |
normalised spatial intensities
spatialIntensities, spatialIntensities.fromSPDF
Having estimated either the pair correlation or K functions using respectively ginhomAverage or KinhomAverage, the spatial parameters sigma and phi can be estimated. This function provides a visual tool for this estimation procedure.
spatialparsEst( gk, sigma.range, phi.range, spatial.covmodel, covpars = c(), guess = FALSE )
spatialparsEst( gk, sigma.range, phi.range, spatial.covmodel, covpars = c(), guess = FALSE )
gk |
an R object; output from the function KinhomAverage or ginhomAverage |
sigma.range |
range of sigma values to consider |
phi.range |
range of phi values to consider |
spatial.covmodel |
correlation type see ?CovarianceFct |
covpars |
vector of additional parameters for certain classes of covariance function (eg Matern), these must be supplied in the order given in ?CovarianceFct |
guess |
logical. Perform an initial guess at paramters? Alternative (the default) sets initial values in the middle of sigma.range and phi.range. NOTE: automatic parameter estimation can be can be unreliable. |
To get a good choice of parameters, it is likely that the routine will have to be called several times in order to refine the choice of sigma.range and phi.range.
rpanel function to help choose sigma nad phi by eye
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Baddeley AJ, Moller J, Waagepetersen R (2000). Non-and semi-parametric estimation of interaction in inhomogeneous point patterns. Statistica Neerlandica, 54, 329-350.
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
ginhomAverage, KinhomAverage, thetaEst, lambdaEst, muEst
A function to return the SpatialPolygonsDataFrame part of an stapp object
SpatialPolygonsDataFrame.stapp(from)
SpatialPolygonsDataFrame.stapp(from)
from |
stapp object |
an object of class SpatialPolygonsDataFrame
A function to declare and also evaluate a spiked exponential covariance function. Note that the present version of lgcp only offers estimation for sigma and phi, the additional parameter 'spikevar' is treated as fixed.
SpikedExponentialCovFct(d, CovParameters, spikevar = 1)
SpikedExponentialCovFct(d, CovParameters, spikevar = 1)
d |
toral distance |
CovParameters |
parameters of the latent field, an object of class "CovParamaters". |
spikevar |
the additional variance at distance 0 |
the spiked exponential covariance function; note that the spikevariance is currently not estimated as part of the MCMC routine, and is thus treated as a fixed parameter.
CovFunction.function, exponentialCovFct, RandomFieldsCovFct
Generic function for space-time aggregated point-process data
stapp(obj, ...)
stapp(obj, ...)
obj |
an object |
... |
additional arguments |
method stapp
A wrapper function for stapp.SpatialPolygonsDataFrame
## S3 method for class 'list' stapp(obj, ...)
## S3 method for class 'list' stapp(obj, ...)
obj |
an list object as described above, see ?stapp.SpatialPolygonsDataFrame for further details on the requirements of the list |
... |
additional arguments |
Construct a space-time aggregated point-process (stapp) object from a list object. The first element of the list should be a SpatialPolygonsDataFrame, the second element of the list a counts matrix, the third element of the list a vector of times, the fourth element a vector giving the bounds of the temporal observation window and the fifth element a spatstat owin object giving the spatial observation window.
an object of class stapp
Construct a space-time aggregated point-process (stapp) object from a SpatialPolygonsDataFrame (along with some other info)
## S3 method for class 'SpatialPolygonsDataFrame' stapp(obj, counts, t, tlim, window, ...)
## S3 method for class 'SpatialPolygonsDataFrame' stapp(obj, counts, t, tlim, window, ...)
obj |
an SpatialPolygonsDataFrame object |
counts |
a (length(t) by N) matrix containing aggregated case counts for each of the geographical regions defined by the SpatialPolygonsDataFrame, where N is the number of regions |
t |
vector of times, for each element of t there should correspond a column in the matrix 'counts' |
tlim |
vector giving the upper and lower bounds of the temporal observation window |
window |
the observation window, of class owin, see ?owin |
... |
additional arguments |
an object of class stapp
A function to store a realisation of a spatiotemporal gaussian process for use in MCMC algorithms that include Bayesian parameter estimation. Stores not only the realisation, but also computational quantities.
stGPrealisation(gamma, fftgrid, covFunction, covParameters, d, tdiff)
stGPrealisation(gamma, fftgrid, covFunction, covParameters, d, tdiff)
gamma |
the transformed (white noise) realisation of the process |
fftgrid |
an object of class FFTgrid, see ?genFFTgrid |
covFunction |
an object of class function returning the spatial covariance |
covParameters |
an object of class CovParamaters, see ?CovParamaters |
d |
matrix of grid distances |
tdiff |
vector of time differences |
a realisation of a spatiotemporal Gaussian process on a regular grid
Generic function used in the construction of space-time planar point patterns. An stppp object is like a ppp object, but with extra components for (1) a vector giving the time at whcih the event occurred and (2) a time-window over which observations occurred. Observations are assumed to occur in the plane and the observation window is assumed not to change over time.
stppp(P, ...)
stppp(P, ...)
P |
an object |
... |
additional arguments |
method stppp
Construct a space-time planar point pattern from a list object
## S3 method for class 'list' stppp(P, ...)
## S3 method for class 'list' stppp(P, ...)
P |
list object containing $data, an (n x 3) matrix corresponding to (x,y,t) values; $tlim, a vector of length 2 givign the observation time window; and $window giving an owin spatial observation winow, see ?owin for more details |
... |
additional arguments |
an object of class stppp
Construct a space-time planar point pattern from a ppp object
## S3 method for class 'ppp' stppp(P, t, tlim, ...)
## S3 method for class 'ppp' stppp(P, t, tlim, ...)
P |
a spatstat ppp object |
t |
a vector of length P$n |
tlim |
a vector of length 2 specifying the observation time window |
... |
additional arguments |
an object of class stppp
Summary method for lgcp objects. This just applies the summary function to each of the elements of object$grid.
## S3 method for class 'lgcpgrid' summary(object, ...)
## S3 method for class 'lgcpgrid' summary(object, ...)
object |
an object of class lgcpgrid |
... |
other arguments |
Summary per grid, see ?summary for further options
lgcpgrid.list, lgcpgrid.array, as.list.lgcpgrid, print.lgcpgrid, quantile.lgcpgrid, image.lgcpgrid, plot.lgcpgrid
summary of an mcmc iterator print out values of an iterator and reset it. DONT call this in a loop that uses this iterator - it will reset it. And break.
## S3 method for class 'mcmc' summary(object, ...)
## S3 method for class 'mcmc' summary(object, ...)
object |
an mcmc iterator |
... |
other args |
A function to compute the target and gradient for the Bayesian aggregated point process model. Not for general use.
target.and.grad.AggregateSpatialPlusPars( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc )
target.and.grad.AggregateSpatialPlusPars( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc )
GP |
an object constructed using GPrealisation |
prior |
the prior, created using lgcpPrior |
Z |
the design matrix on the full FFT grid |
Zt |
the transpose of the design matrix |
eta |
the model parameter, eta |
beta |
the model parameters, beta |
nis |
cell counts on the FFT grid |
cellarea |
the cell area |
spatial |
the poisson offset |
gradtrunc |
the gradient truncation parameter |
the target and gradient
A function to compute the taget an gradient for the Bayesian multivariate lgcp
target.and.grad.MultitypespatialPlusPars( GPlist, priorlist, Zlist, Ztlist, eta, beta, nis, cellarea, spatial, gradtrunc )
target.and.grad.MultitypespatialPlusPars( GPlist, priorlist, Zlist, Ztlist, eta, beta, nis, cellarea, spatial, gradtrunc )
GPlist |
list of Gaussian processes |
priorlist |
list of priors |
Zlist |
list of design matrices on the FFT gridd |
Ztlist |
list of transposed design matrices |
eta |
LGCP model parameter eta |
beta |
LGCP model parameter beta |
nis |
matrix of cell counts on the extended grid |
cellarea |
the cell area |
spatial |
the poisson offset interpolated onto the correcy grid |
gradtrunc |
gradient truncation paramter |
the target and gradient
A function to compute the target and gradient for 'spatial only' MALA
target.and.grad.spatial( Gamma, nis, cellarea, rootQeigs, invrootQeigs, mu, spatial, logspat, scaleconst, gradtrunc )
target.and.grad.spatial( Gamma, nis, cellarea, rootQeigs, invrootQeigs, mu, spatial, logspat, scaleconst, gradtrunc )
Gamma |
current state of the chain, Gamma |
nis |
matrix of cell counts |
cellarea |
area of cells, a positive number |
rootQeigs |
square root of the eigenvectors of the precision matrix |
invrootQeigs |
inverse square root of the eigenvectors of the precision matrix |
mu |
parameter of the latent Gaussian field |
spatial |
spatial at risk function, lambda, interpolated onto correct grid |
logspat |
log of spatial at risk function, lambda*scaleconst, interpolated onto correct grid |
scaleconst |
the expected number of cases |
gradtrunc |
gradient truncation parameter |
the back-transformed Y, its exponential, the log-target and gradient for use in MALAlgcpSpatial
A function to compute the target and gradient for the Bayesian spatial LGCP
target.and.grad.spatialPlusPars( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc )
target.and.grad.spatialPlusPars( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc )
GP |
an object created using GPrealisation |
prior |
the model priors, created using lgcpPrior |
Z |
the design matrix on the FFT grid |
Zt |
transpose of the design matrix |
eta |
the paramters, eta |
beta |
the parameters, beta |
nis |
cell counts on the FFT grid |
cellarea |
the cell area |
spatial |
poisson offset |
gradtrunc |
the gradient truncation parameter |
the target and graient for this model
A function to compute the target and gradient for 'spatial only' MALA
target.and.grad.spatiotemporal( Gamma, nis, cellarea, rootQeigs, invrootQeigs, mu, spatial, logspat, temporal, bt, gt, gradtrunc )
target.and.grad.spatiotemporal( Gamma, nis, cellarea, rootQeigs, invrootQeigs, mu, spatial, logspat, temporal, bt, gt, gradtrunc )
Gamma |
current state of the chain, Gamma |
nis |
matrix of cell counts |
cellarea |
area of cells, a positive number |
rootQeigs |
square root of the eigenvectors of the precision matrix |
invrootQeigs |
inverse square root of the eigenvectors of the precision matrix |
mu |
parameter of the latent Gaussian field |
spatial |
spatial at risk function, lambda, interpolated onto correct grid |
logspat |
log of spatial at risk function, lambda*scaleconst, interpolated onto correct grid |
temporal |
fitted temoporal values |
bt |
in Brix and Diggle vector b(delta t) |
gt |
in Brix and Diggle vector g(delta t) (ie the coefficient of R in G(t)), with convention that (deltat[1])=Inf |
gradtrunc |
gradient truncation parameter |
the back-transformed Y, its exponential, the log-target and gradient for use in MALAlgcp
A function to compute the target and gradient for the Bayesian spatiotemporal LGCP.
target.and.grad.SpatioTemporalPlusPars( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc, ETA0, tdiff )
target.and.grad.SpatioTemporalPlusPars( GP, prior, Z, Zt, eta, beta, nis, cellarea, spatial, gradtrunc, ETA0, tdiff )
GP |
an object created using the stGPrealisation function |
prior |
the priors for hte model, created using lgcpPrior |
Z |
the design matrix on the FFT grid |
Zt |
the transpose of the design matrix |
eta |
the paramers eta |
beta |
the parameters beta |
nis |
the cell counts on the FFT grid |
cellarea |
the cell area |
spatial |
the poisson offset |
gradtrunc |
the gradient truncation parameter |
ETA0 |
the initial value of eta |
tdiff |
vector of time differences between time points |
the target and gradient for the spatiotemporal model.
Generic function used in the construction of temporalAtRisk objects. A temporalAtRisk object describes the at risk population globally in an observation time window [t_1,t_2]. Therefore, for any t in [t_1,t_2], a temporalAtRisk object should be able to return the global at risk population, mu(t) = E(number of cases in the unit time interval containing t). This is in contrast to the class of spatialAtRisk objects, which describe the spatial inhomogeneity in the population at risk, lambda(s).
temporalAtRisk(obj, ...)
temporalAtRisk(obj, ...)
obj |
an object |
... |
additional arguments |
Note that in the prediction routine, lgcpPredict, and the simulation routine, lgcpSim, time discretisation is achieved
using as.integer
on both observation times and time limits t_1 and t_2 (which may be stored as non-integer values). The
functions that create temporalAtRisk objects therefore return piecewise cconstant step-functions. that can be evaluated for any real
t in [t_1,t_2], but with the restriction that mu(t_i) = mu(t_j) whenever as.integer(t_i)==as.integer(t_j)
.
A temporalAtRisk object may be (1) 'assumed known', or (2) scaled to a particular dataset. In the latter case, in the routines available (temporalAtRisk.numeric and temporalAtRisk.function), the stppp dataset of interest should be referenced, in which case the scaling of mu(t) will be done automatically. Otherwise, for example for simulation purposes, no scaling of mu(t) occurs, and it is assumed that the mu(t) corresponds to the expected number of cases during the unit time interval containnig t. For reference purposes, the following is a mathematical description of a log-Gaussian Cox Process, it is best viewed in the pdf version of the manual.
Let be a spatiotemporal Gaussian process,
be an
observation window in space and
be an interval of time of interest.
Cases occur at spatio-temporal positions
according to an inhomogeneous spatio-temporal Cox process,
i.e. a Poisson process with a stochastic intensity
,
The number of cases,
, arising in
any
during the interval
is
then Poisson distributed conditional on
,
Following Brix and Diggle (2001) and Diggle et al (2005), the intensity is decomposed multiplicatively as
In the above, the fixed spatial component, ,
is a known function, proportional to the population at risk at each point in space and scaled so that
whilst the fixed temporal component,
, is also a known function with
for in a small interval of time,
, over which the rate of the process over
can be considered constant.
method temporalAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
spatialAtRisk, lgcpPredict, lgcpSim, temporalAtRisk.numeric, temporalAtRisk.function, constantInTime, constantInTime.numeric, constantInTime.stppp, print.temporalAtRisk, plot.temporalAtRisk
Create a temporalAtRisk object from a function.
## S3 method for class ''function'' temporalAtRisk(obj, tlim, xyt = NULL, warn = TRUE, ...)
## S3 method for class ''function'' temporalAtRisk(obj, tlim, xyt = NULL, warn = TRUE, ...)
obj |
a function accepting single, scalar, numeric argument, t, that returns the temporal intensity for time t |
tlim |
an integer vector of length 2 giving the time limits of the observation window |
xyt |
an object of class stppp. If NULL (default) then the function returned is not scaled. Otherwise, the function is scaled so that f(t) = expected number of counts at time t. |
warn |
Issue a warning if the given temporal intensity treated is treated as 'known'? |
... |
additional arguments |
Note that in the prediction routine, lgcpPredict, and the simulation routine, lgcpSim, time discretisation is achieved
using as.integer
on both observation times and time limits t_1 and t_2 (which may be stored as non-integer values). The
functions that create temporalAtRisk objects therefore return piecewise cconstant step-functions. that can be evaluated for any real
t in [t_1,t_2], but with the restriction that mu(t_i) = mu(t_j) whenever as.integer(t_i)==as.integer(t_j)
.
A temporalAtRisk object may be (1) 'assumed known', corresponding to the default argument xyt=NULL
; or (2) scaled to a particular dataset
(argument xyt=[stppp object of interest]). In the latter case, in the routines available (temporalAtRisk.numeric
and temporalAtRisk.function), the dataset of interest should be referenced, in which case the scaling of mu(t) will be done
automatically. Otherwise, for example for simulation purposes, no scaling of mu(t) occurs, and it is assumed that the mu(t) corresponds to the
expected number of cases during the unit time interval containnig t.
a function f(t) giving the temporal intensity at time t for integer t in the interval [tlim[1],tlim[2]] of class temporalAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
temporalAtRisk, spatialAtRisk, temporalAtRisk.numeric, constantInTime, constantInTime.numeric, constantInTime.stppp, print.temporalAtRisk, plot.temporalAtRisk
Create a temporalAtRisk object from a numeric vector.
## S3 method for class 'numeric' temporalAtRisk(obj, tlim, xyt = NULL, warn = TRUE, ...)
## S3 method for class 'numeric' temporalAtRisk(obj, tlim, xyt = NULL, warn = TRUE, ...)
obj |
a numeric vector of length (tlim[2]-tlim[1] + 1) giving the temporal intensity up to a constant of proportionality at each integer time within the interval defined by tlim |
tlim |
an integer vector of length 2 giving the time limits of the observation window |
xyt |
an object of class stppp. If NULL (default) then the function returned is not scaled. Otherwise, the function is scaled so that f(t) = expected number of counts at time t. |
warn |
Issue a warning if the given temporal intensity treated is treated as 'known'? |
... |
additional arguments |
Note that in the prediction routine, lgcpPredict, and the simulation routine, lgcpSim, time discretisation is achieved
using as.integer
on both observation times and time limits t_1 and t_2 (which may be stored as non-integer values). The
functions that create temporalAtRisk objects therefore return piecewise constant step-functions that can be evaluated for any real
t in [t_1,t_2], but with the restriction that mu(t_i) = mu(t_j) whenever as.integer(t_i)==as.integer(t_j)
.
A temporalAtRisk object may be (1) 'assumed known', corresponding to the default argument xyt=NULL
; or (2) scaled to a particular dataset
(argument xyt=[stppp object of interest]). In the latter case, in the routines available (temporalAtRisk.numeric
and temporalAtRisk.function), the dataset of interest should be referenced, in which case the scaling of mu(t) will be done
automatically. Otherwise, for example for simulation purposes, no scaling of mu(t) occurs, and it is assumed that the mu(t) corresponds to the
expected number of cases during the unit time interval containing t.
a function f(t) giving the temporal intensity at time t for integer t in the interval as.integer([tlim[1],tlim[2]]) of class temporalAtRisk
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
temporalAtRisk, spatialAtRisk, temporalAtRisk.function, constantInTime, constantInTime.numeric, constantInTime.stppp, print.temporalAtRisk, plot.temporalAtRisk
A function to create a temporary raster object from an x-y regular grid of cell centroids. Useful for projection from one raster to another.
tempRaster(mcens, ncens)
tempRaster(mcens, ncens)
mcens |
vector of equally-spaced coordinates of cell centroids in x-direction |
ncens |
vector of equally-spaced coordinates of cell centroids in y-direction |
an empty raster object
A function to print a text description of the inferred paramerers beta and eta from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars
textsummary(obj, digits = 3, scientific = -3, inclIntercept = FALSE, ...)
textsummary(obj, digits = 3, scientific = -3, inclIntercept = FALSE, ...)
obj |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars orlgcpPredictMultitypeSpatialPlusPars |
digits |
see the option "digits" in ?format |
scientific |
see the option "scientific" in ?format |
inclIntercept |
logical: whether to summarise the intercept term, default is FALSE. |
... |
other arguments passed to the function "format" |
A text summary, that can be pasted into a LaTeX document and later edited.
ltar, autocorr, parautocorr, traceplots, parsummary, priorpost, postcov, exceedProbs, betavals, etavals
A tool to visually estimate the temporal correlation parameter theta; note that sigma and phi must have first been estiamted.
thetaEst( xyt, spatial.intensity = NULL, temporal.intensity = NULL, sigma, phi, theta.range = c(0, 10), N = 100, spatial.covmodel = "exponential", covpars = c() )
thetaEst( xyt, spatial.intensity = NULL, temporal.intensity = NULL, sigma, phi, theta.range = c(0, 10), N = 100, spatial.covmodel = "exponential", covpars = c() )
xyt |
object of class stppp |
spatial.intensity |
A spatial at risk object OR a bivariate density estimate of lambda, an object of class im (produced from density.ppp for example), |
temporal.intensity |
either an object of class temporalAtRisk, or one that can be coerced into that form. If NULL (default), this is estimated from the data, seee ?muEst |
sigma |
estimate of parameter sigma |
phi |
estimate of parameter phi |
theta.range |
range of theta values to consider |
N |
number of integration points in computation of C(v,beta) (see Brix and Diggle 2003, corrigendum to Brix and Diggle 2001) |
spatial.covmodel |
spatial covariance model |
covpars |
additional covariance parameters |
An r panel tool for visual estimation of temporal parameter theta NOTE if lambdaEst has been invoked to estimate lambda, then the returned density should be passed to thetaEst as the argument spatial.intensity
Benjamin M. Taylor, Tilman M. Davies, Barry S. Rowlingson, Peter J. Diggle (2013). Journal of Statistical Software, 52(4), 1-40. URL http://www.jstatsoft.org/v52/i04/
Brix A, Diggle PJ (2001). Spatiotemporal Prediction for log-Gaussian Cox processes. Journal of the Royal Statistical Society, Series B, 63(4), 823-841.
Diggle P, Rowlingson B, Su T (2005). Point Process Methodology for On-line Spatio-temporal Disease Surveillance. Environmetrics, 16(5), 423-434.
ginhomAverage, KinhomAverage, spatialparsEst, lambdaEst, muEst
A function to compute the covariance matrix of a stationary process on a torus.
toral.cov.mat(xg, yg, sigma, phi, model, additionalparameters)
toral.cov.mat(xg, yg, sigma, phi, model, additionalparameters)
xg |
x grid |
yg |
y grid |
sigma |
spatial variability parameter |
phi |
spatial decay parameter |
model |
model for covariance, see ?CovarianceFct |
additionalparameters |
additional parameters for covariance structure |
circulant covariacne matrix
A function to compute which cells are touching an owin or spatial polygons object
touchingowin(x, y, w)
touchingowin(x, y, w)
x |
grid centroids in x-direction note this will be expanded into a GRID of (x,y) values in the function |
y |
grid centroids in y-direction note this will be expanded into a GRID of (x,y) values in the function |
w |
an owin or SpatialPolygons object |
vector of TRUE or FALSE according to whether the cell
A function to produce trace plots for the paramerers beta and eta from a call to the function lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars or lgcpPredictMultitypeSpatialPlusPars
traceplots(obj, xlab = "Sample No.", ylab = NULL, main = "", ask = TRUE, ...)
traceplots(obj, xlab = "Sample No.", ylab = NULL, main = "", ask = TRUE, ...)
obj |
an object produced by a call to lgcpPredictSpatialPlusPars, lgcpPredictAggregateSpatialPlusPars, lgcpPredictSpatioTemporalPlusPars orlgcpPredictMultitypeSpatialPlusPars |
xlab |
optional label for x-axis, there is a sensible default. |
ylab |
optional label for y-axis, there is a sensible default. |
main |
optional title of the plot, there is a sensible default. |
ask |
the paramter "ask", see ?par |
... |
other arguments passed to the function "hist" |
produces MCMC trace plots of the parameters beta and eta
ltar, autocorr, parautocorr, parsummary, textsummary, priorpost, postcov, exceedProbs, betavals, etavals
A function to return a transparent black colour.
transblack(alpha = 0.1)
transblack(alpha = 0.1)
alpha |
transparency parameter, see ?rgb |
character string of colour
A function to return a transparent blue colour.
transblue(alpha = 0.1)
transblue(alpha = 0.1)
alpha |
transparency parameter, see ?rgb |
character string of colour
A function to return a transparent green colour.
transgreen(alpha = 0.1)
transgreen(alpha = 0.1)
alpha |
transparency parameter, see ?rgb |
character string of colour
A function to return a transparent red colour.
transred(alpha = 0.1)
transred(alpha = 0.1)
alpha |
transparency parameter, see ?rgb |
character string of colour
This is the base txtProgressBar but with a little modification to implement the label parameter for style=3. For full info see txtProgressBar
txtProgressBar2( min = 0, max = 1, initial = 0, char = "=", width = NA, title = "", label = "", style = 1 )
txtProgressBar2( min = 0, max = 1, initial = 0, char = "=", width = NA, title = "", label = "", style = 1 )
min |
min value for bar |
max |
max value for bar |
initial |
initial value for bar |
char |
the character (or character string) to form the progress bar. |
width |
progress bar width |
title |
ignored |
label |
text to put at the end of the bar |
style |
bar style |
A generic to be used for the purpose of user-defined adaptive MCMC schemes, updateAMCMC tells the MALA algorithm how to update the value of h. See lgcp vignette, codevignette("lgcp"), for further details on writing adaptive MCMC schemes.
updateAMCMC(obj, ...)
updateAMCMC(obj, ...)
obj |
an object |
... |
additional arguments |
method updateAMCMC
updateAMCMC.constanth, updateAMCMC.andrieuthomsh
Updates the andrieuthomsh adaptive scheme.
## S3 method for class 'andrieuthomsh' updateAMCMC(obj, ...)
## S3 method for class 'andrieuthomsh' updateAMCMC(obj, ...)
obj |
an object |
... |
additional arguments |
update and return current h for scheme
Andrieu C, Thoms J (2008). A tutorial on adaptive MCMC. Statistics and Computing, 18(4), 343-373.
Robbins H, Munro S (1951). A Stochastic Approximation Methods. The Annals of Mathematical Statistics, 22(3), 400-407.
Roberts G, Rosenthal J (2001). Optimal Scaling for Various Metropolis-Hastings Algorithms. Statistical Science, 16(4), 351-367.
Updates the constanth adaptive scheme.
## S3 method for class 'constanth' updateAMCMC(obj, ...)
## S3 method for class 'constanth' updateAMCMC(obj, ...)
obj |
an object |
... |
additional arguments |
update and return current h for scheme
Generic function to extract the variance of the latent field Y.
varfield(obj, ...)
varfield(obj, ...)
obj |
an object |
... |
additional arguments |
method meanfield
This is an accessor function for objects of class lgcpPredict
and returns the variance of the
field Y as an lgcpgrid object.
## S3 method for class 'lgcpPredict' varfield(obj, ...)
## S3 method for class 'lgcpPredict' varfield(obj, ...)
obj |
an object of class lgcpPredict |
... |
additional arguments |
returns the cell-wise variance of Y computed via Monte Carlo.
A function to return the variance of the latent field from a call to lgcpPredictINLA output.
## S3 method for class 'lgcpPredictINLA' varfield(obj, ...)
## S3 method for class 'lgcpPredictINLA' varfield(obj, ...)
obj |
an object of class lgcpPredictINLA |
... |
other arguments |
the variance of the latent field
Accessor function returning the observation window from objects of class lgcpPredict
. Note that for
computational purposes, the window of an stppp
object will be extended to accommodate the requirement that
the dimensions must be powers of 2. The function window.lgcpPredict
returns the extended window.
## S3 method for class 'lgcpPredict' window(x, ...)
## S3 method for class 'lgcpPredict' window(x, ...)
x |
an object of class lgcpPredict |
... |
additional arguments |
returns the observation window used durign computation
Population of Welsh counties
data(wpopdata)
data(wpopdata)
matrix
ONS
http://www.statistics.gov.uk/default.asp
Welsh town details: location
data(wtowncoords)
data(wtowncoords)
matrix
Wikipedia
Welsh town details: population
data(wtowns)
data(wtowns)
matrix
ONS
http://www.statistics.gov.uk/default.asp
Generic for extractign the 'x values' from an object.
xvals(obj, ...)
xvals(obj, ...)
obj |
an object of class spatialAtRisk |
... |
additional arguments |
the xvals method
yvals, zvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Default method for extracting 'x values' looks for $X, $x in that order.
## Default S3 method: xvals(obj, ...)
## Default S3 method: xvals(obj, ...)
obj |
an object |
... |
additional arguments |
the x values
xvals, yvals, zvals, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Method for extracting 'x values' from an object of class fromXYZ
## S3 method for class 'fromXYZ' xvals(obj, ...)
## S3 method for class 'fromXYZ' xvals(obj, ...)
obj |
a spatialAtRisk object |
... |
additional arguments |
the x values
xvals, yvals, zvals, xvals.default, yvals.default, zvals.default, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Gets the x-coordinates of the centroids of the prediction grid.
## S3 method for class 'lgcpPredict' xvals(obj, ...)
## S3 method for class 'lgcpPredict' xvals(obj, ...)
obj |
an object of class lgcpPredict |
... |
additional arguments |
the x coordinates of the centroids of the grid
Method for extracting 'x values' from an object of class spatialGridDataFrame
## S3 method for class 'SpatialGridDataFrame' xvals(obj, ...)
## S3 method for class 'SpatialGridDataFrame' xvals(obj, ...)
obj |
an object |
... |
additional arguments |
the x values
xvals, yvals, zvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
A function to change Gammas (white noise) into Ys (spatially correlated noise). Used in the MALA algorithm.
YfromGamma(Gamma, invrootQeigs, mu)
YfromGamma(Gamma, invrootQeigs, mu)
Gamma |
Gamma matrix |
invrootQeigs |
inverse square root of the eigenvectors of the precision matrix |
mu |
parameter of the latent Gaussian field |
Y
Generic for extractign the 'y values' from an object.
yvals(obj, ...)
yvals(obj, ...)
obj |
an object of class spatialAtRisk |
... |
additional arguments |
the yvals method
xvals, zvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Default method for extracting 'y values' looks for $Y, $y in that order.
## Default S3 method: yvals(obj, ...)
## Default S3 method: yvals(obj, ...)
obj |
an object |
... |
additional arguments |
the y values
xvals, yvals, zvals, xvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Method for extracting 'y values' from an object of class fromXYZ
## S3 method for class 'fromXYZ' yvals(obj, ...)
## S3 method for class 'fromXYZ' yvals(obj, ...)
obj |
a spatialAtRisk object |
... |
additional arguments |
the y values
xvals, yvals, zvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Gets the y-coordinates of the centroids of the prediction grid.
## S3 method for class 'lgcpPredict' yvals(obj, ...)
## S3 method for class 'lgcpPredict' yvals(obj, ...)
obj |
an object of class lgcpPredict |
... |
additional arguments |
the y coordinates of the centroids of the grid
Method for extracting 'y values' from an object of class SpatialGridDataFrame
## S3 method for class 'SpatialGridDataFrame' yvals(obj, ...)
## S3 method for class 'SpatialGridDataFrame' yvals(obj, ...)
obj |
an object |
... |
additional arguments |
the y values
xvals, yvals, zvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Generic for extractign the 'z values' from an object.
zvals(obj, ...)
zvals(obj, ...)
obj |
an object |
... |
additional arguments |
the zvals method
xvals, yvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Default method for extracting 'z values' looks for $Zm, $Z, $z in that order.
## Default S3 method: zvals(obj, ...)
## Default S3 method: zvals(obj, ...)
obj |
an object |
... |
additional arguments |
the x values
xvals, yvals, zvals, xvals.default, yvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Method for extracting 'z values' from an object of class fromXYZ
## S3 method for class 'fromXYZ' zvals(obj, ...)
## S3 method for class 'fromXYZ' zvals(obj, ...)
obj |
a spatialAtRisk object |
... |
additional arguments |
the z values
xvals, yvals, zvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame, zvals.SpatialGridDataFrame
Method for extracting 'z values' from an object of class SpatialGridDataFrame
## S3 method for class 'SpatialGridDataFrame' zvals(obj, ...)
## S3 method for class 'SpatialGridDataFrame' zvals(obj, ...)
obj |
an object |
... |
additional arguments |
the z values
xvals, yvals, zvals, xvals.default, yvals.default, zvals.default, xvals.fromXYZ, yvals.fromXYZ, zvals.fromXYZ, xvals.SpatialGridDataFrame, yvals.SpatialGridDataFrame